Skip to content

Commit 92d8362

Browse files
committed
test(motion): ViewSwitcher 真源断言改读 tokens.css
1 parent 8997248 commit 92d8362

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎app/src/ui/primitives/ViewSwitcher.test.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* W7 图标走 `ui/icons` 注册表(渲染出 `svg` 且**装饰性**;类型层由 `tsc` 承担,见报告 V2);
1313
* W8(C14① 的 §8.6.1 第 3 条)响应层接缝 `--ed-dur-micro` 120ms,且**没有新增未被覆盖的动效类**。
1414
*
15-
* 副作用:只挂 React 树 + 只读同目录 `ViewSwitcher.css` / `motion.css`。边界:本仓未装 jest-dom ⇒ 原生 DOM API;
15+
* 副作用:只挂 React 树 + 只读 `ViewSwitcher.css` / `motion.css` / 唯一真源产物 `../tokens.css`。边界:本仓未装 jest-dom ⇒ 原生 DOM API;
1616
* jsdom **不是真浏览器** —— 真实观感/焦点环像素/真实粘性与动效一律登记为「未验证」(见 T5 报告 §未验证)。
1717
*/
1818
import { readFileSync } from "node:fs";
@@ -28,6 +28,8 @@ const read = (file: string): string => readFileSync(join(HERE, file), "utf8").re
2828
const stripComments = (s: string): string => s.replace(/\/\*[\s\S]*?\*\//g, "");
2929
const VS_CSS = stripComments(read("ViewSwitcher.css"));
3030
const MOTION_CSS = stripComments(read("motion.css"));
31+
/** 批 6 T5:时长/缓动的**唯一真源产物**已迁到 `ui/tokens.css`(`motion.css` 的临时变量块已删) */
32+
const TOKENS_CSS = stripComments(read("../tokens.css"));
3133

3234
/** 取某选择器的规则体(选择器 → 第一个 `}`)—— 防「写在别的规则里也算过」 */
3335
function bodyOf(css: string, sel: string): string {
@@ -209,7 +211,7 @@ describe("W8 响应层接缝(§8.6.1 第 3 条):`--ed-dur-micro` 120ms +
209211
expect(body, "ViewSwitcher.css 缺 `.ed-btn--segment` 规则").not.toBe("");
210212
expect(body.match(/var\(--ed-dur-micro, 120ms\)/g) ?? [], "接缝不是三属性单值 120ms").toHaveLength(3);
211213
expect(body, "过渡缺 `transition:` 声明").toContain("transition:");
212-
expect(MOTION_CSS, "`--ed-dur-micro` 的真源定值不是 120ms").toContain("--ed-dur-micro: 120ms;");
214+
expect(TOKENS_CSS, "`--ed-dur-micro` 的真源定值不是 120ms").toContain("--ed-dur-micro: 120ms;");
213215
// 反例守门:同一条取段器喂一条**没有**接缝的合成规则必须取不到 ⇒ 上面三条不承重时会露馅
214216
expect(bodyOf(".ed-btn--segment { color: var(--ed-ink-3); }", ".ed-btn--segment {")).not.toContain("transition:");
215217
});

0 commit comments

Comments
 (0)