// import everything from json-html import { HtmlArray, parse_html } from "../reflect-html" import { make_gauges } from "./gauges" describe("HtmlArray", () => { // ===== HtmlArray mutations describe("HtmlArray mutations", () => { it("should add classes", () => { const root = make_gauges() expect(root.select(".myclass").length).toEqual(0) root.select("line").addClass("myclass") expect(root.select(".myclass").length).toEqual(4) expect(root.select(".myclass").hasClass("myclass")).toBeTruthy() expect(root.select(".myclass").hasClass("xxx")).toBeFalsy() expect(root.select("line.myclass").length).toEqual(4) }) it("should remove classes", () => { const root = make_gauges() expect(root.select(".myclass").length).toEqual(0) root.select("line").addClass("myclass") expect(root.select(".myclass").length).toEqual(4) expect(root.select("#g2 line").length).toEqual(1) root.select("#g2 line").removeClass("myclass") expect(root.select(".myclass").length).toEqual(3) root.select("line").removeClass("myclass") expect(root.select(".myclass").length).toEqual(0) }) it("should add attributes", () => { const root = make_gauges() expect(root.select("[foo=bar]").length).toEqual(0) root.select("line").attr("foo", "bar") expect(root.select("[foo=bar]").length).toEqual(4) expect(root.select("[foo=bar]").attr("foo")).toContain("bar") expect(root.select("[foo=bar]").attr("xxx")[0]).toEqual(undefined) expect(root.select("line[foo=bar]").length).toEqual(4) }) // inner content mutations it("should add inner text", () => {}) }) // ===== Parse HTML describe("Parsing HTML", () => { it("should parse simple HTML elements", () => { const html = `