Files
freeCodeCamp/cypress/e2e/default/learn/header/lang-selector.ts
renovate[bot] 87e1ae21a5 chore: update TS and Fastify (#52157)
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>
2023-11-07 17:22:59 +05:30

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}`);
});
});
});