Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
chai-bookshelf
Advanced tools
Make assertions on your bookshelf.js models.
Install via npm: npm install chai-bookshelf
Note that it's handy to use the shortcut --save-dev: npm install --save-dev chai-bookshelf
var chai = require('chai');
chai.use(require('chai-bookshelf'));
Right now, only basic assertions on relationships are supported.
Remove boiler plate from your code by making straightforward assertions
Supported Relationships include:
expect(ClassA).to.haveOne(ClassB)
expect(ClassA).to.haveMany(ClassB)
expect(ClassA).to.belongTo(ClassB)
expect(ClassA).to.belongToMany(ClassB)
A basic example showing a test of a relationship
describe('User model', function() {
var User
, Thing
;
beforeEach(function() {
Thing = db.Model.extend({
tableName: 'things'
});
User = db.Model.extend({
things: function() {
return this.hasMany(Thing);
}
});
});
describe('Relationships', function() {
it('has many things', function() {
expect(User).to.haveMany(Thing);
})
});
});
By default, the assertion will use the singular form of the tablename. If the attribute is named something other than the target model's class (for example, to be plural) you will need to specify the name of the attribute that represents the relationship.
describe('User model', function() {
var User
, Thing
;
beforeEach(function() {
User = db.Model.extend({});
Thing = db.Model.extend({
owner: function() {
this.belongsTo(User);
}
});
});
describe('Relationships', function() {
it('has many things', function() {
expect(Thing).to.belongTo(User, 'owner');
})
});
});
FAQs
Chai assertions for bookshelf-based models
The npm package chai-bookshelf receives a total of 21 weekly downloads. As such, chai-bookshelf popularity was classified as not popular.
We found that chai-bookshelf 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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.