43 lines
1.1 KiB
JavaScript

var expect = require("chai").expect;
module.exports = function (helpers) {
var component = helpers.mount(require.resolve("./index.marko"), {
name: "Frank",
});
expect(
component.getComponent("foo").el.querySelector(".render-count").innerHTML,
).to.equal("0");
expect(
component.getComponent("foo").el.querySelector(".name").innerHTML,
).to.equal("Frank");
// Rerender with a new props object that has the shallow properties
component.input = {
name: "Frank",
};
component.update();
expect(
component.getComponent("foo").el.querySelector(".render-count").innerHTML,
).to.equal("0");
expect(
component.getComponent("foo").el.querySelector(".name").innerHTML,
).to.equal("Frank");
// Rerender with a new props object that has the shallow properties
component.input = {
name: "John",
};
component.update();
expect(
component.getComponent("foo").el.querySelector(".render-count").innerHTML,
).to.equal("1");
expect(
component.getComponent("foo").el.querySelector(".name").innerHTML,
).to.equal("John");
};