diff options
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/error_block/error_block.svelte | 2 | ||||
| -rw-r--r-- | src/components/error_block/error_block.test.js | 10 | ||||
| -rw-r--r-- | src/components/post/post.test.js | 19 | ||||
| -rw-r--r-- | src/components/topic/topic.svelte | 2 | ||||
| -rw-r--r-- | src/components/topic/topic.test.js | 8 |
5 files changed, 38 insertions, 3 deletions
diff --git a/src/components/error_block/error_block.svelte b/src/components/error_block/error_block.svelte index 3a43a1e..e38bfae 100644 --- a/src/components/error_block/error_block.svelte +++ b/src/components/error_block/error_block.svelte @@ -1,6 +1,6 @@ <script> import { _ } from 'svelte-i18n'; - export let message; + export let message = null; import { blink } from '$/animations/blink'; </script> diff --git a/src/components/error_block/error_block.test.js b/src/components/error_block/error_block.test.js index 1d7a7ac..43c9331 100644 --- a/src/components/error_block/error_block.test.js +++ b/src/components/error_block/error_block.test.js @@ -7,7 +7,7 @@ import ErrorBlock from './error_block.svelte'; describe('Error Block component', () => { - test('Should act as an image', () => { + test('Should display error message sent', () => { const results = render(ErrorBlock, { props: { message: 'An error has, sadly, destroyed everything.' @@ -16,5 +16,13 @@ describe('Error Block component', () => { expect(results.getByText('An error has, sadly, destroyed everything.')) .toBeVisible(); }); + + test('Should display default error message', () => { + + const results = render(ErrorBlock); + + expect(results.getByText('Unknown error has occurred. Panic!')) + .toBeVisible(); + }); }); diff --git a/src/components/post/post.test.js b/src/components/post/post.test.js index 9ab4848..e158ce9 100644 --- a/src/components/post/post.test.js +++ b/src/components/post/post.test.js @@ -102,4 +102,23 @@ describe('Post component', () => { 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(); + }); }); diff --git a/src/components/topic/topic.svelte b/src/components/topic/topic.svelte index 0b73d44..c0dbfbc 100644 --- a/src/components/topic/topic.svelte +++ b/src/components/topic/topic.svelte @@ -5,7 +5,7 @@ import Post from '$/components/post/post.svelte'; import { readableTime } from '$/utils/readable_time.js'; - $: remainingTime = topic ? topic.updated_at + topic.ttl - Date.now() : 0; + $: remainingTime = topic.updated_at + topic.ttl - Date.now(); $: remaining = readableTime(remainingTime); </script> diff --git a/src/components/topic/topic.test.js b/src/components/topic/topic.test.js index 83eeba3..ca1abfb 100644 --- a/src/components/topic/topic.test.js +++ b/src/components/topic/topic.test.js @@ -105,6 +105,14 @@ describe('Topic component', () => { .toBeVisible(); }); + test('Should send index and countt to posts', () => { + + expect(internals.results.getByTitle('Post 1 of 2 by past_user')) + .toBeVisible(); + expect(internals.results.getByTitle('Post 2 of 2 by future_user')) + .toBeVisible(); + }); + describe('Forum link', () => { test('Should show forum if the post has one', () => { |