Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 24 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import Breadcrumb from './Breadcrumb.svelte'; |
||
2 | import {screen, render} from '@testing-library/svelte'; |
||
3 | |||
4 | it('renders the breadcrumb', () => { |
||
5 | const items = [{path: '/fairness', title: 'Fairness'}, {title: 'Anything'}]; |
||
6 | render(Breadcrumb, {items}); |
||
7 | |||
8 | // Check that current page is the one without path. |
||
9 | const listItems = screen.getAllByRole('listitem'); |
||
10 | // needs to be trim because of whitespace from listitem and if... |
||
11 | const listItemNames = listItems.map((li) => li.textContent.trim()); |
||
12 | |||
13 | expect(listItems).toHaveLength(3); |
||
14 | expect(listItemNames).toMatchInlineSnapshot(` |
||
15 | Array [ |
||
16 | "Permacoop", |
||
17 | "Fairness", |
||
18 | "Anything", |
||
19 | ] |
||
20 | `); |
||
21 | |||
22 | // Check that active item is "Anything". |
||
23 | expect(screen.getByText(/anything/i).classList.contains('active')).toBe(true); |
||
24 | }); |
||
25 |