import { describe, it, expect } from "vitest"; import { marked } from "marked"; /** Tests for marked list rendering — covering v17 breaking changes */ describe("Markdown list rendering", () => { const parse = (md: string) => marked.parse(md, { async: false }) as string; describe("loose lists (paragraphs inside list items)", () => { it("renders loose list items with
tags", () => { const md = `- Item one\n\n- Item two\n\n- Item three\n`; const html = parse(md); expect(html).toContain("
expect(html).toContain("
Item one
"); expect(html).toContain("Item two
"); expect(html).toContain("Item three
"); }); it("renders tight list items withouttags", () => { const md = `- Item one\n- Item two\n- Item three\n`; const html = parse(md); expect(html).toContain("
"); expect(html).toContain("Item one"); }); }); describe("checkbox/task lists", () => { it("renders unchecked checkboxes", () => { const md = `- [ ] Todo item\n`; const html = parse(md); expect(html).toContain(' { const md = `- [x] Done item\n`; const html = parse(md); expect(html).toContain('checked'); expect(html).toContain("Done item"); }); it("renders mixed task list", () => { const md = `- [x] Done\n- [ ] Pending\n- Regular item\n`; const html = parse(md); expect(html).toContain("Done"); expect(html).toContain("Pending"); expect(html).toContain("Regular item"); // Should have exactly 2 checkboxes const checkboxCount = (html.match(/type="checkbox"/g) || []).length; expect(checkboxCount).toBe(2); }); }); describe("nested lists", () => { it("renders nested unordered lists", () => { const md = `- Parent\n - Child\n - Grandchild\n`; const html = parse(md); expect(html).toContain("Parent"); expect(html).toContain("Child"); expect(html).toContain("Grandchild"); // Should have nested
npm install");
expect(html).toContain("npm test");
});
it("renders bold and italic in list items", () => {
const md = `- **Bold item**\n- *Italic item*\n`;
const html = parse(md);
expect(html).toContain("Bold item");
expect(html).toContain("Italic item");
});
});
});