]> git.r.bdr.sh - rbdr/forum/blobdiff - src/lib/components/forum_list/forum_list.test.ts
Use supabase
[rbdr/forum] / src / lib / components / forum_list / forum_list.test.ts
index be7d44907af8e3e85636ec4fb4429367c3f1fb9f..1670b5c09b39b4c99610fcb86d2abd489068182b 100644 (file)
@@ -12,83 +12,79 @@ import { addMessages } from 'svelte-i18n';
 import ForumList from './forum_list.svelte';
 
 const internals = {
-  results: null
+       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');
-  });
+       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');
+       });
 });