import { describe, expect, test } from "vitest"; import { extractHardcodedStrings, extractIntlFormattingUsages, renderMarkdown } from "./i18n-audit.mjs"; describe("i18n-audit renderMarkdown", () => { test("renders a clean baseline when there are no hits", () => { const md = renderMarkdown( { scannedFileCount: 5, fileHitCount: 0, totalHardcodedStrings: 0, intlFileCount: 0, totalIntlFormattingUsages: 0, files: [], intlFiles: [] }, new Date("2026-05-17T00:00:00Z"), ); expect(md).toContain("# i18n Audit — Baseline 2026-05-17"); expect(md).toContain("No hardcoded strings detected. Audit clean."); expect(md).toContain("apps/web/app/{routes,modules,routeModules,components}/**/*.{ts,tsx}"); }); test("includes top-offender + detail tables when hits exist", () => { const md = renderMarkdown( { scannedFileCount: 2, fileHitCount: 1, totalHardcodedStrings: 2, intlFileCount: 0, totalIntlFormattingUsages: 0, files: [ { filePath: "apps/web/app/components/Foo.tsx", hits: [ { line: 12, text: "Save changes" }, { line: 34, text: "Cancel" }, ], }, ], intlFiles: [], }, new Date("2026-05-17T00:00:00Z"), ); expect(md).toContain("| `apps/web/app/components/Foo.tsx` | 2 |"); expect(md).toContain("Save changes"); expect(md).toContain("Cancel"); }); test("reports locale-sensitive formatting signals separately from hardcoded JSX text", () => { const md = renderMarkdown( { scannedFileCount: 1, fileHitCount: 0, totalHardcodedStrings: 0, intlFileCount: 1, totalIntlFormattingUsages: 3, files: [], intlFiles: [ { filePath: "apps/web/app/routes/admin.tsx", hits: [ { line: 10, expression: "toLocaleString" }, { line: 11, expression: "DateUtils.dateYMD" }, { line: 12, expression: "NumberUtils.intFormat" }, ], }, ], }, new Date("2026-05-17T00:00:00Z"), ); expect(md).toContain("| Files with locale-sensitive formatting signals | 1 |"); expect(md).toContain("## Formatting migration signals"); expect(md).toContain("| `apps/web/app/routes/admin.tsx:10` | `toLocaleString` |"); expect(md).toContain("| `apps/web/app/routes/admin.tsx:11` | `DateUtils.dateYMD` |"); expect(md).toContain("| `apps/web/app/routes/admin.tsx:12` | `NumberUtils.intFormat` |"); }); }); describe("i18n-audit extractHardcodedStrings", () => { test("detects visible JSX text", () => { expect(extractHardcodedStrings("
Watch the demo video:
";', "const body = 'It works!';", "const template = `