Files
reverse-engineering-anything/tests/evaluation/incurImportGuard.test.ts
T
morluto 07c5a54fee refactor(cli): import zod directly instead of through incur (#11655)
* refactor(cli): import zod directly instead of through incur

* fix(verify): count incur z imports from declarations, not comment or string text
2026-11-16 10:37:43 +08:00

30 lines
1.3 KiB
TypeScript

import { expect, it } from "vitest";
import { incurZodImportCount } from "../../scripts/verify/incur-import-guard.mjs";
it("counts declarations that take z from incur in every spelling", () => {
expect(incurZodImportCount('import { z } from "incur";')).toBe(1);
expect(incurZodImportCount("import type { z } from 'incur';")).toBe(1);
expect(incurZodImportCount('import { Cli, type z } from "incur";')).toBe(1);
expect(incurZodImportCount('import { z as zod } from "incur";')).toBe(1);
expect(incurZodImportCount('export { z } from "incur";')).toBe(1);
expect(
incurZodImportCount(
'import {\n Cli,\n z,\n} from "incur";\nconst a = 1;',
),
).toBe(1);
});
it("ignores other names, other modules and non-declaration text", () => {
expect(incurZodImportCount('import { Cli } from "incur";')).toBe(0);
expect(incurZodImportCount('import { schema as z } from "incur";')).toBe(0);
expect(incurZodImportCount('import { z } from "zod";')).toBe(0);
expect(incurZodImportCount('// import { z } from "incur";')).toBe(0);
expect(incurZodImportCount('/* import { z } from "incur"; */')).toBe(0);
expect(
incurZodImportCount("const fixture = 'import { z } from \"incur\";';"),
).toBe(0);
expect(
incurZodImportCount('const fixture = `\nimport { z } from "incur";\n`;'),
).toBe(0);
});