diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-05-01 00:56:06 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-05-01 00:56:06 +0200 |
| commit | a7cf03c192470cbab13edeb1aec99e0c66dede10 (patch) | |
| tree | 581b4430d1de958dcb666bae80a7678332134602 /src/components/forum_list | |
| parent | 010f307346e525ac2e4239a0549d2c1a4d6d102b (diff) | |
Update / use typescript
Diffstat (limited to 'src/components/forum_list')
| -rw-r--r-- | src/components/forum_list/.forum_list.svelte.icloud | bin | 0 -> 167 bytes | |||
| -rw-r--r-- | src/components/forum_list/.forum_list.test.js.icloud | bin | 0 -> 168 bytes | |||
| -rw-r--r-- | src/components/forum_list/forum_list.svelte | 42 | ||||
| -rw-r--r-- | src/components/forum_list/forum_list.test.js | 90 |
4 files changed, 0 insertions, 132 deletions
diff --git a/src/components/forum_list/.forum_list.svelte.icloud b/src/components/forum_list/.forum_list.svelte.icloud Binary files differnew file mode 100644 index 0000000..5ee5709 --- /dev/null +++ b/src/components/forum_list/.forum_list.svelte.icloud diff --git a/src/components/forum_list/.forum_list.test.js.icloud b/src/components/forum_list/.forum_list.test.js.icloud Binary files differnew file mode 100644 index 0000000..e4c26fc --- /dev/null +++ b/src/components/forum_list/.forum_list.test.js.icloud diff --git a/src/components/forum_list/forum_list.svelte b/src/components/forum_list/forum_list.svelte deleted file mode 100644 index aeb389e..0000000 --- a/src/components/forum_list/forum_list.svelte +++ /dev/null @@ -1,42 +0,0 @@ -<script> - import { _ } from 'svelte-i18n'; - export let forums; - - $: sortedForums = forums.slice().sort((a, b) => a.position - b.position); -</script> - -<ul> - {#each sortedForums as forum} - <li> - <a href="/f/{forum.id}"> - <span aria-hidden="true" class="navigation-glyph {forum.glyph}">{forum.glyph}</span> - <span class="navigation-label">{$_(forum.label)}</span> - </a> - </li> - {/each} -</ul> - -<style> - ul { - padding: 0; - } - - li { - display: block; - text-align: left; - margin-bottom: 20px; - } - - .navigation-glyph { - font-size: 1.5rem; - display: block; - } - - .☽ { - font-size: 2rem; - } - - a { - text-decoration: none; - } -</style> diff --git a/src/components/forum_list/forum_list.test.js b/src/components/forum_list/forum_list.test.js deleted file mode 100644 index a165f28..0000000 --- a/src/components/forum_list/forum_list.test.js +++ /dev/null @@ -1,90 +0,0 @@ -import '@testing-library/jest-dom/extend-expect'; - -import { render } from '@testing-library/svelte'; -import '$/config/i18n'; - -import { addMessages } from 'svelte-i18n'; - -import ForumList from './forum_list.svelte'; - -const internals = { - results: null -}; - -describe('Forum List component', () => { - - beforeAll(() => { - - addMessages('en', { - 'test_forums.yes': 'Absolutely yes', - 'test_forums.no': 'No, not at all', - 'test_forums.maybe': 'OK, maybe...' - }); - }); - - beforeEach(() => { - - internals.results = render(ForumList, { props: { - forums: [ - { - id: 'yes', - glyph: '☆', - label: 'test_forums.yes', - position: 2 - }, - { - id: 'no', - glyph: '◯', - label: 'test_forums.no', - position: 0 - }, - { - id: 'maybe', - glyph: '⏀', - label: 'test_forums.maybe', - position: 1 - } - ] - } }); - }); - - test('It should display each forum according to their position', () => { - - expect(internals.results.container) - .toHaveTextContent(/^◯.+⏀.+☆.+$/); - }); - - test('It should translate forum labels', () => { - - expect(internals.results.getByText('Absolutely yes')).toBeVisible(); - expect(internals.results.getByText('No, not at all')).toBeVisible(); - expect(internals.results.getByText('OK, maybe...')).toBeVisible(); - }); - - test('It should display forum glyphs', () => { - - expect(internals.results.getByText('☆')).toBeVisible(); - expect(internals.results.getByText('◯')).toBeVisible(); - expect(internals.results.getByText('⏀')).toBeVisible(); - }); - - test('Label should be a permalink to the forum', () => { - - expect(internals.results.getByText('Absolutely yes').closest('a')) - .toHaveAttribute('href', '/f/yes'); - expect(internals.results.getByText('No, not at all').closest('a')) - .toHaveAttribute('href', '/f/no'); - expect(internals.results.getByText('OK, maybe...').closest('a')) - .toHaveAttribute('href', '/f/maybe'); - }); - - test('Glyph should be a permalink to the forum', () => { - - expect(internals.results.getByText('☆').closest('a')) - .toHaveAttribute('href', '/f/yes'); - expect(internals.results.getByText('◯').closest('a')) - .toHaveAttribute('href', '/f/no'); - expect(internals.results.getByText('⏀').closest('a')) - .toHaveAttribute('href', '/f/maybe'); - }); -}); |