import { sanitizeFileName } from "./sanitizeFileName"; describe("sanitizeFileName", () => { it("returns an empty string when input is undefined", () => { expect(sanitizeFileName(undefined)).toBe(""); }); it("returns the input unchanged when no newlines are present", () => { expect(sanitizeFileName("report.pdf")).toBe("report.pdf"); }); it("collapses a single embedded \\n into a space", () => { expect(sanitizeFileName("first\nsecond.txt")).toBe("first second.txt"); }); it("collapses runs of CR / LF into a single space", () => { expect(sanitizeFileName("first\r\n\r\nsecond.txt")).toBe( "first second.txt", ); }); it("leaves spaces unchanged", () => { expect(sanitizeFileName("with spaces.pdf")).toBe("with spaces.pdf"); }); });