diff --git a/src/components/AppBar/AppBar.spec.js b/src/components/AppBar/AppBar.spec.js new file mode 100644 index 0000000..9ed07cc --- /dev/null +++ b/src/components/AppBar/AppBar.spec.js @@ -0,0 +1,53 @@ +import React from 'react' +import { render } from '@testing-library/react' + +import AppBar from './AppBar' + +const defaultProps = { children: '' } + +describe('', () => { + it('should render header', () => { + const { container } = render() + const headerEl = container.firstChild + + expect(headerEl.tagName).toBe('HEADER') + }) + + it('should render children', () => { + const { container } = render(A nice app bar) + const headerEl = container.firstChild + + expect(headerEl).toHaveTextContent('A nice app bar') + }) + + it('should render fixed prop properly', () => { + const { container, rerender } = render() + const headerEl = container.firstChild + + expect(headerEl).toHaveStyleRule('position', 'fixed') + + rerender() + + expect(headerEl).toHaveStyleRule('position', 'absolute') + }) + + it('should custom style', () => { + const { container } = render(( + + )) + const headerEl = container.firstChild + + expect(headerEl).toHaveAttribute('style', 'background-color: papayawhip;') + }) + + it('should render custom props', () => { + const customProps = { title: 'cool-header' } + const { container } = render() + const headerEl = container.firstChild + + expect(headerEl).toHaveAttribute('title', 'cool-header') + }) +})