Passed
Pull Request — master (#111)
by Nicolas
01:41
created

client/src/components/Breadcrumb.spec.js   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 24
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 10
mnd 0
bc 0
fnc 2
dl 0
loc 24
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 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