import { describe, it, expect } from "vitest"; import { renderMarkdown, renderMarkdownSync, markdownToPlainText } from "./markdown"; describe("Markdown Rendering", () => { describe("renderMarkdown", () => { it("should render basic markdown to HTML", async () => { const markdown = "# Hello World\n\nThis is **bold** text."; const html = await renderMarkdown(markdown); expect(html).toContain("bold"); }); it("should handle empty input", async () => { const html = await renderMarkdown(""); expect(html).toBe(""); }); it("should handle null/undefined input", async () => { expect(await renderMarkdown(null as any)).toBe(""); expect(await renderMarkdown(undefined as any)).toBe(""); }); it("should sanitize potentially dangerous HTML", async () => { const markdown = '\n\n**Safe** content'; const html = await renderMarkdown(markdown); expect(html).not.toContain("'; const html = renderMarkdownSync(markdown); expect(html).not.toContain("'; const html = await renderMarkdown(markdown); expect(html).not.toContain(""); }); }); describe("Edge Cases", () => { it("should handle very long content", async () => { const markdown = "# Test\n\n" + "A ".repeat(10000); const html = await renderMarkdown(markdown); expect(html.length).toBeGreaterThan(0); expect(html).toContain(" { const markdown = "# δ½ ε₯½ World 🌍\n\n**Γ‰mojis**: πŸ˜€ ✨ πŸš€"; const html = await renderMarkdown(markdown); expect(html).toContain("δ½ ε₯½"); expect(html).toContain("🌍"); expect(html).toContain("πŸ˜€"); }); it("should handle nested markdown correctly", async () => { const markdown = "**Bold with _italic_ inside**"; const html = await renderMarkdown(markdown); expect(html).toContain(""); expect(html).toContain(""); }); }); });