]>
git.r.bdr.sh - rbdr/forum/blob - src/components/forum/forum.test.js
832fd6cf79cfccdda234f15645217dec2daf0e37
1 import '@testing-library/jest-dom/extend-expect';
3 import { addMessages
} from 'svelte-i18n';
5 import { render
} from '@testing-library/svelte';
6 import '$/config/i18n';
8 import Forum
from './forum.svelte';
14 describe('Forum component', () => {
19 'test_forums.oleo': 'Oleo'
25 internals
.results
= render(Forum
, { props: {
29 label: 'test_forums.oleo',
32 id: '0575d375-5bea-44df-a597-bee3adda624d',
33 title: 'Very forumy topic',
35 updated_at: Date
.now()
38 id: 'aeeb56e4-751d-4400-8aa7-d0f3a20d4e25',
39 title: 'Only mildly forum-like',
41 updated_at: Date
.now()
48 test('It should display the forum glyph and label', () => {
50 expect(internals
.results
.getByText(/^\s*☽\s*Oleo\s*$/))
54 test('It should display the topics', () => {
56 expect(internals
.results
.getByText('Very forumy topic'))
58 expect(internals
.results
.getByText('Only mildly forum-like'))
62 test('It should link to the topics', () => {
64 expect(internals
.results
.getByText('Very forumy topic').closest('a'))
65 .toHaveAttribute('href', '/t/0575d375-5bea-44df-a597-bee3adda624d');
66 expect(internals
.results
.getByText('Only mildly forum-like').closest('a'))
67 .toHaveAttribute('href', '/t/aeeb56e4-751d-4400-8aa7-d0f3a20d4e25');