import rehypeFormat from "rehype-format"; import rehypeParse from "rehype-parse"; import rehypeStringify from "rehype-stringify"; import { unified } from "unified"; import { describe, expect, it } from "vitest"; import { nestedListsToBlockNoteStructure } from "./nestedLists"; async function testHTML(html: string) { const htmlNode = nestedListsToBlockNoteStructure(html); const pretty = await unified() .use(rehypeParse, { fragment: true }) .use(rehypeFormat) .use(rehypeStringify) .process(htmlNode.innerHTML); expect(pretty.value).toMatchSnapshot(); } describe("Lift nested lists", () => { it("Lifts nested bullet lists", async () => { const html = ``; await testHTML(html); }); it("Lifts nested bullet lists without li", async () => { const html = ``; await testHTML(html); }); it("Lifts nested bullet lists with content after nested list", async () => { const html = ``; await testHTML(html); }); it("Lifts multiple bullet lists", async () => { const html = ``; await testHTML(html); }); it("Lifts multiple bullet lists with content in between", async () => { const html = ``; await testHTML(html); }); it("Lifts nested numbered lists", async () => { const html = `
  1. Numbered List Item 1
    1. Nested Numbered List Item 1
    2. Nested Numbered List Item 2
  2. Numbered List Item 2
`; await testHTML(html); }); it("Lifts nested mixed lists", async () => { const html = `
  1. Numbered List Item 1
  2. Numbered List Item 2
`; await testHTML(html); }); });