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', () => {
21 'test_forums.oleo': 'Oleo'
26 internals.results = render(Forum, {
31 label: 'test_forums.oleo',
34 id: '0575d375-5bea-44df-a597-bee3adda624d',
35 title: 'Very forumy topic',
37 updated_at: Date.now()
40 id: 'aeeb56e4-751d-4400-8aa7-d0f3a20d4e25',
41 title: 'Only mildly forum-like',
43 updated_at: Date.now()
51 test('It should display the forum glyph and label', () => {
52 expect(internals.results.getByText(/^\s*☽\s*Oleo\s*$/)).toBeVisible();
55 test('It should display the topics', () => {
56 expect(internals.results.getByText('Very forumy topic')).toBeVisible();
57 expect(internals.results.getByText('Only mildly forum-like')).toBeVisible();
60 test('It should link to the topics', () => {
61 expect(internals.results.getByText('Very forumy topic').closest('a')).toHaveAttribute(
63 '/t/0575d375-5bea-44df-a597-bee3adda624d'
65 expect(internals.results.getByText('Only mildly forum-like').closest('a')).toHaveAttribute(
67 '/t/aeeb56e4-751d-4400-8aa7-d0f3a20d4e25'