import { readFileSync } from "node:fs"; import { describe, expect, it } from "vitest"; import en from "../src/locales/en.json" with { type: "json" }; import kk from "../src/locales/kk.json" with { type: "json" }; import ru from "../src/locales/ru.json" with { type: "json" }; /** Слова из колонки «Нельзя» словаря docs/glossary.md. */ function bannedWords(): string[] { const lines = readFileSync(new URL("../docs/glossary.md", import.meta.url), "utf8").split("\n"); return lines .filter( (line) => line.startsWith("|") && !line.startsWith("|---") && !line.startsWith("| Понятие"), ) .flatMap((line) => (line.split("|")[3] ?? "").split(",")) .map((word) => word.trim()) .filter(Boolean); } function findBanned(text: string, banned: string[]): string[] { return banned.filter((word) => { const escaped = word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); return new RegExp(`(? { const banned = bannedWords(); it("словарь читается", () => { expect(banned).toContain("стори"); expect(banned).toContain("мок"); }); it.each([ ["ru", ru], ["kk", kk], ["en", en], ])("в текстах %s нет слов из колонки «Нельзя»", (_name, file) => { for (const [key, value] of Object.entries(file)) { expect(findBanned(value, banned), `${key}: ${value}`).toEqual([]); } }); it("русские тексты обращаются на «вы» со строчной буквы", () => { for (const value of Object.values(ru)) expect(value).not.toMatch(/(?