import { html, mount, patch, text } from "../../src/blockdom"; import { makeTestFixture } from "./helpers"; //------------------------------------------------------------------------------ // Setup and helpers //------------------------------------------------------------------------------ let fixture: HTMLElement; beforeEach(() => { fixture = makeTestFixture(); }); afterEach(() => { fixture.remove(); }); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ describe("html block", () => { test("can be mounted and patched", async () => { const tree = html("12"); mount(tree, fixture); expect(fixture.innerHTML).toBe("12"); patch(tree, html("
coucou
")); expect(fixture.innerHTML).toBe("
coucou
"); }); test("html vnode can be used as text", () => { mount(text(html("

a

") as any), fixture); expect(fixture.textContent).toBe("

a

"); }); test("html vnode can represent ", () => { const fixture = document.createElement("table"); // const block = createBlock('
'); // const tree = block([], [html(`tomato`)]); const tree = html(`tomato`); mount(tree, fixture); expect(fixture.innerHTML).toBe("tomato"); patch(tree, html(`potato`)); expect(fixture.innerHTML).toBe("potato"); }); });