diff --git a/app/utils/i18n.test.ts b/app/utils/i18n.test.ts index 1783ea0fd6..99210bbb98 100644 --- a/app/utils/i18n.test.ts +++ b/app/utils/i18n.test.ts @@ -4,12 +4,18 @@ import en_US from "../../shared/i18n/locales/en_US/translation.json"; import pt_PT from "../../shared/i18n/locales/pt_PT/translation.json"; import { initI18n } from "./i18n"; +function addResources() { + i18n + .addResources("en-US", "translation", en_US) + .addResources("de-DE", "translation", de_DE) + .addResources("pt-PT", "translation", pt_PT); +} + describe("i18n env is unset", () => { - beforeEach(() => { - initI18n() - .addResources("en-US", "translation", en_US) - .addResources("de-DE", "translation", de_DE) - .addResources("pt-PT", "translation", pt_PT); + beforeEach(async () => { + initI18n(); + addResources(); + await i18n.changeLanguage("en-US"); }); it("translation of key should match", () => @@ -25,12 +31,12 @@ describe("i18n env is unset", () => { expect(i18n.t("Saving")).toBe("A guardar"); }); }); + describe("i18n env is en-US", () => { - beforeEach(() => { - initI18n("en-US") - .addResources("en-US", "translation", en_US) - .addResources("de-DE", "translation", de_DE) - .addResources("pt-PT", "translation", pt_PT); + beforeEach(async () => { + initI18n("en-US"); + addResources(); + await i18n.changeLanguage("en-US"); }); it("translation of key should match", () => @@ -48,11 +54,10 @@ describe("i18n env is en-US", () => { }); describe("i18n env is de-DE", () => { - beforeEach(() => { - initI18n("de-DE") - .addResources("en-US", "translation", en_US) - .addResources("de-DE", "translation", de_DE) - .addResources("pt-PT", "translation", pt_PT); + beforeEach(async () => { + initI18n("de-DE"); + addResources(); + await i18n.changeLanguage("de-DE"); }); it("translation of key should match", () => @@ -70,11 +75,10 @@ describe("i18n env is de-DE", () => { }); describe("i18n env is pt-PT", () => { - beforeEach(() => { - initI18n("pt-PT") - .addResources("en-US", "translation", en_US) - .addResources("de-DE", "translation", de_DE) - .addResources("pt-PT", "translation", pt_PT); + beforeEach(async () => { + initI18n("pt-PT"); + addResources(); + await i18n.changeLanguage("pt-PT"); }); it("translation of key should match", () =>