From 15fd9f4a6ecf947c7648c6b7865b97c40124fde1 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Thu, 14 Apr 2022 19:12:54 +0200
Subject: chore: add a MainNav component

---
 src/components/organisms/toolbar/main-nav.test.tsx | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 src/components/organisms/toolbar/main-nav.test.tsx

(limited to 'src/components/organisms/toolbar/main-nav.test.tsx')

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
+    );
+  });
+});
-- 
cgit v1.2.3

