Use `vitest` for backend tests: - `bench` script now uses [vitest's `bench`](https://vitest.dev/api/#bench) - e2e test fails with same error happening now with jest:`data-testid` attribute not present. vitest left, jest right <img width="1264" height="603" alt="image" src="https://github.com/user-attachments/assets/56fc43a6-e143-4208-bf14-7e016aae7fa9" />
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
import { describe, expect, it } from "vitest";
|
|
|
|
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'",
|
|
);
|
|
});
|
|
});
|