chore(deps): Kill small dependencies (#4467)
This commit is contained in:
22
packages/coding-agent/test/ansi-utils.test.ts
Normal file
22
packages/coding-agent/test/ansi-utils.test.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { stripAnsi } from "../src/utils/ansi.js";
|
||||
|
||||
describe("stripAnsi", () => {
|
||||
it("strips RIS without leaking the final byte", () => {
|
||||
expect(stripAnsi("\x1bcdone")).toBe("done");
|
||||
});
|
||||
|
||||
it("strips single-byte ESC sequences without leaking final bytes", () => {
|
||||
for (let code = "g".charCodeAt(0); code <= "m".charCodeAt(0); code++) {
|
||||
expect(stripAnsi(`\x1b${String.fromCharCode(code)}ok`)).toBe("ok");
|
||||
}
|
||||
for (let code = "r".charCodeAt(0); code <= "t".charCodeAt(0); code++) {
|
||||
expect(stripAnsi(`\x1b${String.fromCharCode(code)}ok`)).toBe("ok");
|
||||
}
|
||||
});
|
||||
|
||||
it("strips common ANSI sequences used in tool output", () => {
|
||||
const input = "a\x1b[31mred\x1b[0m\x1b]8;;https://example.com\x07link\x1b]8;;\x07z";
|
||||
expect(stripAnsi(input)).toBe("aredlinkz");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user