forked from anuraghazra/github-readme-stats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
i18n.test.js
33 lines (30 loc) · 1.09 KB
/
i18n.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { expect, it, describe } from "@jest/globals";
import { I18n } from "../src/common/I18n.js";
import { statCardLocales } from "../src/translations.js";
describe("I18n", () => {
it("should return translated string", () => {
const i18n = new I18n({
locale: "en",
translations: statCardLocales({ name: "Anurag Hazra", apostrophe: "s" }),
});
expect(i18n.t("statcard.title")).toBe("Anurag Hazra's GitHub Stats");
});
it("should throw error if translation string not found", () => {
const i18n = new I18n({
locale: "en",
translations: statCardLocales({ name: "Anurag Hazra", apostrophe: "s" }),
});
expect(() => i18n.t("statcard.title1")).toThrow(
"statcard.title1 Translation string not found",
);
});
it("should throw error if translation not found for locale", () => {
const i18n = new I18n({
locale: "asdf",
translations: statCardLocales({ name: "Anurag Hazra", apostrophe: "s" }),
});
expect(() => i18n.t("statcard.title")).toThrow(
"'statcard.title' translation not found for locale 'asdf'",
);
});
});