UNPKG

@patternslib/patternslib

Version:

Patternslib is a JavaScript library that enables designers to build rich interactive prototypes without the need for writing any Javascript. All events are triggered by classes and other attributes in the HTML, without abusing the HTML as a programming la

44 lines (32 loc) 1.29 kB
import Pattern from "./minimalpattern"; describe("Minimalpattern tests", function () { beforeEach(function () { const el = document.createElement("div"); el.setAttribute("id", "lab"); document.body.appendChild(el); }); afterEach(function () { document.body.removeChild(document.querySelector("#lab")); }); it("Changes the color on click.", function (done) { const el = document.createElement("div"); el.setAttribute("class", "pat-minimalpattern"); document.body.appendChild(el); new Pattern(el); expect(el.getAttribute("style")).toBeFalsy(); el.click(); expect(el.getAttribute("style") === "background-color: green;").toBeTruthy(); done(); }); it("Changes the color to the one specified on click.", function (done) { const el = document.createElement("div"); el.setAttribute("class", "pat-minimalpattern"); el.setAttribute("data-pat-minimalpattern", "background-color: red;"); document.body.appendChild(el); new Pattern(el); expect(el.getAttribute("style")).toBeFalsy(); el.click(); expect(el.getAttribute("style") === "background-color: red;").toBeTruthy(); done(); }); });