]>
Commit | Line | Data |
---|---|---|
47b0bfe4 RBR |
1 | import '@testing-library/jest-dom/extend-expect'; |
2 | ||
3 | import { render } from '@testing-library/svelte'; | |
4 | import '$/config/i18n'; | |
5 | ||
6 | import Tag from './tag.svelte'; | |
7 | ||
8 | const internals = { | |
9 | results: null | |
10 | }; | |
11 | ||
12 | describe('Tag component', () => { | |
13 | ||
14 | beforeEach(() => { | |
15 | ||
16 | internals.results = render(Tag, { props: { | |
17 | tag: { | |
18 | id: 'avocado', | |
19 | topics: [ | |
20 | { | |
21 | id: 'eb751e7a-5777-46c3-b81b-cc66546d5157', | |
22 | title: 'A single topic', | |
23 | ttl: 160 * 1000, | |
24 | updated_at: Date.now() | |
25 | }, | |
26 | { | |
27 | id: 'b4a5613c-237b-4147-a867-9c105d51e365', | |
28 | title: 'And its companion', | |
29 | ttl: 160 * 1000, | |
30 | updated_at: Date.now() | |
31 | } | |
32 | ] | |
33 | } | |
34 | } }); | |
35 | }); | |
36 | ||
37 | test('It should display the tag title', () => { | |
38 | ||
39 | expect(internals.results.getByText('Tag: avocado')) | |
40 | .toBeVisible(); | |
41 | }); | |
42 | ||
43 | test('It should display the topics', () => { | |
44 | ||
45 | expect(internals.results.getByText('A single topic')) | |
46 | .toBeVisible(); | |
47 | expect(internals.results.getByText('And its companion')) | |
48 | .toBeVisible(); | |
49 | }); | |
4e6be9f4 RBR |
50 | |
51 | test('It should link to the topics', () => { | |
52 | ||
53 | expect(internals.results.getByText('A single topic').closest('a')) | |
54 | .toHaveAttribute('href', '/t/eb751e7a-5777-46c3-b81b-cc66546d5157'); | |
55 | expect(internals.results.getByText('And its companion').closest('a')) | |
56 | .toHaveAttribute('href', '/t/b4a5613c-237b-4147-a867-9c105d51e365'); | |
57 | }); | |
47b0bfe4 | 58 | }); |