Add respondsTo and satisfies as aliases

This commit is contained in:
Andrew Couch 2015-07-17 11:14:17 -04:00
parent 6ee53e438a
commit 802fa5e0bb

View file

@ -1368,12 +1368,13 @@ module.exports = function (chai, _) {
* expect(Klass).itself.to.respondTo('baz');
*
* @name respondTo
* @alias respondsTo
* @param {String} method
* @param {String} message _optional_
* @api public
*/
Assertion.addMethod('respondTo', function (method, msg) {
function respondTo (method, msg) {
if (msg) flag(this, 'message', msg);
var obj = flag(this, 'object')
, itself = flag(this, 'itself')
@ -1386,7 +1387,10 @@ module.exports = function (chai, _) {
, 'expected #{this} to respond to ' + _.inspect(method)
, 'expected #{this} to not respond to ' + _.inspect(method)
);
});
}
Assertion.addMethod('respondTo', respondTo);
Assertion.addMethod('respondsTo', respondTo);
/**
* ### .itself
@ -1416,12 +1420,13 @@ module.exports = function (chai, _) {
* expect(1).to.satisfy(function(num) { return num > 0; });
*
* @name satisfy
* @alias satisfies
* @param {Function} matcher
* @param {String} message _optional_
* @api public
*/
Assertion.addMethod('satisfy', function (matcher, msg) {
function satisfy (matcher, msg) {
if (msg) flag(this, 'message', msg);
var obj = flag(this, 'object');
var result = matcher(obj);
@ -1432,7 +1437,10 @@ module.exports = function (chai, _) {
, this.negate ? false : true
, result
);
});
}
Assertion.addMethod('satisfy', satisfy);
Assertion.addMethod('satisfies', satisfy);
/**
* ### .closeTo(expected, delta)