Skip to content

Commit

Permalink
Merge pull request #601 from keithamus/release-3.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
keithamus committed Jan 28, 2016
2 parents e614fee + 4ca0218 commit 57c85f6
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 10 deletions.
139 changes: 131 additions & 8 deletions chai.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var used = []
* Chai version
*/

exports.version = '3.4.2';
exports.version = '3.5.0';

/*!
* Assertion Error
Expand Down Expand Up @@ -1914,7 +1914,7 @@ module.exports = function (chai, _) {
* var fn = function() { obj.val += 3 };
* var noChangeFn = function() { return 'foo' + 'bar'; }
* expect(fn).to.change(obj, 'val');
* expect(noChangFn).to.not.change(obj, 'val')
* expect(noChangeFn).to.not.change(obj, 'val')
*
* @name change
* @alias changes
Expand Down Expand Up @@ -2689,8 +2689,8 @@ module.exports = function (chai, util) {
/**
* ### .isObject(value, [message])
*
* Asserts that `value` is an object (as revealed by
* `Object.prototype.toString`).
* Asserts that `value` is an object of type 'Object' (as revealed by `Object.prototype.toString`).
* _The assertion does not match subclassed objects._
*
* var selection = { name: 'Chai', serve: 'with spices' };
* assert.isObject(selection, 'tea selection is an object');
Expand All @@ -2709,7 +2709,7 @@ module.exports = function (chai, util) {
/**
* ### .isNotObject(value, [message])
*
* Asserts that `value` is _not_ an object.
* Asserts that `value` is _not_ an object of type 'Object' (as revealed by `Object.prototype.toString`).
*
* var selection = 'chai'
* assert.isNotObject(selection, 'tea selection is not an object');
Expand Down Expand Up @@ -3454,6 +3454,27 @@ module.exports = function (chai, util) {
new Assertion(superset, msg).to.include.members(subset);
}

/**
* ### .includeDeepMembers(superset, subset, [message])
*
* Asserts that `subset` is included in `superset` - using deep equality checking.
* Order is not taken into account.
* Duplicates are ignored.
*
* assert.includeDeepMembers([ {a: 1}, {b: 2}, {c: 3} ], [ {b: 2}, {a: 1}, {b: 2} ], 'include deep members');
*
* @name includeDeepMembers
* @param {Array} superset
* @param {Array} subset
* @param {String} message
* @namespace Assert
* @api public
*/

assert.includeDeepMembers = function (superset, subset, msg) {
new Assertion(superset, msg).to.include.deep.members(subset);
}

/**
* ### .oneOf(inList, list, [message])
*
Expand Down Expand Up @@ -3874,29 +3895,131 @@ module.exports = function (chai, util) {
}, should.fail);
};

/**
* ### .equal(actual, expected, [message])
*
* Asserts non-strict equality (`==`) of `actual` and `expected`.
*
* should.equal(3, '3', '== coerces values to strings');
*
* @name equal
* @param {Mixed} actual
* @param {Mixed} expected
* @param {String} message
* @namespace Should
* @api public
*/

should.equal = function (val1, val2, msg) {
new Assertion(val1, msg).to.equal(val2);
};

/**
* ### .throw(function, [constructor/string/regexp], [string/regexp], [message])
*
* Asserts that `function` will throw an error that is an instance of
* `constructor`, or alternately that it will throw an error with message
* matching `regexp`.
*
* should.throw(fn, 'function throws a reference error');
* should.throw(fn, /function throws a reference error/);
* should.throw(fn, ReferenceError);
* should.throw(fn, ReferenceError, 'function throws a reference error');
* should.throw(fn, ReferenceError, /function throws a reference error/);
*
* @name throw
* @alias Throw
* @param {Function} function
* @param {ErrorConstructor} constructor
* @param {RegExp} regexp
* @param {String} message
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
* @namespace Should
* @api public
*/

should.Throw = function (fn, errt, errs, msg) {
new Assertion(fn, msg).to.Throw(errt, errs);
};

/**
* ### .exist
*
* Asserts that the target is neither `null` nor `undefined`.
*
* var foo = 'hi';
*
* should.exist(foo, 'foo exists');
*
* @name exist
* @namespace Should
* @api public
*/

should.exist = function (val, msg) {
new Assertion(val, msg).to.exist;
}

// negation
should.not = {}

/**
* ### .not.equal(actual, expected, [message])
*
* Asserts non-strict inequality (`!=`) of `actual` and `expected`.
*
* should.not.equal(3, 4, 'these numbers are not equal');
*
* @name not.equal
* @param {Mixed} actual
* @param {Mixed} expected
* @param {String} message
* @namespace Should
* @api public
*/

should.not.equal = function (val1, val2, msg) {
new Assertion(val1, msg).to.not.equal(val2);
};

/**
* ### .throw(function, [constructor/regexp], [message])
*
* Asserts that `function` will _not_ throw an error that is an instance of
* `constructor`, or alternately that it will not throw an error with message
* matching `regexp`.
*
* should.not.throw(fn, Error, 'function does not throw');
*
* @name not.throw
* @alias not.Throw
* @param {Function} function
* @param {ErrorConstructor} constructor
* @param {RegExp} regexp
* @param {String} message
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
* @namespace Should
* @api public
*/

should.not.Throw = function (fn, errt, errs, msg) {
new Assertion(fn, msg).to.not.Throw(errt, errs);
};

/**
* ### .not.exist
*
* Asserts that the target is neither `null` nor `undefined`.
*
* var bar = null;
*
* should.not.exist(bar, 'bar does not exist');
*
* @name not.exist
* @namespace Should
* @api public
*/

should.not.exist = function (val, msg) {
new Assertion(val, msg).to.not.exist;
}
Expand Down Expand Up @@ -4296,9 +4419,9 @@ module.exports = function (obj, args) {
if(typeof msg === "function") msg = msg();
msg = msg || '';
msg = msg
.replace(/#{this}/g, objDisplay(val))
.replace(/#{act}/g, objDisplay(actual))
.replace(/#{exp}/g, objDisplay(expected));
.replace(/#\{this\}/g, function () { return objDisplay(val); })
.replace(/#\{act\}/g, function () { return objDisplay(actual); })
.replace(/#\{exp\}/g, function () { return objDisplay(expected); });

return flagMsg ? flagMsg + ': ' + msg : msg;
};
Expand Down
2 changes: 1 addition & 1 deletion lib/chai.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var used = []
* Chai version
*/

exports.version = '3.4.2';
exports.version = '3.5.0';

/*!
* Assertion Error
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"Veselin Todorov <[email protected]>",
"John Firebaugh <[email protected]>"
],
"version": "3.4.2",
"version": "3.5.0",
"repository": {
"type": "git",
"url": "https://github.com/chaijs/chai"
Expand Down

0 comments on commit 57c85f6

Please sign in to comment.