import { expect, test } from "vitest"; import { Fragment, RawHtml, renderHtml } from "./html_render.ts"; test("HTML Render", () => { expect( renderHtml({ name: "b", body: "hello", }), ).toEqual(`hello`); expect( renderHtml({ name: "a", attrs: { href: "https://example.com", }, body: "hello", }), ).toEqual(`hello`); expect( renderHtml({ name: "span", body: "<>", }), ).toEqual(`<>`); }); test("RawHtml with string body passes through unescaped", () => { expect( renderHtml({ name: RawHtml, body: 'italic & "quoted"', }), ).toEqual('italic & "quoted"'); }); test("RawHtml with array body passes strings through unescaped", () => { expect( renderHtml({ name: RawHtml, body: [ "bold", { name: "i", body: "normal" }, ], }), ).toEqual("boldnormal"); }); test("Fragment renders children without wrapper", () => { expect( renderHtml({ name: Fragment, body: [ { name: "b", body: "one" }, { name: "i", body: "two" }, ], }), ).toEqual("onetwo"); });