import { describe, expect, it } from "vitest"; import { normalizeExtraRichText, sanitizeRichTextHtml, sanitizeRichTextUrl, } from "@/lib/rich-text"; describe("rich text sanitization", () => { it("keeps supported formatting, colors, and safe links", () => { expect(sanitizeRichTextHtml( '
Good news link
', )).toBe( 'Good news link
', ); }); it("removes executable markup, unsafe links, and unsupported styles", () => { expect(sanitizeRichTextHtml( 'Safe textlink
', )).toBe("Safe textlink
"); expect(sanitizeRichTextUrl("data:text/html,bad")).toBe(""); }); }); describe("legacy Extra rich text conversion", () => { it("escapes plain text, preserves newlines, and converts phrase colors", () => { expect(normalizeExtraRichText("<unsafe>
MASSIVE damage
Ready
', [ { text: "Ready", color: "#ff0000" }, ])).toBe("Ready
"); }); });