mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 22:35:51 +00:00
test: 新增测试代码文件
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { validateUuid } from "../uuid";
|
||||
import { validateUuid, createAgentId } from "../uuid";
|
||||
|
||||
describe("validateUuid", () => {
|
||||
test("validates correct UUID", () => {
|
||||
@@ -9,7 +9,7 @@ describe("validateUuid", () => {
|
||||
|
||||
test("validates uppercase UUID", () => {
|
||||
const result = validateUuid("550E8400-E29B-41D4-A716-446655440000");
|
||||
expect(result).not.toBeNull();
|
||||
expect(result).toBe("550E8400-E29B-41D4-A716-446655440000");
|
||||
});
|
||||
|
||||
test("returns null for non-string", () => {
|
||||
@@ -31,4 +31,21 @@ describe("validateUuid", () => {
|
||||
test("returns null for UUID with invalid chars", () => {
|
||||
expect(validateUuid("550e8400-e29b-41d4-a716-44665544000g")).toBeNull();
|
||||
});
|
||||
|
||||
test("returns null for UUID with leading/trailing whitespace", () => {
|
||||
expect(validateUuid(" 550e8400-e29b-41d4-a716-446655440000")).toBeNull();
|
||||
expect(validateUuid("550e8400-e29b-41d4-a716-446655440000 ")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("createAgentId", () => {
|
||||
test("generates id without label in correct format", () => {
|
||||
const id = createAgentId();
|
||||
expect(id).toMatch(/^a[0-9a-f]{16}$/);
|
||||
});
|
||||
|
||||
test("generates id with label in correct format", () => {
|
||||
const id = createAgentId("compact");
|
||||
expect(id).toMatch(/^acompact-[0-9a-f]{16}$/);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user