import { renderToStaticMarkup } from "react-dom/server"; import ReactMarkdown from "react-markdown"; import remarkGfm from "remark-gfm"; import { describe, expect, it } from "vite-plus/test"; import { remarkNormalizeListItemIndentation } from "./markdown-list-indentation"; function renderMarkdown(markdown: string): string { return renderToStaticMarkup( {markdown} , ); } describe("remarkNormalizeListItemIndentation", () => { it("renders same-line over-indented list content as list text", () => { const html = renderMarkdown(`why did you do this? - for (const step of rest.steps) { - if (step.request.body) { - step.request.body = ""; - } - }`); expect(html).not.toContain("
");
    expect(html).toContain("
  • for (const step of rest.steps) {
  • "); expect(html).toContain("
  • if (step.request.body) {
  • "); expect(html).toContain("
  • step.request.body = "<redacted>";
  • "); }); it("parses inline markdown in recovered list content", () => { const html = renderMarkdown( "- **important** [docs](https://example.com) use `inline code`, not ~~plain text~~", ); expect(html).toContain("important"); expect(html).toContain('docs'); expect(html).toContain("inline code"); expect(html).toContain("plain text"); expect(html).not.toContain("**important**"); }); it("preserves every recovered block separated by blank lines", () => { const html = renderMarkdown(`- **first block** [second block](https://example.com)`); expect(html).toContain("first block"); expect(html).toContain('second block'); }); it("recursively normalizes lists in recovered tail blocks", () => { const html = renderMarkdown(`- first block - nested block`); expect(html).not.toContain("
    ");
        expect(html).toContain("
  • nested block
  • "); }); it("preserves fenced code blocks within list items", () => { const html = renderMarkdown(`- \`\`\`ts const value = 1; \`\`\``); expect(html).toContain('
    const value = 1;');
      });
    
      it("preserves indented code blocks that start below a list marker", () => {
        const html = renderMarkdown(`-
          const value = 1;`);
    
        expect(html).toContain("
    const value = 1;");
      });
    
      it("preserves same-line code blocks without excess indentation", () => {
        const html = renderMarkdown("-     const value = 1;");
    
        expect(html).toContain("
    const value = 1;");
      });
    });