Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
chai-backbone
Advanced tools
chai-backbone is an extension to the chai assertion library that provides a set of backbone specific assertions.
Use the assertions with chai's expect
or should
assertions.
trigger
model.should.trigger("change", { with: [model] }).when(function() {
model.set({ attribute: "value" });
});
this can also be chained further:
model.should.trigger("change").and.trigger("change:attribute").when(function() {
model.set({ attribute: "value" });
});
model.should.trigger("change").and.not.trigger("reset").when(function() {
model.set({ attribute: "value" });
});
route.to
Tests if a route is delegated to the correct router and if the arguments are extracted in the expected manner.
"page/3".should.route.to(myRouter, "openPage", { arguments: ["3"] });
"pages/3".should.not.route.to(myRouter, "openPage");
"page/3".should.route.to(myRouter, "openPage", { considering: [conflictingRouter] });
call
This assertion is ideal for testing view callbacks it will rebind view events to test DOM events
view.should.call('startAuthentication').when(function() {
view.$('a.login').trigger('click');
});
Do an npm install chai-backbone
to get up and running. Then:
var chai = require("chai");
var chaiBackbone = require("chai-backbone");
chai.use(chaiBackbone);
You can of course put this code in a common test fixture file; for an example using Mocha
Chai Backbone supports being used as an AMD module, registering itself anonymously (just like Chai). So,
assuming you have configured your loader to map the Chai and Chai
Backbone files to the respective module IDs
"chai"
and "chai-backbone"
, you can use them as follows:
define(function (require, exports, module) {
var chai = require("chai");
var chaiBackbone = require("chai-backbone");
chai.use(chaiBackbone);
});
<script>
tagIf you include Chai Backbone directly with a <script>
tag, after the one for Chai itself,
then it will automatically plug in to Chai and be ready for use:
<script src="chai.js"></script>
<script src="chai-backbone.js"></script>
Copyright (c) 2012-2015 Matthijs Groen
MIT License (see the LICENSE file)
FAQs
Backbone assertions for the Chai assertion library
The npm package chai-backbone receives a total of 3,644 weekly downloads. As such, chai-backbone popularity was classified as popular.
We found that chai-backbone demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.