mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 14:31:42 +00:00
test: merge empty-id sanitize mode checks
This commit is contained in:
@@ -191,9 +191,6 @@ describe("sanitizeToolCallId", () => {
|
|||||||
it("strips invalid characters", () => {
|
it("strips invalid characters", () => {
|
||||||
expect(sanitizeToolCallId("call_abc|item:456")).toBe("callabcitem456");
|
expect(sanitizeToolCallId("call_abc|item:456")).toBe("callabcitem456");
|
||||||
});
|
});
|
||||||
it("returns default for empty IDs", () => {
|
|
||||||
expect(sanitizeToolCallId("")).toBe("defaulttoolid");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("strict mode (alphanumeric only)", () => {
|
describe("strict mode (alphanumeric only)", () => {
|
||||||
@@ -204,9 +201,6 @@ describe("sanitizeToolCallId", () => {
|
|||||||
"whatsapplogin17687998415271",
|
"whatsapplogin17687998415271",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it("returns default for empty IDs", () => {
|
|
||||||
expect(sanitizeToolCallId("", "strict")).toBe("defaulttoolid");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("strict9 mode (Mistral tool call IDs)", () => {
|
describe("strict9 mode (Mistral tool call IDs)", () => {
|
||||||
@@ -214,9 +208,26 @@ describe("sanitizeToolCallId", () => {
|
|||||||
const out = sanitizeToolCallId("call_abc|item:456", "strict9");
|
const out = sanitizeToolCallId("call_abc|item:456", "strict9");
|
||||||
expect(out).toMatch(/^[a-zA-Z0-9]{9}$/);
|
expect(out).toMatch(/^[a-zA-Z0-9]{9}$/);
|
||||||
});
|
});
|
||||||
it("returns default for empty IDs", () => {
|
});
|
||||||
expect(sanitizeToolCallId("", "strict9")).toMatch(/^[a-zA-Z0-9]{9}$/);
|
|
||||||
});
|
it.each([
|
||||||
|
{
|
||||||
|
modeLabel: "default",
|
||||||
|
run: () => sanitizeToolCallId(""),
|
||||||
|
assert: (value: string) => expect(value).toBe("defaulttoolid"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
modeLabel: "strict",
|
||||||
|
run: () => sanitizeToolCallId("", "strict"),
|
||||||
|
assert: (value: string) => expect(value).toBe("defaulttoolid"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
modeLabel: "strict9",
|
||||||
|
run: () => sanitizeToolCallId("", "strict9"),
|
||||||
|
assert: (value: string) => expect(value).toMatch(/^[a-zA-Z0-9]{9}$/),
|
||||||
|
},
|
||||||
|
])("returns default for empty IDs in $modeLabel mode", ({ run, assert }) => {
|
||||||
|
assert(run());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user