From 6561fc29a4b8f85ea97d9d92401ca592c9d0ab52 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Thu, 16 Jul 2015 22:02:04 +0100 Subject: [PATCH] chai@3.1.0 --- chai.js | 324 ++++++++++++++++++++++++++++++++++++++++++++------- lib/chai.js | 2 +- package.json | 2 +- 3 files changed, 287 insertions(+), 41 deletions(-) diff --git a/chai.js b/chai.js index 46f5d0eac..2e605452e 100644 --- a/chai.js +++ b/chai.js @@ -1,4 +1,7 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.chai = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o @@ -12,7 +15,7 @@ var used = [] * Chai version */ -exports.version = '3.0.0'; +exports.version = '3.1.0'; /*! * Assertion Error @@ -93,7 +96,7 @@ exports.use(should); var assert = require('./chai/interface/assert'); exports.use(assert); -},{"./chai/assertion":2,"./chai/config":3,"./chai/core/assertions":4,"./chai/interface/assert":5,"./chai/interface/expect":6,"./chai/interface/should":7,"./chai/utils":20,"assertion-error":28}],2:[function(require,module,exports){ +},{"./chai/assertion":3,"./chai/config":4,"./chai/core/assertions":5,"./chai/interface/assert":6,"./chai/interface/expect":7,"./chai/interface/should":8,"./chai/utils":21,"assertion-error":29}],3:[function(require,module,exports){ /*! * chai * http://chaijs.com @@ -226,7 +229,7 @@ module.exports = function (_chai, util) { }); }; -},{"./config":3}],3:[function(require,module,exports){ +},{"./config":4}],4:[function(require,module,exports){ module.exports = { /** @@ -283,7 +286,7 @@ module.exports = { }; -},{}],4:[function(require,module,exports){ +},{}],5:[function(require,module,exports){ /*! * chai * http://chaijs.com @@ -617,6 +620,25 @@ module.exports = function (chai, _) { ); }); + /** + * ### .NaN + * Asserts that the target is `NaN`. + * + * expect('foo').to.be.NaN; + * expect(4).not.to.be.NaN; + * + * @name NaN + * @api public + */ + + Assertion.addProperty('NaN', function () { + this.assert( + isNaN(flag(this, 'object')) + , 'expected #{this} to be NaN' + , 'expected #{this} not to be NaN' + ); + }); + /** * ### .exist * @@ -1904,9 +1926,90 @@ module.exports = function (chai, _) { Assertion.addChainableMethod('decrease', assertDecreases); Assertion.addChainableMethod('decreases', assertDecreases); + /** + * ### .extensible + * + * Asserts that the target is extensible (can have new properties added to + * it). + * + * var nonExtensibleObject = Object.preventExtensions({}); + * var sealedObject = Object.seal({}); + * var frozenObject = Object.freeze({}); + * + * expect({}).to.be.extensible; + * expect(nonExtensibleObject).to.not.be.extensible; + * expect(sealedObject).to.not.be.extensible; + * expect(frozenObject).to.not.be.extensible; + * + * @name extensible + * @api public + */ + + Assertion.addProperty('extensible', function() { + var obj = flag(this, 'object'); + + this.assert( + Object.isExtensible(obj) + , 'expected #{this} to be extensible' + , 'expected #{this} to not be extensible' + ); + }); + + /** + * ### .sealed + * + * Asserts that the target is sealed (cannot have new properties added to it + * and its existing properties cannot be removed). + * + * var sealedObject = Object.seal({}); + * var frozenObject = Object.freeze({}); + * + * expect(sealedObject).to.be.sealed; + * expect(frozenObject).to.be.sealed; + * expect({}).to.not.be.sealed; + * + * @name sealed + * @api public + */ + + Assertion.addProperty('sealed', function() { + var obj = flag(this, 'object'); + + this.assert( + Object.isSealed(obj) + , 'expected #{this} to be sealed' + , 'expected #{this} to not be sealed' + ); + }); + + /** + * ### .frozen + * + * Asserts that the target is frozen (cannot have new properties added to it + * and its existing properties cannot be modified). + * + * var frozenObject = Object.freeze({}); + * + * expect(frozenObject).to.be.frozen; + * expect({}).to.not.be.frozen; + * + * @name frozen + * @api public + */ + + Assertion.addProperty('frozen', function() { + var obj = flag(this, 'object'); + + this.assert( + Object.isSealed(obj) + , 'expected #{this} to be frozen' + , 'expected #{this} to not be frozen' + ); + }); + }; -},{}],5:[function(require,module,exports){ +},{}],6:[function(require,module,exports){ /*! * chai * Copyright(c) 2011-2014 Jake Luer @@ -2239,6 +2342,37 @@ module.exports = function (chai, util) { new Assertion(val, msg).to.not.equal(null); }; + /** + * ### .isNaN + * Asserts that value is NaN + * + * assert.isNaN('foo', 'foo is NaN'); + * + * @name isNaN + * @param {Mixed} value + * @param {String} message + * @api public + */ + + assert.isNaN = function (val, msg) { + new Assertion(val, msg).to.be.NaN; + }; + + /** + * ### .isNotNaN + * Asserts that value is not NaN + * + * assert.isNotNaN(4, '4 is not NaN'); + * + * @name isNotNaN + * @param {Mixed} value + * @param {String} message + * @api public + */ + assert.isNotNaN = function (val, msg) { + new Assertion(val, msg).not.to.be.NaN; + }; + /** * ### .isUndefined(value, [message]) * @@ -3172,6 +3306,121 @@ module.exports = function (chai, util) { } }; + /** + * ### .extensible(object) + * + * Asserts that `object` is extensible (can have new properties added to it). + * + * assert.extensible({}); + * + * @name extensible + * @param {Object} object + * @param {String} message _optional_ + * @api public + */ + + assert.extensible = function (obj, msg) { + new Assertion(obj, msg).to.be.extensible; + }; + + /** + * ### .notExtensible(object) + * + * Asserts that `object` is _not_ extensible. + * + * var nonExtensibleObject = Object.preventExtensions({}); + * var sealedObject = Object.seal({}); + * var frozenObject = Object.freese({}); + * + * assert.notExtensible(nonExtensibleObject); + * assert.notExtensible(sealedObject); + * assert.notExtensible(frozenObject); + * + * @name notExtensible + * @param {Object} object + * @param {String} message _optional_ + * @api public + */ + + assert.notExtensible = function (obj, msg) { + new Assertion(obj, msg).to.not.be.extensible; + }; + + /** + * ### .sealed(object) + * + * Asserts that `object` is sealed (cannot have new properties added to it + * and its existing properties cannot be removed). + * + * var sealedObject = Object.seal({}); + * var frozenObject = Object.seal({}); + * + * assert.sealed(sealedObject); + * assert.sealed(frozenObject); + * + * @name sealed + * @param {Object} object + * @param {String} message _optional_ + * @api public + */ + + assert.sealed = function (obj, msg) { + new Assertion(obj, msg).to.be.sealed; + }; + + /** + * ### .notSealed(object) + * + * Asserts that `object` is _not_ sealed. + * + * assert.notSealed({}); + * + * @name notSealed + * @param {Object} object + * @param {String} message _optional_ + * @api public + */ + + assert.notSealed = function (obj, msg) { + new Assertion(obj, msg).to.not.be.sealed; + }; + + /** + * ### .frozen(object) + * + * Asserts that `object` is frozen (cannot have new properties added to it + * and its existing properties cannot be modified). + * + * var frozenObject = Object.freeze({}); + * assert.frozen(frozenObject); + * + * @name frozen + * @param {Object} object + * @param {String} message _optional_ + * @api public + */ + + assert.frozen = function (obj, msg) { + new Assertion(obj, msg).to.be.frozen; + }; + + /** + * ### .notFrozen(object) + * + * Asserts that `object` is _not_ frozen. + * + * assert.notFrozen({}); + * + * @name notSealed + * @param {Object} object + * @param {String} message _optional_ + * @api public + */ + + assert.notFrozen = function (obj, msg) { + new Assertion(obj, msg).to.not.be.frozen; + }; + /*! * Aliases. */ @@ -3184,7 +3433,7 @@ module.exports = function (chai, util) { ('Throw', 'throws'); }; -},{}],6:[function(require,module,exports){ +},{}],7:[function(require,module,exports){ /*! * chai * Copyright(c) 2011-2014 Jake Luer @@ -3219,7 +3468,7 @@ module.exports = function (chai, util) { }; }; -},{}],7:[function(require,module,exports){ +},{}],8:[function(require,module,exports){ /*! * chai * Copyright(c) 2011-2014 Jake Luer @@ -3319,7 +3568,7 @@ module.exports = function (chai, util) { chai.Should = loadShould; }; -},{}],8:[function(require,module,exports){ +},{}],9:[function(require,module,exports){ /*! * Chai - addChainingMethod utility * Copyright(c) 2012-2014 Jake Luer @@ -3432,7 +3681,7 @@ module.exports = function (ctx, name, method, chainingBehavior) { }); }; -},{"../config":3,"./flag":11,"./transferFlags":27}],9:[function(require,module,exports){ +},{"../config":4,"./flag":12,"./transferFlags":28}],10:[function(require,module,exports){ /*! * Chai - addMethod utility * Copyright(c) 2012-2014 Jake Luer @@ -3477,7 +3726,7 @@ module.exports = function (ctx, name, method) { }; }; -},{"../config":3,"./flag":11}],10:[function(require,module,exports){ +},{"../config":4,"./flag":12}],11:[function(require,module,exports){ /*! * Chai - addProperty utility * Copyright(c) 2012-2014 Jake Luer @@ -3519,7 +3768,7 @@ module.exports = function (ctx, name, getter) { }); }; -},{}],11:[function(require,module,exports){ +},{}],12:[function(require,module,exports){ /*! * Chai - flag utility * Copyright(c) 2012-2014 Jake Luer @@ -3553,7 +3802,7 @@ module.exports = function (obj, key, value) { } }; -},{}],12:[function(require,module,exports){ +},{}],13:[function(require,module,exports){ /*! * Chai - getActual utility * Copyright(c) 2012-2014 Jake Luer @@ -3573,7 +3822,7 @@ module.exports = function (obj, args) { return args.length > 4 ? args[4] : obj._obj; }; -},{}],13:[function(require,module,exports){ +},{}],14:[function(require,module,exports){ /*! * Chai - getEnumerableProperties utility * Copyright(c) 2012-2014 Jake Luer @@ -3600,7 +3849,7 @@ module.exports = function getEnumerableProperties(object) { return result; }; -},{}],14:[function(require,module,exports){ +},{}],15:[function(require,module,exports){ /*! * Chai - message composition utility * Copyright(c) 2012-2014 Jake Luer @@ -3652,7 +3901,7 @@ module.exports = function (obj, args) { return flagMsg ? flagMsg + ': ' + msg : msg; }; -},{"./flag":11,"./getActual":12,"./inspect":21,"./objDisplay":22}],15:[function(require,module,exports){ +},{"./flag":12,"./getActual":13,"./inspect":22,"./objDisplay":23}],16:[function(require,module,exports){ /*! * Chai - getName utility * Copyright(c) 2012-2014 Jake Luer @@ -3674,7 +3923,7 @@ module.exports = function (func) { return match && match[1] ? match[1] : ""; }; -},{}],16:[function(require,module,exports){ +},{}],17:[function(require,module,exports){ /*! * Chai - getPathInfo utility * Copyright(c) 2012-2014 Jake Luer @@ -3786,7 +4035,7 @@ function _getPathValue (parsed, obj, index) { return res; } -},{"./hasProperty":19}],17:[function(require,module,exports){ +},{"./hasProperty":20}],18:[function(require,module,exports){ /*! * Chai - getPathValue utility * Copyright(c) 2012-2014 Jake Luer @@ -3830,7 +4079,7 @@ module.exports = function(path, obj) { return info.value; }; -},{"./getPathInfo":16}],18:[function(require,module,exports){ +},{"./getPathInfo":17}],19:[function(require,module,exports){ /*! * Chai - getProperties utility * Copyright(c) 2012-2014 Jake Luer @@ -3867,7 +4116,7 @@ module.exports = function getProperties(object) { return result; }; -},{}],19:[function(require,module,exports){ +},{}],20:[function(require,module,exports){ /*! * Chai - hasProperty utility * Copyright(c) 2012-2014 Jake Luer @@ -3932,7 +4181,7 @@ module.exports = function hasProperty(name, obj) { return name in obj; }; -},{"type-detect":33}],20:[function(require,module,exports){ +},{"type-detect":34}],21:[function(require,module,exports){ /*! * chai * Copyright(c) 2011 Jake Luer @@ -4060,7 +4309,7 @@ exports.addChainableMethod = require('./addChainableMethod'); exports.overwriteChainableMethod = require('./overwriteChainableMethod'); -},{"./addChainableMethod":8,"./addMethod":9,"./addProperty":10,"./flag":11,"./getActual":12,"./getMessage":14,"./getName":15,"./getPathInfo":16,"./getPathValue":17,"./hasProperty":19,"./inspect":21,"./objDisplay":22,"./overwriteChainableMethod":23,"./overwriteMethod":24,"./overwriteProperty":25,"./test":26,"./transferFlags":27,"deep-eql":29,"type-detect":33}],21:[function(require,module,exports){ +},{"./addChainableMethod":9,"./addMethod":10,"./addProperty":11,"./flag":12,"./getActual":13,"./getMessage":15,"./getName":16,"./getPathInfo":17,"./getPathValue":18,"./hasProperty":20,"./inspect":22,"./objDisplay":23,"./overwriteChainableMethod":24,"./overwriteMethod":25,"./overwriteProperty":26,"./test":27,"./transferFlags":28,"deep-eql":30,"type-detect":34}],22:[function(require,module,exports){ // This is (almost) directly from Node.js utils // https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js @@ -4395,7 +4644,7 @@ function objectToString(o) { return Object.prototype.toString.call(o); } -},{"./getEnumerableProperties":13,"./getName":15,"./getProperties":18}],22:[function(require,module,exports){ +},{"./getEnumerableProperties":14,"./getName":16,"./getProperties":19}],23:[function(require,module,exports){ /*! * Chai - flag utility * Copyright(c) 2012-2014 Jake Luer @@ -4446,7 +4695,7 @@ module.exports = function (obj) { } }; -},{"../config":3,"./inspect":21}],23:[function(require,module,exports){ +},{"../config":4,"./inspect":22}],24:[function(require,module,exports){ /*! * Chai - overwriteChainableMethod utility * Copyright(c) 2012-2014 Jake Luer @@ -4501,7 +4750,7 @@ module.exports = function (ctx, name, method, chainingBehavior) { }; }; -},{}],24:[function(require,module,exports){ +},{}],25:[function(require,module,exports){ /*! * Chai - overwriteMethod utility * Copyright(c) 2012-2014 Jake Luer @@ -4554,7 +4803,7 @@ module.exports = function (ctx, name, method) { } }; -},{}],25:[function(require,module,exports){ +},{}],26:[function(require,module,exports){ /*! * Chai - overwriteProperty utility * Copyright(c) 2012-2014 Jake Luer @@ -4610,7 +4859,7 @@ module.exports = function (ctx, name, getter) { }); }; -},{}],26:[function(require,module,exports){ +},{}],27:[function(require,module,exports){ /*! * Chai - test utility * Copyright(c) 2012-2014 Jake Luer @@ -4638,7 +4887,7 @@ module.exports = function (obj, args) { return negate ? !expr : expr; }; -},{"./flag":11}],27:[function(require,module,exports){ +},{"./flag":12}],28:[function(require,module,exports){ /*! * Chai - transferFlags utility * Copyright(c) 2012-2014 Jake Luer @@ -4684,7 +4933,7 @@ module.exports = function (assertion, object, includeAll) { } }; -},{}],28:[function(require,module,exports){ +},{}],29:[function(require,module,exports){ /*! * assertion-error * Copyright(c) 2013 Jake Luer @@ -4798,10 +5047,10 @@ AssertionError.prototype.toJSON = function (stack) { return props; }; -},{}],29:[function(require,module,exports){ +},{}],30:[function(require,module,exports){ module.exports = require('./lib/eql'); -},{"./lib/eql":30}],30:[function(require,module,exports){ +},{"./lib/eql":31}],31:[function(require,module,exports){ /*! * deep-eql * Copyright(c) 2013 Jake Luer @@ -5060,10 +5309,10 @@ function objectEqual(a, b, m) { return true; } -},{"buffer":undefined,"type-detect":31}],31:[function(require,module,exports){ +},{"buffer":undefined,"type-detect":32}],32:[function(require,module,exports){ module.exports = require('./lib/type'); -},{"./lib/type":32}],32:[function(require,module,exports){ +},{"./lib/type":33}],33:[function(require,module,exports){ /*! * type-detect * Copyright(c) 2013 jake luer @@ -5207,9 +5456,9 @@ Library.prototype.test = function (obj, type) { } }; -},{}],33:[function(require,module,exports){ -arguments[4][31][0].apply(exports,arguments) -},{"./lib/type":34,"dup":31}],34:[function(require,module,exports){ +},{}],34:[function(require,module,exports){ +arguments[4][32][0].apply(exports,arguments) +},{"./lib/type":35,"dup":32}],35:[function(require,module,exports){ /*! * type-detect * Copyright(c) 2013 jake luer @@ -5345,8 +5594,5 @@ Library.prototype.test = function(obj, type) { } }; -},{}],35:[function(require,module,exports){ -module.exports = require('./lib/chai'); - -},{"./lib/chai":1}]},{},[35])(35) +},{}]},{},[1])(1) }); \ No newline at end of file diff --git a/lib/chai.js b/lib/chai.js index 1d89b209b..31853fb5c 100644 --- a/lib/chai.js +++ b/lib/chai.js @@ -11,7 +11,7 @@ var used = [] * Chai version */ -exports.version = '3.0.0'; +exports.version = '3.1.0'; /*! * Assertion Error diff --git a/package.json b/package.json index 75a21e44f..5349332b8 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "Veselin Todorov ", "John Firebaugh " ], - "version": "3.0.0", + "version": "3.1.0", "repository": { "type": "git", "url": "https://github.com/chaijs/chai"