import { render } from '@stencil/vitest';
import { mutationObserverMock } from '../../../utils/tests/mutation-observer.mock';
global.MutationObserver = mutationObserverMock;
describe('ontario-language-toggle', () => {
describe('snapshot', () => {
it('should render the expected html', async () => {
const page = await render(``);
expect(page.root).toMatchSnapshot();
});
});
it('should render the default size language toggle if no size is passed', async () => {
const page = await render(``);
expect(page.root).toEqualHtml(`
FR
Français
`);
expect(page.instance.size).toBe('default');
});
/**
* TODO: Determine if this is testable.
*
* Not sure how to properly test against this, seems to be a race condition.
*
* Takes a few processes before the html lang attribute is updated.
*
* Using setTimeout() leads to a false positive.
*
* Using page.waitForChanges() or autoApplyChanges: true seem to have no effect.
*/
it.skip('should render a default language of English on the tag if no language prop is passed', async () => {
const page = await render(``);
expect(page.instance.language).toBe('en');
});
it('should render a small size language toggle with a French default language when explicitly specified', async () => {
const page = await render(
``,
);
expect(page.root).toEqualHtml(`
English
`);
});
});