mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-02-20 07:01:03 -05:00
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Sboonny <muhammedelruby@gmail.com> Co-authored-by: Shaun Hamilton <shauhami020@gmail.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
35 lines
905 B
TypeScript
35 lines
905 B
TypeScript
import { availableLangs, hiddenLangs } from '../../../../../shared/config/i18n';
|
|
|
|
const buttonSelector = '#toggle-lang-button';
|
|
const toLangSelector = (lang: string) => `[data-value="${lang}"]`;
|
|
|
|
const langOpts = availableLangs.client.filter(
|
|
lang => !hiddenLangs.includes(lang)
|
|
);
|
|
|
|
describe('language selector', () => {
|
|
beforeEach(() => {
|
|
cy.visit('/learn');
|
|
});
|
|
|
|
it('should render the button', () => {
|
|
cy.get(buttonSelector).should('be.visible');
|
|
});
|
|
|
|
langOpts.forEach(lang => {
|
|
it(`should render the ${lang} option`, () => {
|
|
cy.get(buttonSelector).click();
|
|
cy.get(toLangSelector(lang)).should('be.visible');
|
|
});
|
|
|
|
if (String(lang) === 'english') {
|
|
return;
|
|
}
|
|
it(`should navigate to ${lang}`, () => {
|
|
cy.get(buttonSelector).click();
|
|
cy.get(toLangSelector(lang)).click();
|
|
cy.url().should('include', `/${lang}`);
|
|
});
|
|
});
|
|
});
|