test: merge empty-id sanitize mode checks

This commit is contained in:
Peter Steinberger
2026-02-18 23:37:03 +00:00
parent 595246b58b
commit 002f158da6

View File

@@ -191,9 +191,6 @@ describe("sanitizeToolCallId", () => {
it("strips invalid characters", () => {
expect(sanitizeToolCallId("call_abc|item:456")).toBe("callabcitem456");
});
it("returns default for empty IDs", () => {
expect(sanitizeToolCallId("")).toBe("defaulttoolid");
});
});
describe("strict mode (alphanumeric only)", () => {
@@ -204,9 +201,6 @@ describe("sanitizeToolCallId", () => {
"whatsapplogin17687998415271",
);
});
it("returns default for empty IDs", () => {
expect(sanitizeToolCallId("", "strict")).toBe("defaulttoolid");
});
});
describe("strict9 mode (Mistral tool call IDs)", () => {
@@ -214,9 +208,26 @@ describe("sanitizeToolCallId", () => {
const out = sanitizeToolCallId("call_abc|item:456", "strict9");
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());
});
});