Files
monie-landing/src/shared/lib/i18n/messages-parity.test.ts
Denis Krylov 014058071a
Some checks failed
Deploy monie-landing (kaniko) / build-and-deploy (push) Failing after 1m46s
chore: initialize project
2026-04-04 21:36:32 +03:00

34 lines
923 B
TypeScript

import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { describe, expect, it } from "vitest";
function readMessages(locale: "ru" | "en") {
const filepath = resolve(process.cwd(), "messages", `${locale}.json`);
return JSON.parse(readFileSync(filepath, "utf-8")) as Record<string, string>;
}
describe("message catalogs", () => {
it("have the same keyset for ru and en", () => {
const ru = readMessages("ru");
const en = readMessages("en");
const ruKeys = Object.keys(ru).sort();
const enKeys = Object.keys(en).sort();
expect(ruKeys).toEqual(enKeys);
});
it("have non-empty translations", () => {
const catalogs = [readMessages("ru"), readMessages("en")];
for (const catalog of catalogs) {
for (const [key, value] of Object.entries(catalog)) {
expect(
value.trim().length,
`Empty translation for key: ${key}`,
).toBeGreaterThan(0);
}
}
});
});