File size: 1,067 Bytes
fc93158 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import { describe, expect, it } from "vitest";
import { extractToolCallLocations, formatToolTitle } from "./event-mapper.js";
describe("extractToolCallLocations", () => {
it("enforces the global node visit cap across nested structures", () => {
const nested = Array.from({ length: 20 }, (_, outer) =>
Array.from({ length: 20 }, (_, inner) =>
inner === 19 ? { path: `/tmp/file-${outer}.txt` } : { note: `${outer}-${inner}` },
),
);
const locations = extractToolCallLocations(nested);
expect(locations).toBeDefined();
expect(locations?.length).toBeLessThan(20);
expect(locations).not.toContainEqual({ path: "/tmp/file-19.txt" });
});
});
describe("formatToolTitle", () => {
it("escapes inline control characters in tool args", () => {
const title = formatToolTitle("read", {
path: "/tmp/file.txt\nnext-line\twith-tab",
});
expect(title).toContain("\\n");
expect(title).toContain("\\t");
expect(title).not.toContain("\nnext-line");
expect(title).not.toContain("\twith-tab");
});
});
|