mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
var expect = require("chai").expect;
|
|
|
|
module.exports = function (helpers) {
|
|
var items = ["a", "b", "c"];
|
|
var count = 0;
|
|
|
|
var component = helpers.mount(require.resolve("./index"), {
|
|
items: items,
|
|
count: count,
|
|
});
|
|
|
|
expect(
|
|
helpers.targetEl.firstElementChild.getAttribute("data-count"),
|
|
).to.equal("0");
|
|
|
|
Array.from(helpers.targetEl.firstElementChild.childNodes).forEach((child) => {
|
|
if (child.tagName === "div") {
|
|
expect(child.getAttribute("data-count")).to.equal("0");
|
|
}
|
|
});
|
|
|
|
expect(helpers.targetEl.textContent).to.equal("abc");
|
|
|
|
component.input = {
|
|
count: ++count,
|
|
items: [].concat(items).reverse(),
|
|
};
|
|
component.update();
|
|
|
|
expect(
|
|
helpers.targetEl.firstElementChild.getAttribute("data-count"),
|
|
).to.equal("1");
|
|
|
|
Array.from(helpers.targetEl.firstElementChild.childNodes).forEach((child) => {
|
|
if (child.tagName === "div") {
|
|
expect(child.getAttribute("data-count")).to.equal("0");
|
|
}
|
|
});
|
|
|
|
expect(helpers.targetEl.textContent).to.equal("cba");
|
|
};
|