aboutsummaryrefslogtreecommitdiff
path: root/src/components/post
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/post')
-rw-r--r--src/components/post/post.svelte2
-rw-r--r--src/components/post/post.test.js22
2 files changed, 23 insertions, 1 deletions
diff --git a/src/components/post/post.svelte b/src/components/post/post.svelte
index fd9e580..66901af 100644
--- a/src/components/post/post.svelte
+++ b/src/components/post/post.svelte
@@ -23,9 +23,11 @@
{timestampToISO(post.created_at)}
</a>
</time>
+ {#if post.topic}
<span>
({$_('post.topic_location')} <a href="/t/{post.topic.id}">{post.topic.title}</a>.)
</span>
+ {/if}
</aside>
<article
class="e-content"
diff --git a/src/components/post/post.test.js b/src/components/post/post.test.js
index 3a76482..9ab4848 100644
--- a/src/components/post/post.test.js
+++ b/src/components/post/post.test.js
@@ -1,6 +1,6 @@
import '@testing-library/jest-dom/extend-expect';
-import { render } from '@testing-library/svelte';
+import { cleanup, render } from '@testing-library/svelte';
import '$/config/i18n';
import Post from './post.svelte';
@@ -19,6 +19,15 @@ const internals = {
title: 'Parent topic, yes'
}
},
+ postWithoutTopic: {
+ id: '9e52e38e-9007-4a20-bbf1-cea4e2f950f3',
+ text: 'This is a post without a topic',
+ created_at: Date.UTC(2022, 8, 21, 4, 3, 1, 340).valueOf(),
+ author: {
+ handle: 'my_normal_user',
+ id: '121f8f97-de02-4102-b25d-f34fd619009b'
+ }
+ },
results: null
};
@@ -82,4 +91,15 @@ describe('Post component', () => {
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);
+ });
});