From 802fa5e0bb0bded91fe2b4a3cef78efbfeac4570 Mon Sep 17 00:00:00 2001 From: Andrew Couch Date: Fri, 17 Jul 2015 11:14:17 -0400 Subject: [PATCH] Add respondsTo and satisfies as aliases --- lib/chai/core/assertions.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/chai/core/assertions.js b/lib/chai/core/assertions.js index dc5fc64..b9189b8 100644 --- a/lib/chai/core/assertions.js +++ b/lib/chai/core/assertions.js @@ -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)