]>
Commit | Line | Data |
---|---|---|
1 | import '@testing-library/jest-dom/extend-expect'; | |
2 | ||
3 | import { render } from '@testing-library/svelte'; | |
4 | import '$/config/i18n'; | |
5 | ||
6 | import TopicSummary from './topic_summary.svelte'; | |
7 | ||
8 | const internals = { | |
9 | results: null | |
10 | }; | |
11 | ||
12 | describe('Topic Summary component', () => { | |
13 | ||
14 | beforeEach(() => { | |
15 | ||
16 | internals.results = render(TopicSummary, { props: { | |
17 | topic: { | |
18 | id: 'ea2431c8-5c1c-4ed0-907a-45e012696ab8', | |
19 | title: 'I sure am a test topic', | |
20 | ttl: 160 * 1000, | |
21 | updated_at: Date.now() | |
22 | } | |
23 | } }); | |
24 | }); | |
25 | ||
26 | test('It should display the title', () => { | |
27 | ||
28 | expect(internals.results.getByText('I sure am a test topic')) | |
29 | .toBeVisible(); | |
30 | }); | |
31 | ||
32 | test('Topic title should be a permalink', () => { | |
33 | ||
34 | expect(internals.results.getByText('I sure am a test topic').closest('a')) | |
35 | .toHaveAttribute('href', '/t/ea2431c8-5c1c-4ed0-907a-45e012696ab8'); | |
36 | }); | |
37 | ||
38 | test('It should display remaining time in readable format', () => { | |
39 | ||
40 | expect(internals.results.getByText(/2 minutes remaining/)) | |
41 | .toBeVisible(); | |
42 | }); | |
43 | }); |