]>
git.r.bdr.sh - rbdr/forum/blob - src/components/forum_list/forum_list.test.js
a165f285a1fe318ac6e2d56aceb181c0ea695e6f
1 import '@testing-library/jest-dom/extend-expect';
3 import { render
} from '@testing-library/svelte';
4 import '$/config/i18n';
6 import { addMessages
} from 'svelte-i18n';
8 import ForumList
from './forum_list.svelte';
14 describe('Forum List component', () => {
19 'test_forums.yes': 'Absolutely yes',
20 'test_forums.no': 'No, not at all',
21 'test_forums.maybe': 'OK, maybe...'
27 internals
.results
= render(ForumList
, { props: {
32 label: 'test_forums.yes',
38 label: 'test_forums.no',
44 label: 'test_forums.maybe',
51 test('It should display each forum according to their position', () => {
53 expect(internals
.results
.container
)
54 .toHaveTextContent(/^◯.+⏀.+☆.+$/);
57 test('It should translate forum labels', () => {
59 expect(internals
.results
.getByText('Absolutely yes')).toBeVisible();
60 expect(internals
.results
.getByText('No, not at all')).toBeVisible();
61 expect(internals
.results
.getByText('OK, maybe...')).toBeVisible();
64 test('It should display forum glyphs', () => {
66 expect(internals
.results
.getByText('☆')).toBeVisible();
67 expect(internals
.results
.getByText('◯')).toBeVisible();
68 expect(internals
.results
.getByText('⏀')).toBeVisible();
71 test('Label should be a permalink to the forum', () => {
73 expect(internals
.results
.getByText('Absolutely yes').closest('a'))
74 .toHaveAttribute('href', '/f/yes');
75 expect(internals
.results
.getByText('No, not at all').closest('a'))
76 .toHaveAttribute('href', '/f/no');
77 expect(internals
.results
.getByText('OK, maybe...').closest('a'))
78 .toHaveAttribute('href', '/f/maybe');
81 test('Glyph should be a permalink to the forum', () => {
83 expect(internals
.results
.getByText('☆').closest('a'))
84 .toHaveAttribute('href', '/f/yes');
85 expect(internals
.results
.getByText('◯').closest('a'))
86 .toHaveAttribute('href', '/f/no');
87 expect(internals
.results
.getByText('⏀').closest('a'))
88 .toHaveAttribute('href', '/f/maybe');