import { isRichTextEmpty, richTextExcerpt, sanitizeRichText, toRichTextHtml } from "@/lib/rich-text"; describe("rich-text", () => { it("strips scripts, handlers and unknown tags but keeps formatting", () => { const html = sanitizeRichText('
Hi there
Hi there
"); }); it("drops javascript links and opens real ones in a new tab", () => { expect(sanitizeRichText('x')).not.toContain("javascript"); expect(sanitizeRichText('x')).toBe('x'); }); it("turns imported markdown-ish text into blocks", () => { expect(toRichTextHtml("## Unit 1\n\nFirst line\nsecond line\n\n- a\n- b\n1. one")).toBe( "First line
second line
a < b
"); }); it("reads excerpts and emptiness from the text, not the markup", () => { expect(richTextExcerpt("Body text
")).toBe("Title Body text"); expect(richTextExcerpt("abcdef
", 3)).toBe("abc…"); expect(isRichTextEmpty("x
")).toBe(false); }); });