Passed
Pull Request — master (#277)
by
unknown
02:57 queued 01:15
created

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

Complexity

Total Complexity 3
Complexity/F 1

Size

Lines of Code 31
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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