diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-04-14 19:12:54 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-04-14 19:24:46 +0200 |
| commit | 15fd9f4a6ecf947c7648c6b7865b97c40124fde1 (patch) | |
| tree | 528ef96e731b0dd9c3c15d398b75f2877473289e /src/components/organisms/toolbar/main-nav.test.tsx | |
| parent | 872b0c172a38db4f440dc6044eb1d5725c03abb1 (diff) | |
chore: add a MainNav component
Diffstat (limited to 'src/components/organisms/toolbar/main-nav.test.tsx')
| -rw-r--r-- | src/components/organisms/toolbar/main-nav.test.tsx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/components/organisms/toolbar/main-nav.test.tsx b/src/components/organisms/toolbar/main-nav.test.tsx new file mode 100644 index 0000000..6e50562 --- /dev/null +++ b/src/components/organisms/toolbar/main-nav.test.tsx @@ -0,0 +1,33 @@ +import { render, screen } from '@test-utils'; +import MainNav from './main-nav'; + +const items = [ + { id: 'home', label: 'Home', href: '/' }, + { id: 'blog', label: 'Blog', href: '/blog' }, + { id: 'contact', label: 'Contact', href: '/contact' }, +]; + +describe('MainNav', () => { + it('renders a checkbox to open main nav', () => { + render(<MainNav items={items} isActive={false} setIsActive={() => null} />); + expect(screen.getByRole('checkbox')).toHaveAccessibleName('Open menu'); + }); + + it('renders a checkbox to close main nav', () => { + render(<MainNav items={items} isActive={true} setIsActive={() => null} />); + expect(screen.getByRole('checkbox')).toHaveAccessibleName('Close menu'); + }); + + it('renders the correct number of items', () => { + render(<MainNav items={items} isActive={true} setIsActive={() => null} />); + expect(screen.getAllByRole('listitem')).toHaveLength(items.length); + }); + + it('renders some links with the right label', () => { + render(<MainNav items={items} isActive={true} setIsActive={() => null} />); + expect(screen.getByRole('link', { name: items[0].label })).toHaveAttribute( + 'href', + items[0].href + ); + }); +}); |
