Archived
1
0
Fork 0
This repository has been archived on 2024-07-25. You can view files and clone it, but cannot push or open issues or pull requests.
paren/ren/node.test.ts

35 lines
889 B
TypeScript
Raw Permalink Normal View History

2022-05-22 00:26:32 +03:00
import { assertEquals, assertInstanceOf } from "testing/asserts.ts";
import { Elem, Fragment, TextNode } from "../core/node.ts";
import { E, F } from "./node.ts";
Deno.test({
name: "should create fragment via util",
fn: () => {
const el = E("p", [], "hello world");
const innerFrag = F(["inner"]);
const frag = F(["hello", innerFrag, "world", el]);
assertInstanceOf(frag, Fragment);
assertEquals(frag.children, [
new TextNode("hello"),
new TextNode("inner"),
new TextNode("world"),
el,
]);
},
});
Deno.test({
name: "should create element via util",
fn: () => {
const child = E("p", [], "hello world");
const el = E("div", { class: "hello" }, [child]);
assertInstanceOf(el, Elem);
assertEquals(el.tagName, "div");
assertEquals(el.attrs, { class: "hello" });
assertEquals(el.children, [child]);
},
});