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', () => {
18 internals.results = render(Tag, {
24 id: 'eb751e7a-5777-46c3-b81b-cc66546d5157',
25 title: 'A single topic',
27 updated_at: Date.now()
30 id: 'b4a5613c-237b-4147-a867-9c105d51e365',
31 title: 'And its companion',
33 updated_at: Date.now()
41 test('It should display the tag title', () => {
42 expect(internals.results.getByText('Tag: avocado')).toBeVisible();
45 test('It should display the topics', () => {
46 expect(internals.results.getByText('A single topic')).toBeVisible();
47 expect(internals.results.getByText('And its companion')).toBeVisible();
50 test('It should link to the topics', () => {
51 expect(internals.results.getByText('A single topic').closest('a')).toHaveAttribute(
53 '/t/eb751e7a-5777-46c3-b81b-cc66546d5157'
55 expect(internals.results.getByText('And its companion').closest('a')).toHaveAttribute(
57 '/t/b4a5613c-237b-4147-a867-9c105d51e365'