mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 11:43:20 +00:00
* refactor(cli): import zod directly instead of through incur * fix(verify): count incur z imports from declarations, not comment or string text
30 lines
1.3 KiB
TypeScript
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);
|
|
});
|