Files
SnapOtter/tests/unit/scripts/i18n/validate.test.ts
T
SnapOtterandGitHub 00b651c9f8 feat(i18n): 21-language pipeline, landing/docs/API wiring, landing+API translations
Shared Claude Code translation pipeline (scripts/i18n, no API key) plus Astro/VitePress/Scalar i18n wiring. Landing and API reference translated into all 20 languages; docs i18n wiring + English source anchors. The translated docs markdown (apps/docs/<locale>/**, 3,620 files) follows in a companion PR because it exceeds GitHub's per-PR CI file limit.
2026-07-11 13:01:55 +08:00

30 lines
1.1 KiB
TypeScript

// tests/unit/scripts/i18n/validate.test.ts
import { describe, expect, it } from "vitest";
import { validate } from "../../../../scripts/i18n/lib/validate.mjs";
const SRC = "```\ncode\n```\nUse `x` and [t](/u) with {name}.";
describe("validate", () => {
it("passes when structure is preserved", () => {
const translated = "```\ncode\n```\nBenutze `x` und [Text](/u) mit {name}.";
expect(validate(SRC, translated)).toEqual({ ok: true, errors: [] });
});
it("fails when a code fence is dropped", () => {
const translated = "Benutze `x` und [Text](/u) mit {name}.";
const result = validate(SRC, translated);
expect(result.ok).toBe(false);
expect(result.errors.join(" ")).toMatch(/fences/);
});
it("fails when a placeholder count changes", () => {
const translated = "```\ncode\n```\nBenutze `x` und [Text](/u) mit {name} {name}.";
expect(validate(SRC, translated).ok).toBe(false);
});
it("fails when a mask token leaked into the output", () => {
const translated = `${SRC}⸤I18N0⸥`;
expect(validate(SRC, translated).ok).toBe(false);
});
});