fix(frontend): errorCode 统一自 generation/cards 去重复定义(CR-H10)
This commit is contained in:
19
apps/web/lib/style/errorCode-dedup.test.ts
Normal file
19
apps/web/lib/style/errorCode-dedup.test.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
// CR-H10 回归守卫:errorCode 只应有一份权威实现(lib/generation/cards),
|
||||
// style 侧两个 hook 不得再各自本地定义 `function errorCode(`,须统一 import。
|
||||
describe("errorCode 去重(CR-H10)", () => {
|
||||
it.each(["useRefine.ts", "useStyleLearn.ts"])(
|
||||
"%s 不再本地定义 errorCode,且从 generation/cards 引入",
|
||||
(file) => {
|
||||
const src = readFileSync(new URL(`./${file}`, import.meta.url), "utf-8");
|
||||
|
||||
expect(src).not.toMatch(/function\s+errorCode\s*\(/);
|
||||
expect(src).toMatch(
|
||||
/import\s*\{[^}]*\berrorCode\b[^}]*\}\s*from\s*["']@\/lib\/generation\/cards["']/,
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user