import { assertEquals, assertInstanceOf } from "testing/asserts.ts";
import { Elem, Fragment, TextNode } from "./node.ts";
Deno.test({
name: "should create text node from string",
fn: () => {
const sourceText = "hello world";
const tn = new TextNode(sourceText);
assertInstanceOf(tn, TextNode);
assertEquals(tn.innerText, sourceText);
},
});
name: "should create fragment from array",
const hello = new TextNode("hello");
const world = new TextNode("world");
const frag = new Fragment([hello, world]);
assertInstanceOf(frag, Fragment);
assertEquals(frag.children, [hello, world]);
name: "should create element",
const child = new Elem("p", {}, [new TextNode("hello world")]);
const el = new Elem("div", { class: "hello" }, [child]);
assertEquals(el.tagName, "div");
assertEquals(el.attrs, { class: "hello" });
assertEquals(el.children, [child]);