]>
Commit | Line | Data |
---|---|---|
a7cf03c1 RBR |
1 | /** |
2 | * @jest-environment jsdom | |
3 | */ | |
4 | ||
47b0bfe4 RBR |
5 | import '@testing-library/jest-dom/extend-expect'; |
6 | ||
7 | import { render } from '@testing-library/svelte'; | |
a7cf03c1 | 8 | import '$lib/i18n'; |
47b0bfe4 RBR |
9 | |
10 | import TopicSummary from './topic_summary.svelte'; | |
11 | ||
12 | const internals = { | |
cac85db0 | 13 | results: null |
47b0bfe4 RBR |
14 | }; |
15 | ||
16 | describe('Topic Summary component', () => { | |
cac85db0 RBR |
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 | }); | |
47b0bfe4 | 44 | }); |