Skip to content

Commit 0fe98b1

Browse files
committed
chai@4.0.0
1 parent 30a4451 commit 0fe98b1

File tree

2 files changed

+209
-5
lines changed

2 files changed

+209
-5
lines changed

chai.js

Lines changed: 208 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4982,6 +4982,197 @@ module.exports = function (chai, util) {
49824982
new Assertion(exp, msg, assert.notDeepInclude, true).not.deep.include(inc);
49834983
};
49844984

4985+
/**
4986+
* ### .nestedInclude(haystack, needle, [message])
4987+
*
4988+
* Asserts that 'haystack' includes 'needle'.
4989+
* Can be used to assert the inclusion of a subset of properties in an
4990+
* object.
4991+
* Enables the use of dot- and bracket-notation for referencing nested
4992+
* properties.
4993+
* '[]' and '.' in property names can be escaped using double backslashes.
4994+
*
4995+
* assert.nestedInclude({'.a': {'b': 'x'}}, {'\\.a.[b]': 'x'});
4996+
* assert.nestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'x'});
4997+
*
4998+
* @name nestedInclude
4999+
* @param {Object} haystack
5000+
* @param {Object} needle
5001+
* @param {String} message
5002+
* @namespace Assert
5003+
* @api public
5004+
*/
5005+
5006+
assert.nestedInclude = function (exp, inc, msg) {
5007+
new Assertion(exp, msg, assert.nestedInclude, true).nested.include(inc);
5008+
};
5009+
5010+
/**
5011+
* ### .notNestedInclude(haystack, needle, [message])
5012+
*
5013+
* Asserts that 'haystack' does not include 'needle'.
5014+
* Can be used to assert the absence of a subset of properties in an
5015+
* object.
5016+
* Enables the use of dot- and bracket-notation for referencing nested
5017+
* properties.
5018+
* '[]' and '.' in property names can be escaped using double backslashes.
5019+
*
5020+
* assert.notNestedInclude({'.a': {'b': 'x'}}, {'\\.a.b': 'y'});
5021+
* assert.notNestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'y'});
5022+
*
5023+
* @name notNestedInclude
5024+
* @param {Object} haystack
5025+
* @param {Object} needle
5026+
* @param {String} message
5027+
* @namespace Assert
5028+
* @api public
5029+
*/
5030+
5031+
assert.notNestedInclude = function (exp, inc, msg) {
5032+
new Assertion(exp, msg, assert.notNestedInclude, true)
5033+
.not.nested.include(inc);
5034+
};
5035+
5036+
/**
5037+
* ### .deepNestedInclude(haystack, needle, [message])
5038+
*
5039+
* Asserts that 'haystack' includes 'needle'.
5040+
* Can be used to assert the inclusion of a subset of properties in an
5041+
* object while checking for deep equality.
5042+
* Enables the use of dot- and bracket-notation for referencing nested
5043+
* properties.
5044+
* '[]' and '.' in property names can be escaped using double backslashes.
5045+
*
5046+
* assert.deepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {x: 1}});
5047+
* assert.deepNestedInclude({'.a': {'[b]': {x: 1}}}, {'\\.a.\\[b\\]': {x: 1}});
5048+
*
5049+
* @name deepNestedInclude
5050+
* @param {Object} haystack
5051+
* @param {Object} needle
5052+
* @param {String} message
5053+
* @namespace Assert
5054+
* @api public
5055+
*/
5056+
5057+
assert.deepNestedInclude = function(exp, inc, msg) {
5058+
new Assertion(exp, msg, assert.deepNestedInclude, true)
5059+
.deep.nested.include(inc);
5060+
};
5061+
5062+
/**
5063+
* ### .notDeepNestedInclude(haystack, needle, [message])
5064+
*
5065+
* Asserts that 'haystack' does not include 'needle'.
5066+
* Can be used to assert the absence of a subset of properties in an
5067+
* object while checking for deep equality.
5068+
* Enables the use of dot- and bracket-notation for referencing nested
5069+
* properties.
5070+
* '[]' and '.' in property names can be escaped using double backslashes.
5071+
*
5072+
* assert.notDeepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {y: 1}})
5073+
* assert.notDeepNestedInclude({'.a': {'[b]': {x: 1}}}, {'\\.a.\\[b\\]': {y: 2}});
5074+
*
5075+
* @name notDeepNestedInclude
5076+
* @param {Object} haystack
5077+
* @param {Object} needle
5078+
* @param {String} message
5079+
* @namespace Assert
5080+
* @api public
5081+
*/
5082+
5083+
assert.notDeepNestedInclude = function(exp, inc, msg) {
5084+
new Assertion(exp, msg, assert.notDeepNestedInclude, true)
5085+
.not.deep.nested.include(inc);
5086+
};
5087+
5088+
/**
5089+
* ### .ownInclude(haystack, needle, [message])
5090+
*
5091+
* Asserts that 'haystack' includes 'needle'.
5092+
* Can be used to assert the inclusion of a subset of properties in an
5093+
* object while ignoring inherited properties.
5094+
*
5095+
* assert.ownInclude({ a: 1 }, { a: 1 });
5096+
*
5097+
* @name ownInclude
5098+
* @param {Object} haystack
5099+
* @param {Object} needle
5100+
* @param {String} message
5101+
* @namespace Assert
5102+
* @api public
5103+
*/
5104+
5105+
assert.ownInclude = function(exp, inc, msg) {
5106+
new Assertion(exp, msg, assert.ownInclude, true).own.include(inc);
5107+
};
5108+
5109+
/**
5110+
* ### .notOwnInclude(haystack, needle, [message])
5111+
*
5112+
* Asserts that 'haystack' includes 'needle'.
5113+
* Can be used to assert the absence of a subset of properties in an
5114+
* object while ignoring inherited properties.
5115+
*
5116+
* Object.prototype.b = 2;
5117+
*
5118+
* assert.notOwnInclude({ a: 1 }, { b: 2 });
5119+
*
5120+
* @name notOwnInclude
5121+
* @param {Object} haystack
5122+
* @param {Object} needle
5123+
* @param {String} message
5124+
* @namespace Assert
5125+
* @api public
5126+
*/
5127+
5128+
assert.notOwnInclude = function(exp, inc, msg) {
5129+
new Assertion(exp, msg, assert.notOwnInclude, true).not.own.include(inc);
5130+
};
5131+
5132+
/**
5133+
* ### .deepOwnInclude(haystack, needle, [message])
5134+
*
5135+
* Asserts that 'haystack' includes 'needle'.
5136+
* Can be used to assert the inclusion of a subset of properties in an
5137+
* object while ignoring inherited properties and checking for deep equality.
5138+
*
5139+
* assert.deepOwnInclude({a: {b: 2}}, {a: {b: 2}});
5140+
*
5141+
* @name deepOwnInclude
5142+
* @param {Object} haystack
5143+
* @param {Object} needle
5144+
* @param {String} message
5145+
* @namespace Assert
5146+
* @api public
5147+
*/
5148+
5149+
assert.deepOwnInclude = function(exp, inc, msg) {
5150+
new Assertion(exp, msg, assert.deepOwnInclude, true)
5151+
.deep.own.include(inc);
5152+
};
5153+
5154+
/**
5155+
* ### .notDeepOwnInclude(haystack, needle, [message])
5156+
*
5157+
* Asserts that 'haystack' includes 'needle'.
5158+
* Can be used to assert the absence of a subset of properties in an
5159+
* object while ignoring inherited properties and checking for deep equality.
5160+
*
5161+
* assert.notDeepOwnInclude({a: {b: 2}}, {a: {c: 3}});
5162+
*
5163+
* @name notDeepOwnInclude
5164+
* @param {Object} haystack
5165+
* @param {Object} needle
5166+
* @param {String} message
5167+
* @namespace Assert
5168+
* @api public
5169+
*/
5170+
5171+
assert.notDeepOwnInclude = function(exp, inc, msg) {
5172+
new Assertion(exp, msg, assert.notDeepOwnInclude, true)
5173+
.not.deep.own.include(inc);
5174+
};
5175+
49855176
/**
49865177
* ### .match(value, regexp, [message])
49875178
*
@@ -7146,7 +7337,16 @@ var canSetPrototype = typeof Object.setPrototypeOf === 'function';
71467337
// However, some of functions' own props are not configurable and should be skipped.
71477338
var testFn = function() {};
71487339
var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) {
7149-
return !Object.getOwnPropertyDescriptor(testFn, name).configurable;
7340+
var propDesc = Object.getOwnPropertyDescriptor(testFn, name);
7341+
7342+
// Note: PhantomJS 1.x includes `callee` as one of `testFn`'s own properties,
7343+
// but then returns `undefined` as the property descriptor for `callee`. As a
7344+
// workaround, we perform an otherwise unnecessary type-check for `propDesc`,
7345+
// and then filter it out if it's not an object as it should be.
7346+
if (typeof propDesc !== 'object')
7347+
return true;
7348+
7349+
return !propDesc.configurable;
71507350
});
71517351

71527352
// Cache `Function` properties
@@ -10409,6 +10609,7 @@ module.exports = {
1040910609

1041010610
},{}],39:[function(require,module,exports){
1041110611
'use strict';
10612+
1041210613
/* !
1041310614
* type-detect
1041410615
* Copyright(c) 2013 jake luer <jake@alogicalparadox.com>
@@ -10431,7 +10632,7 @@ var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf(new Set().e
1043110632
var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf(new Map().entries());
1043210633
var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function';
1043310634
var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
10434-
var stringIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function';
10635+
var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === 'function';
1043510636
var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(''[Symbol.iterator]());
1043610637
var toStringLeftSliceLength = 8;
1043710638
var toStringRightSliceLength = -1;
@@ -10501,7 +10702,10 @@ module.exports = function typeDetect(obj) {
1050110702
* Post:
1050210703
* array literal x 22,479,650 ops/sec ±0.96% (81 runs sampled)
1050310704
*/
10504-
if (Array.isArray(obj)) {
10705+
if (
10706+
Array.isArray(obj) &&
10707+
(symbolToStringTagExists === false || !(Symbol.toStringTag in obj))
10708+
) {
1050510709
return 'Array';
1050610710
}
1050710711

@@ -10795,7 +10999,7 @@ module.exports={
1079510999
"Veselin Todorov <hi@vesln.com>",
1079611000
"John Firebaugh <john.firebaugh@gmail.com>"
1079711001
],
10798-
"version": "4.0.0-canary.2",
11002+
"version": "4.0.0",
1079911003
"repository": {
1080011004
"type": "git",
1080111005
"url": "https://github.com/chaijs/chai"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"Veselin Todorov <hi@vesln.com>",
1818
"John Firebaugh <john.firebaugh@gmail.com>"
1919
],
20-
"version": "4.0.0-canary.2",
20+
"version": "4.0.0",
2121
"repository": {
2222
"type": "git",
2323
"url": "https://github.com/chaijs/chai"

0 commit comments

Comments
 (0)