/** * packages/shared — renderMarkdown tests (TASK-0112 SEND_EMAIL). * * The critical contract is XSS-safety: input is escaped FIRST, then * transforms are applied, so no raw HTML survives. Also: the supported * inline/block set, safe link targets only (javascript: defanged), and * total behavior (any string in → a safe string out). */ import { describe, expect, it } from "vitest"; import { renderMarkdown } from "./markdown.js"; describe("renderMarkdown", () => { it("escapes raw HTML (the XSS contract)", () => { expect(renderMarkdown("")).toBe("
<script>alert(1)</script>
"); expect(renderMarkdown('<img src=x onerror="alert(1)">
"); expect(renderMarkdown("**bold**")).toContain("bold"); expect(renderMarkdown("**bold**")).not.toContain(""); expect(out).not.toMatch(/