]>
git.r.bdr.sh - rbdr/forum/blob - src/components/post/post.test.js
3a764824757bc0c9059525e96b8ecb3e86bab2c2
1 import '@testing-library/jest-dom/extend-expect';
3 import { render
} from '@testing-library/svelte';
4 import '$/config/i18n';
6 import Post
from './post.svelte';
10 id: 'e5a19d53-4c9a-4be8-afa5-00942ea3afa4',
11 text: 'This is an example post qwerty',
12 created_at: Date
.UTC(2021, 3, 19, 6, 6, 6, 666).valueOf(),
14 handle: 'very_cool_user',
15 id: 'b01bdb48-4b5e-46a4-97f3-6db789bcd33b'
18 id: '35d3c3eb-e486-42ef-994c-d8ab1f1e167a',
19 title: 'Parent topic, yes'
26 describe('Post component', () => {
30 internals
.results
= render(Post
, { props: {
31 post: internals
.basicPost
35 test('Should display the text of the post', () => {
37 expect(internals
.results
.getByText('This is an example post qwerty')).toBeVisible();
40 test('Should display date of the post', () => {
42 expect(internals
.results
.getByText('2021-04-19T06:06:06.666Z'))
46 test('Date of post should be a permalink to the post', () => {
48 expect(internals
.results
.getByText('2021-04-19T06:06:06.666Z').closest('a'))
49 .toHaveAttribute('href', '/p/e5a19d53-4c9a-4be8-afa5-00942ea3afa4');
52 test('Should display the glyph of the post author', () => {
54 const glyphicon
= internals
.results
.getByRole('img');
59 .toHaveTextContent(/^. . . .$/);
62 test('Should display author handle', () => {
64 expect(internals
.results
.getByText('very_cool_user'))
68 test('Author handle should have a permalink to topic', () => {
70 expect(internals
.results
.getByText('very_cool_user').closest('a'))
71 .toHaveAttribute('href', '/a/very_cool_user');
74 test('Should display parent topic title', () => {
76 expect(internals
.results
.getByText('Parent topic, yes'))
80 test('Parent topic title should have a permalink to topic', () => {
82 expect(internals
.results
.getByText('Parent topic, yes').closest('a'))
83 .toHaveAttribute('href', '/t/35d3c3eb-e486-42ef-994c-d8ab1f1e167a');