-
Notifications
You must be signed in to change notification settings - Fork 20
/
element.spec.ts
54 lines (47 loc) · 1.37 KB
/
element.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { useResetDOM, useDOMElement, useIVI, useHTML, useSVG, useTest } from "ivi-jest";
import { Op } from "ivi";
import { useDOMOpsCounters } from "./jest";
useResetDOM();
const root = useDOMElement();
const domOps = useDOMOpsCounters();
const t = useTest();
describe("element", () => {
describe("HTML", () => {
const h = useHTML();
const r = (op: Op) => t.render<HTMLElement>(op, root()).domNode!;
describe("mount", () => {
test("div", () => {
const n = r(h.div());
expect(n).toMatchSnapshot();
expect(domOps()).toMatchSnapshot();
});
});
describe("update", () => {
test("div to span", () => {
r(h.span());
const n = r(h.div());
expect(n).toMatchSnapshot();
expect(domOps()).toMatchSnapshot();
});
test("div to text", () => {
r(h.span());
const n = r(123);
expect(n).toMatchSnapshot();
expect(domOps()).toMatchSnapshot();
});
});
});
describe("SVG", () => {
const ivi = useIVI();
const s = useSVG();
const r = (op: Op) => t.render<SVGElement>(op, root()).domNode!;
describe("mount", () => {
test("circle", () => {
const n = r(s.circle());
expect(n.namespaceURI).toBe(ivi.SVG_NAMESPACE);
expect(n).toMatchSnapshot();
expect(domOps()).toMatchSnapshot();
});
});
});
});