You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
uptime-kuma/test/cypress/unit/i18n.spec.js

44 lines
1.2 KiB

import { currentLocale } from "../../../src/i18n";
describe("Test i18n.js", () => {
it("currentLocale()", () => {
const setLanguage = (language) => {
Object.defineProperty(window.navigator, 'language', {
value: language,
writable: true
});
}
setLanguage('en-EN');
expect(currentLocale()).equal("en");
setLanguage('zh-HK');
expect(currentLocale()).equal("zh-HK");
// Note that in Safari on iOS prior to 10.2, the country code returned is lowercase: "en-us", "fr-fr" etc.
// https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language
setLanguage('zh-hk');
expect(currentLocale()).equal("en");
setLanguage('en-US');
expect(currentLocale()).equal("en");
setLanguage('ja-ZZ');
expect(currentLocale()).equal("ja");
setLanguage('zz-ZZ');
expect(currentLocale()).equal("en");
setLanguage('zz-ZZ');
expect(currentLocale()).equal("en");
setLanguage('en');
localStorage.locale = "en";
expect(currentLocale()).equal("en");
localStorage.locale = "zh-HK";
expect(currentLocale()).equal("zh-HK");
});
});