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('

Plan

Hi there

'); expect(html).toBe("

Plan

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( "

Unit 1

First line
second line

  1. one
", ); expect(toRichTextHtml("a < b")).toBe("

a < b

"); }); it("reads excerpts and emptiness from the text, not the markup", () => { expect(richTextExcerpt("

Title

Body text

")).toBe("Title Body text"); expect(richTextExcerpt("

abcdef

", 3)).toBe("abc…"); expect(isRichTextEmpty("


")).toBe(true); expect(isRichTextEmpty("

x

")).toBe(false); }); });