fix: Task2 质量修复(TS2774/降级分支测试/跨平台checksize/显式lib)
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
import { uuid } from "../src/util";
|
||||
describe("uuid", () => {
|
||||
it("生成 36 位且不重复", () => {
|
||||
@@ -6,4 +6,11 @@ describe("uuid", () => {
|
||||
expect(a).toMatch(/^[0-9a-f-]{36}$/);
|
||||
expect(a).not.toBe(b);
|
||||
});
|
||||
it("Math.random 降级分支:格式正确且唯一", () => {
|
||||
vi.stubGlobal("crypto", {});
|
||||
const a = uuid(), b = uuid();
|
||||
expect(a).toMatch(/^[0-9a-f-]{36}$/);
|
||||
expect(a).not.toBe(b);
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user