From 73e12fe8ae059ef70bbdf8716af421cb72aec76c Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Tue, 24 Oct 2023 19:26:47 +0200
Subject: refactor(components): rewrite Breadcrumbs component

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

(limited to 'src/components/organisms/nav/breadcrumbs/breadcrumbs.test.tsx')

diff --git a/src/components/organisms/nav/breadcrumbs/breadcrumbs.test.tsx b/src/components/organisms/nav/breadcrumbs/breadcrumbs.test.tsx
new file mode 100644
index 0000000..40bb1b8
--- /dev/null
+++ b/src/components/organisms/nav/breadcrumbs/breadcrumbs.test.tsx
@@ -0,0 +1,22 @@
+import { describe, expect, it } from '@jest/globals';
+import { render, screen as rtlScreen } from '@testing-library/react';
+import { Breadcrumbs, type BreadcrumbsItem } from './breadcrumbs';
+
+const items: BreadcrumbsItem[] = [
+  { id: 'home', url: '#', name: 'Home' },
+  { id: 'blog', url: '#', name: 'Blog' },
+  { id: 'post1', url: '#', name: 'A Post' },
+];
+
+describe('Breadcrumbs', () => {
+  it('renders a list of items wrapped in a nav element', () => {
+    const ariaLabel = 'error tempore iure';
+
+    render(<Breadcrumbs aria-label={ariaLabel} items={items} />);
+
+    expect(rtlScreen.getByRole('navigation')).toHaveAccessibleName(ariaLabel);
+    expect(rtlScreen.getAllByRole('listitem')).toHaveLength(items.length);
+    // The last item should not be linked
+    expect(rtlScreen.getAllByRole('link')).toHaveLength(items.length - 1);
+  });
+});
-- 
cgit v1.2.3

