2 * @jest-environment jsdom
5 import '@testing-library/jest-dom/extend-expect';
7 import { addMessages } from 'svelte-i18n';
9 import { render } from '@testing-library/svelte';
12 import Forum from './forum.svelte';
18 describe('Forum component', () => {
23 'test_forums.oleo': 'Oleo'
29 internals.results = render(Forum, { props: {
33 label: 'test_forums.oleo',
36 id: '0575d375-5bea-44df-a597-bee3adda624d',
37 title: 'Very forumy topic',
39 updated_at: Date.now()
42 id: 'aeeb56e4-751d-4400-8aa7-d0f3a20d4e25',
43 title: 'Only mildly forum-like',
45 updated_at: Date.now()
52 test('It should display the forum glyph and label', () => {
54 expect(internals.results.getByText(/^\s*☽\s*Oleo\s*$/))
58 test('It should display the topics', () => {
60 expect(internals.results.getByText('Very forumy topic'))
62 expect(internals.results.getByText('Only mildly forum-like'))
66 test('It should link to the topics', () => {
68 expect(internals.results.getByText('Very forumy topic').closest('a'))
69 .toHaveAttribute('href', '/t/0575d375-5bea-44df-a597-bee3adda624d');
70 expect(internals.results.getByText('Only mildly forum-like').closest('a'))
71 .toHaveAttribute('href', '/t/aeeb56e4-751d-4400-8aa7-d0f3a20d4e25');