import { describe, it, expect } from "vitest"; import { stripAnsi } from "../../extensions/compress/stages/ansi.js"; describe("stripAnsi", () => { it("returns unchanged string when no ANSI codes present", () => { const text = "hello world\nno escapes here"; expect(stripAnsi(text)).toBe(text); }); it("strips color codes", () => { expect(stripAnsi("\x1b[31mred text\x1b[0m")).toBe("red text"); }); it("strips bold/dim codes", () => { expect(stripAnsi("\x1b[1mbold\x1b[22m")).toBe("bold"); }); it("strips cursor movement sequences", () => { expect(stripAnsi("\x1b[2J\x1b[H")).toBe(""); }); it("strips OSC sequences", () => { expect(stripAnsi("\x1b]0;title\x07text")).toBe("text"); }); it("handles mixed ANSI and plain text", () => { expect(stripAnsi("before\x1b[32mgreen\x1b[0mafter")).toBe("beforegreenafter"); }); it("handles empty string", () => { expect(stripAnsi("")).toBe(""); }); it("handles multiline with ANSI on some lines", () => { const input = "line1\n\x1b[31mline2\x1b[0m\nline3"; expect(stripAnsi(input)).toBe("line1\nline2\nline3"); }); });