chore: initialize project
Some checks failed
Deploy monie-landing (kaniko) / build-and-deploy (push) Failing after 1m46s
Some checks failed
Deploy monie-landing (kaniko) / build-and-deploy (push) Failing after 1m46s
This commit is contained in:
33
src/shared/lib/i18n/messages-parity.test.ts
Normal file
33
src/shared/lib/i18n/messages-parity.test.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user