2 * @jest-environment jsdom
5 import '@testing-library/jest-dom/extend-expect';
7 import { render } from '@testing-library/svelte';
10 import Tag from './tag.svelte';
16 describe('Tag component', () => {
20 internals.results = render(Tag, { props: {
25 id: 'eb751e7a-5777-46c3-b81b-cc66546d5157',
26 title: 'A single topic',
28 updated_at: Date.now()
31 id: 'b4a5613c-237b-4147-a867-9c105d51e365',
32 title: 'And its companion',
34 updated_at: Date.now()
41 test('It should display the tag title', () => {
43 expect(internals.results.getByText('Tag: avocado'))
47 test('It should display the topics', () => {
49 expect(internals.results.getByText('A single topic'))
51 expect(internals.results.getByText('And its companion'))
55 test('It should link to the topics', () => {
57 expect(internals.results.getByText('A single topic').closest('a'))
58 .toHaveAttribute('href', '/t/eb751e7a-5777-46c3-b81b-cc66546d5157');
59 expect(internals.results.getByText('And its companion').closest('a'))
60 .toHaveAttribute('href', '/t/b4a5613c-237b-4147-a867-9c105d51e365');