2 * @jest-environment jsdom
5 import '@testing-library/jest-dom/extend-expect';
7 import { render } from '@testing-library/svelte';
10 import TopicSummary from './topic_summary.svelte';
16 describe('Topic Summary component', () => {
20 internals.results = render(TopicSummary, { props: {
22 id: 'ea2431c8-5c1c-4ed0-907a-45e012696ab8',
23 title: 'I sure am a test topic',
25 updated_at: Date.now()
30 test('It should display the title', () => {
32 expect(internals.results.getByText('I sure am a test topic'))
36 test('Topic title should be a permalink', () => {
38 expect(internals.results.getByText('I sure am a test topic').closest('a'))
39 .toHaveAttribute('href', '/t/ea2431c8-5c1c-4ed0-907a-45e012696ab8');
42 test('It should display remaining time in readable format', () => {
44 expect(internals.results.getByText(/2 minutes remaining/))