]>
git.r.bdr.sh - rbdr/forum/blob - src/components/tag/tag.test.js
a2b6e0dcfddb7ce183538f7e5caee8079a9af50e
1 import '@testing-library/jest-dom/extend-expect';
3 import { render
} from '@testing-library/svelte';
4 import '$/config/i18n';
6 import Tag
from './tag.svelte';
12 describe('Tag component', () => {
16 internals
.results
= render(Tag
, { props: {
21 id: 'eb751e7a-5777-46c3-b81b-cc66546d5157',
22 title: 'A single topic',
24 updated_at: Date
.now()
27 id: 'b4a5613c-237b-4147-a867-9c105d51e365',
28 title: 'And its companion',
30 updated_at: Date
.now()
37 test('It should display the tag title', () => {
39 expect(internals
.results
.getByText('Tag: avocado'))
43 test('It should display the topics', () => {
45 expect(internals
.results
.getByText('A single topic'))
47 expect(internals
.results
.getByText('And its companion'))
51 test('It should link to the topics', () => {
53 expect(internals
.results
.getByText('A single topic').closest('a'))
54 .toHaveAttribute('href', '/t/eb751e7a-5777-46c3-b81b-cc66546d5157');
55 expect(internals
.results
.getByText('And its companion').closest('a'))
56 .toHaveAttribute('href', '/t/b4a5613c-237b-4147-a867-9c105d51e365');