Created
May 24, 2014 02:00
-
-
Save tonylukasavage/e737059af0414546f730 to your computer and use it in GitHub Desktop.
custom should.js assertion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// getter assertion | |
should.Assertion.add('CRAZY', function() { | |
this.params = { | |
operator: 'to be the string "CRAZY"', | |
expected: 'CRAZY', | |
showDiff: true | |
}; | |
this.obj.should.equal('CRAZY'); | |
}, true); | |
// function assertion | |
should.Assertion.add('HttpCode', function(code) { | |
this.params = { | |
operator: 'to be HTTP code', | |
expected: code, | |
showDiff: true | |
}; | |
this.obj.statusCode.should.equal(code); | |
}, false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var str = 'CRAZY'; | |
var err = { | |
statusCode: 403 | |
}; | |
str.should.be.CRAZY; // pass | |
err.should.have.HttpCode(403); // pass | |
err.should.have.HttpCode(400); // fail |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment