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

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

Complexity

Total Complexity 3
Complexity/F 1

Size

Lines of Code 27
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 16
mnd 0
bc 0
fnc 3
dl 0
loc 27
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
1
import '@testing-library/jest-dom/extend-expect';
2
import ServerErrors from './ServerErrors.svelte';
3
import {screen, render} from '@testing-library/svelte';
4
5
it('renders nothing with no error.', () => {
6
  render(ServerErrors, {errors: []});
7
8
  expect(
9
    screen.queryByText('Une erreur est survenue !')
10
  ).not.toBeInTheDocument();
11
});
12
13
it('renders the given errors', () => {
14
  const errors = ['first error', 'second error'];
15
  render(ServerErrors, {errors});
16
17
  const listItems = screen.getAllByRole('listitem');
18
  const listItemErrors = listItems.map((item) => item.textContent);
19
  expect(listItems).toHaveLength(2);
20
  expect(listItemErrors).toMatchInlineSnapshot(`
21
  Array [
22
    "first error",
23
    "second error",
24
  ]
25
`);
26
  expect(screen.getByText(/Une erreur est survenue !/i)).toBeInTheDocument();
27
});
28