Chai-JSkit
This is a simple chai plugin to make testing jskit applications.
Testing Actions
...
actions: ["index"],
...
expect(subject).to.have.action("index");
...
actions: [{ edit: "setupForm" }],
...
expect(subject).to.have.action("edit", "setupForm");
Testing Elements
...
elements: {
index: {
menuToggleButton: ".menu-toggle"
}
}
...
expect(subject).to.cacheElement("index", "$menuToggleButton", ".menu-toggle");
Testing Events
...
elements: {
index: {
todoListItem: [".todo-list-item", { click: "handleTodoListClick" }]
}
},
...
handleTodoListClick: function() {},
expect(subject).to.registerEvent("index", "$todoListItem", "click", "handleTodoListClick");
Dynamic event binding:
...
elements: {
index: {
todoListItem: [".todo-list-item", function() {
on("click", this.handleTodoListClick);
}]
}
},
...
handleTodoListClick: function() {},
expect(subject).to.registerEvent("index", "$todoListItem", "click", "handleTodoListClick");