JSPM

chai-jskit

1.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q28861F
  • License Apache-2.0

A chai plugin for easily testing JSkit applications.

Package Exports

  • chai-jskit

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (chai-jskit) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Chai-JSkit

This is a simple chai plugin to make testing jskit applications.

Testing Actions

// controller:
...
actions: ["index"],
...

// expectation:
expect(subject).to.have.action("index");
// controller:
...
actions: [{ edit: "setupForm" }],
...

// expectation:
expect(subject).to.have.action("edit", "setupForm");

Testing Elements

// controller:
...
elements: {
    index: {
        menuToggleButton: ".menu-toggle"
    }
}
...

// expectation:
expect(subject).to.cacheElement("index", "$menuToggleButton", ".menu-toggle");

Testing Events

// controller:
...
elements: {
  index: {
    todoListItem: [".todo-list-item", { click: "handleTodoListClick" }]
  }
},
...
handleTodoListClick: function() {},

// expectation:
expect(subject).to.registerEvent("index", "$todoListItem", "click", "handleTodoListClick");

Dynamic event binding:

// controller:
...
elements: {
  index: {
    todoListItem: [".todo-list-item", function() {
        on("click", this.handleTodoListClick);
    }]
  }
},
...
handleTodoListClick: function() {},

// expectation:
expect(subject).to.registerEvent("index", "$todoListItem", "click", "handleTodoListClick");