import { describe, it, expect } from "vitest"; import { portableTextToProsemirror } from "../../../src/content/converters/portable-text-to-prosemirror.js"; import { prosemirrorToPortableText } from "../../../src/content/converters/prosemirror-to-portable-text.js"; import type { PortableTextHtmlBlock } from "../../../src/content/converters/types.js"; describe("HTML block round-trip (core converters)", () => { it("preserves html content through PT → PM → PT", () => { const htmlBlock: PortableTextHtmlBlock = { _type: "htmlBlock", _key: "html001", html: '
Hello world
Injected
", }, { _type: "block" as const, _key: "txt002", style: "normal" as const, children: [{ _type: "span" as const, _key: "s2", text: "After" }], }, ]; const pm = portableTextToProsemirror(blocks); expect(pm.content).toHaveLength(3); expect(pm.content[0].type).toBe("paragraph"); expect(pm.content[1].type).toBe("htmlBlock"); expect(pm.content[2].type).toBe("paragraph"); const pt = prosemirrorToPortableText(pm); expect(pt).toHaveLength(3); expect(pt[0]._type).toBe("block"); expect(pt[1]._type).toBe("htmlBlock"); expect((pt[1] as PortableTextHtmlBlock).html).toBe("Injected
"); expect(pt[2]._type).toBe("block"); }); });