// Catalog completeness and a byte snapshot — the CLJS replacement for the
// TS-era MsgKey type check, plus the transliteration gate: every Romanian and
// Hungarian string was moved by a throwaway line-by-line transliterator, and
// this test passing first try is the signal that not one character changed.
import test from "node:test";
import assert from "node:assert/strict";
import { installDom } from "./harness/dom.mjs";
import { mods, readVector } from "./helpers/load.mjs";
installDom();
const M = await mods();
const v = readVector("i18n");
test("EN is the key set of record, and ro/hu cover it exactly", () => {
assert.deepEqual(M.catalogKeys("en"), v.keys.en);
assert.ok(v.keys.en.length >= 140);
for (const lang of ["ro", "hu"]) {
assert.deepEqual(M.catalogKeys(lang), v.keys.en, `${lang} key set`);
assert.deepEqual(M.catalogKeys(lang), v.keys[lang]);
}
});
test("every catalog string is byte-identical to the TypeScript catalogs", () => {
for (const lang of ["en", "ro", "hu"]) {
for (const k of v.keys[lang]) {
assert.deepEqual(M.catalogRaw(lang, k), v.snapshot[lang][k], `${lang} ${k}`);
}
}
});
test("plural sites keep their per-language variant sets", () => {
assert.ok(Object.keys(v.plurals).length > 0);
for (const [k, shapes] of Object.entries(v.plurals)) {
for (const lang of ["en", "ro", "hu"]) {
assert.deepEqual(M.catalogMsg(lang, k), shapes[lang], `${lang} ${k}`);
}
}
});
test("no catalog value carries a wire literal", () => {
for (const lang of ["en", "ro", "hu"]) {
for (const k of v.keys[lang]) {
const m = M.catalogRaw(lang, k);
if (typeof m !== "string") continue;
assert.ok(!m.includes("/sueta/2/"), `${lang} ${k} contains a protocol prefix`);
assert.ok(!m.includes("sueta-id|v2"), `${lang} ${k} contains a domain tag`);
}
}
});
test("the runtime interpolates and falls back to the key", () => {
assert.equal(M.t("toast.key-changed", { name: "Ana" }), v.snapshot.en["toast.key-changed"].replace("{name}", "Ana"));
assert.equal(M.t("no.such.key.at.all"), "no.such.key.at.all");
const count = v.snapshot.en["sel.count"];
assert.equal(M.tn("sel.count", 1), count.one.replace("{n}", "1"));
assert.equal(M.tn("sel.count", 5), count.other.replace("{n}", "5"));
});