import { renderMarkdown } from "@/lib/markdown"; import { describe, expect, it } from "vitest"; describe("renderMarkdown", () => { it("renders simple text", async () => { const html = await renderMarkdown("Hello world"); expect(html).toContain("Hello world"); }); it("renders headings", async () => { const html = await renderMarkdown("# Title\n## Subtitle"); expect(html).toContain(" { const html = await renderMarkdown("**bold** and *italic*"); expect(html).toContain("bold"); expect(html).toContain("italic"); }); it("renders links", async () => { const html = await renderMarkdown("[OpenCodeHub](https://example.com)"); expect(html).toContain(" { const html = await renderMarkdown("```js\nconst x = 1;\n```"); expect(html).toContain(" { const html = await renderMarkdown("Use `npm install` to install"); expect(html).toContain(" { const html = await renderMarkdown("- Item 1\n- Item 2\n- Item 3"); expect(html).toContain(" { const html = await renderMarkdown("1. First\n2. Second"); expect(html).toContain(" { const md = ` | Column A | Column B | |----------|----------| | Val 1 | Val 2 | `.trim(); const html = await renderMarkdown(md); expect(html).toContain(" { const md = "- [x] Done\n- [ ] Todo"; const html = await renderMarkdown(md); expect(html).toContain("Done"); expect(html).toContain("Todo"); }); it("renders GFM strikethrough", async () => { const html = await renderMarkdown("~~deleted~~"); expect(html).toContain(" { const html = await renderMarkdown(''); expect(html).not.toContain(" { const html = await renderMarkdown(''); expect(html).not.toContain("onerror"); }); it("handles empty string", async () => { const html = await renderMarkdown(""); expect(typeof html).toBe("string"); }); it("handles whitespace-only content", async () => { const html = await renderMarkdown(" \n\n "); expect(typeof html).toBe("string"); }); it("renders cross-repo issue references", async () => { const html = await renderMarkdown("See owner/repo#123 for details"); // The remarkCrossRepoLinks plugin should convert owner/repo#123 to a link expect(html).toContain("owner/repo#123"); }); it("renders blockquotes", async () => { const html = await renderMarkdown("> This is a quote"); expect(html).toContain(" { const html = await renderMarkdown("---"); expect(html).toContain(" { const html = await renderMarkdown( "![alt text](https://example.com/img.png)", ); expect(html).toContain("