2 * @jest-environment jsdom
5 import '@testing-library/jest-dom/extend-expect';
7 import { render } from '@testing-library/svelte';
10 import { addMessages } from 'svelte-i18n';
12 import ForumList from './forum_list.svelte';
18 describe('Forum List component', () => {
23 'test_forums.yes': 'Absolutely yes',
24 'test_forums.no': 'No, not at all',
25 'test_forums.maybe': 'OK, maybe...'
31 internals.results = render(ForumList, { props: {
36 label: 'test_forums.yes',
42 label: 'test_forums.no',
48 label: 'test_forums.maybe',
55 test('It should display each forum according to their position', () => {
57 expect(internals.results.container)
58 .toHaveTextContent(/^◯.+⏀.+☆.+$/);
61 test('It should translate forum labels', () => {
63 expect(internals.results.getByText('Absolutely yes')).toBeVisible();
64 expect(internals.results.getByText('No, not at all')).toBeVisible();
65 expect(internals.results.getByText('OK, maybe...')).toBeVisible();
68 test('It should display forum glyphs', () => {
70 expect(internals.results.getByText('☆')).toBeVisible();
71 expect(internals.results.getByText('◯')).toBeVisible();
72 expect(internals.results.getByText('⏀')).toBeVisible();
75 test('Label should be a permalink to the forum', () => {
77 expect(internals.results.getByText('Absolutely yes').closest('a'))
78 .toHaveAttribute('href', '/f/yes');
79 expect(internals.results.getByText('No, not at all').closest('a'))
80 .toHaveAttribute('href', '/f/no');
81 expect(internals.results.getByText('OK, maybe...').closest('a'))
82 .toHaveAttribute('href', '/f/maybe');
85 test('Glyph should be a permalink to the forum', () => {
87 expect(internals.results.getByText('☆').closest('a'))
88 .toHaveAttribute('href', '/f/yes');
89 expect(internals.results.getByText('◯').closest('a'))
90 .toHaveAttribute('href', '/f/no');
91 expect(internals.results.getByText('⏀').closest('a'))
92 .toHaveAttribute('href', '/f/maybe');