2 * @jest-environment jsdom
5 import '@testing-library/jest-dom/extend-expect';
7 import { locale } from 'svelte-i18n';
8 import { act, render } from '@testing-library/svelte';
9 import userEvent from '@testing-library/user-event';
12 import LanguageSelector from './language_selector.svelte';
18 describe('Language Selector component', () => {
20 internals.results = render(LanguageSelector);
23 test('Should display languages in their own language', () => {
24 expect(internals.results.getByText('English')).toBeVisible();
25 expect(internals.results.getByText('Español')).toBeVisible();
28 test('Should change locale when a language is selected', async () => {
29 locale.subscribe((localeValue) => {
30 expect(localeValue).toBe('en');
32 const spanish = internals.results.getByText('Español');
33 await userEvent.selectOptions(spanish.closest('select'), spanish);
35 locale.subscribe((localeValue) => {
36 expect(localeValue).toBe('es');