]>
git.r.bdr.sh - rbdr/forum/blob - src/components/language_selector/language_selector.test.js
baf11bb829073f872a09d43fbb8453d25d47d2e1
1 import '@testing-library/jest-dom/extend-expect';
3 import { locale
} from 'svelte-i18n';
4 import { act
, render
} from '@testing-library/svelte';
5 import userEvent
from '@testing-library/user-event';
6 import '$/config/i18n';
8 import LanguageSelector
from './language_selector.svelte';
14 describe('Language Selector component', () => {
18 internals
.results
= render(LanguageSelector
);
21 test('Should display languages in their own language', () => {
23 expect(internals
.results
.getByText('English'))
25 expect(internals
.results
.getByText('Español'))
29 test('Should change locale when a language is selected', async () => {
31 locale
.subscribe((localeValue
) => {
33 expect(localeValue
).toBe('en-US');
35 const spanish
= internals
.results
.getByText('Español');
36 userEvent
.selectOptions(spanish
.closest('select'), spanish
);
38 locale
.subscribe((localeValue
) => {
40 expect(localeValue
).toBe('es');