From cac85db02ff00732cf75d473dc3411332f33d845 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Sun, 1 May 2022 01:02:58 +0200 Subject: Apply formatting --- src/lib/components/post/post.svelte | 10 +- src/lib/components/post/post.test.ts | 215 +++++++++++++++++------------------ 2 files changed, 108 insertions(+), 117 deletions(-) (limited to 'src/lib/components/post') diff --git a/src/lib/components/post/post.svelte b/src/lib/components/post/post.svelte index 4e6c28f..d909be1 100644 --- a/src/lib/components/post/post.svelte +++ b/src/lib/components/post/post.svelte @@ -23,11 +23,11 @@ {timestampToISO(post.created_at)} - {#if post.topic} - - ({$_('post.topic_location')} {post.topic.title}.) - - {/if} + {#if post.topic} + + ({$_('post.topic_location')} {post.topic.title}.) + + {/if}
{ - - beforeEach(() => { - - internals.results = render(Post, { props: { - post: internals.basicPost - } }); - }); - - test('Should display the text of the post', () => { - - expect(internals.results.getByText('This is an example post qwerty')).toBeVisible(); - }); - - test('Should display date of the post', () => { - - expect(internals.results.getByText('2021-04-19T06:06:06.666Z')) - .toBeVisible(); - }); - - test('Date of post should be a permalink to the post', () => { - - expect(internals.results.getByText('2021-04-19T06:06:06.666Z').closest('a')) - .toHaveAttribute('href', '/p/e5a19d53-4c9a-4be8-afa5-00942ea3afa4'); - }); - - test('Should display the glyph of the post author', () => { - - const glyphicon = internals.results.getByRole('img'); - - expect(glyphicon) - .toBeVisible(); - expect(glyphicon) - .toHaveTextContent(/^. . . .$/); - }); - - test('Should display author handle', () => { - - expect(internals.results.getByText('very_cool_user')) - .toBeVisible(); - }); - - test('Author handle should have a permalink to topic', () => { - - expect(internals.results.getByText('very_cool_user').closest('a')) - .toHaveAttribute('href', '/a/very_cool_user'); - }); - - test('Should display parent topic title', () => { - - expect(internals.results.getByText('Parent topic, yes')) - .toBeVisible(); - }); - - test('Parent topic title should have a permalink to topic', () => { - - expect(internals.results.getByText('Parent topic, yes').closest('a')) - .toHaveAttribute('href', '/t/35d3c3eb-e486-42ef-994c-d8ab1f1e167a'); - }); - - test('Parent topic title should have a permalink to topic', () => { - - cleanup(); - internals.results = render(Post, { props: { - post: internals.postWithoutTopic - } }); - - expect(internals.results.queryByText('Parent topic, yes')) - .toBe(null); - }); - - test('It should default to 1/1 when no index or count is passed', () => { - - expect(internals.results.getByTitle('Post 1 of 1 by very_cool_user')) - .toBeVisible(); - }); - - test('Parent topic title should have a permalink to topic', () => { - - cleanup(); - internals.results = render(Post, { props: { - index: 2, - count: 5, - post: internals.postWithoutTopic - } }); - - expect(internals.results.getByTitle('Post 3 of 5 by my_normal_user')) - .toBeVisible(); - }); + beforeEach(() => { + internals.results = render(Post, { + props: { + post: internals.basicPost + } + }); + }); + + test('Should display the text of the post', () => { + expect(internals.results.getByText('This is an example post qwerty')).toBeVisible(); + }); + + test('Should display date of the post', () => { + expect(internals.results.getByText('2021-04-19T06:06:06.666Z')).toBeVisible(); + }); + + test('Date of post should be a permalink to the post', () => { + expect(internals.results.getByText('2021-04-19T06:06:06.666Z').closest('a')).toHaveAttribute( + 'href', + '/p/e5a19d53-4c9a-4be8-afa5-00942ea3afa4' + ); + }); + + test('Should display the glyph of the post author', () => { + const glyphicon = internals.results.getByRole('img'); + + expect(glyphicon).toBeVisible(); + expect(glyphicon).toHaveTextContent(/^. . . .$/); + }); + + test('Should display author handle', () => { + expect(internals.results.getByText('very_cool_user')).toBeVisible(); + }); + + test('Author handle should have a permalink to topic', () => { + expect(internals.results.getByText('very_cool_user').closest('a')).toHaveAttribute( + 'href', + '/a/very_cool_user' + ); + }); + + test('Should display parent topic title', () => { + expect(internals.results.getByText('Parent topic, yes')).toBeVisible(); + }); + + test('Parent topic title should have a permalink to topic', () => { + expect(internals.results.getByText('Parent topic, yes').closest('a')).toHaveAttribute( + 'href', + '/t/35d3c3eb-e486-42ef-994c-d8ab1f1e167a' + ); + }); + + test('Parent topic title should have a permalink to topic', () => { + cleanup(); + internals.results = render(Post, { + props: { + post: internals.postWithoutTopic + } + }); + + expect(internals.results.queryByText('Parent topic, yes')).toBe(null); + }); + + test('It should default to 1/1 when no index or count is passed', () => { + expect(internals.results.getByTitle('Post 1 of 1 by very_cool_user')).toBeVisible(); + }); + + test('Parent topic title should have a permalink to topic', () => { + cleanup(); + internals.results = render(Post, { + props: { + index: 2, + count: 5, + post: internals.postWithoutTopic + } + }); + + expect(internals.results.getByTitle('Post 3 of 5 by my_normal_user')).toBeVisible(); + }); }); -- cgit