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