aboutsummaryrefslogtreecommitdiff
path: root/src/lib/components/actions
diff options
context:
space:
mode:
authorRuben Beltran del Rio <ruben@unlimited.pizza>2022-05-01 00:56:06 +0200
committerRuben Beltran del Rio <ruben@unlimited.pizza>2022-05-01 00:56:06 +0200
commita7cf03c192470cbab13edeb1aec99e0c66dede10 (patch)
tree581b4430d1de958dcb666bae80a7678332134602 /src/lib/components/actions
parent010f307346e525ac2e4239a0549d2c1a4d6d102b (diff)
Update / use typescript
Diffstat (limited to 'src/lib/components/actions')
-rw-r--r--src/lib/components/actions/topic.svelte25
-rw-r--r--src/lib/components/actions/topic.test.ts29
2 files changed, 54 insertions, 0 deletions
diff --git a/src/lib/components/actions/topic.svelte b/src/lib/components/actions/topic.svelte
new file mode 100644
index 0000000..1311d06
--- /dev/null
+++ b/src/lib/components/actions/topic.svelte
@@ -0,0 +1,25 @@
+<script lang="ts">
+ import type { TopicAction } from '$lib/stores/action';
+ export let actions: TopicAction;
+
+ import { _ } from 'svelte-i18n';
+</script>
+
+<li>
+ <a href="/reply/{actions.id}" title={$_('header.action.reply.title')}>
+ {@html $_('header.action.reply.display')}
+ </a>
+</li>
+
+<style>
+ li {
+ display: inline;
+ margin: 5px;
+ }
+
+ a {
+ text-decoration: none;
+ line-height: 3em;
+ display: inline-block;
+ }
+</style>
diff --git a/src/lib/components/actions/topic.test.ts b/src/lib/components/actions/topic.test.ts
new file mode 100644
index 0000000..0037a7f
--- /dev/null
+++ b/src/lib/components/actions/topic.test.ts
@@ -0,0 +1,29 @@
+/**
+ * @jest-environment jsdom
+ */
+
+import '@testing-library/jest-dom/extend-expect';
+
+import { render } from '@testing-library/svelte';
+import '$lib/i18n';
+
+import Topic from './topic.svelte';
+
+const internals = {
+ results: null
+};
+
+describe('Topic Actions component', () => {
+
+ test('Should link to reply page', () => {
+
+ const results = render(Topic, { props: {
+ actions: {
+ id: '8ebaa211-fd9b-423a-8b4f-b57622007fde'
+ }
+ } });
+
+ expect(results.getByTitle('Reply').closest('a'))
+ .toHaveAttribute('href', '/reply/8ebaa211-fd9b-423a-8b4f-b57622007fde');
+ });
+});