chai 4.3.7 → 4.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +1 -7
- package/History.md +1 -1
- package/chai.js +71 -43
- package/lib/chai/utils/objDisplay.js +1 -0
- package/lib/chai/utils/test.js +1 -1
- package/lib/chai.js +1 -1
- package/package.json +2 -2
package/CONTRIBUTING.md
CHANGED
|
@@ -21,7 +21,6 @@ Following these guidelines helps to communicate that you respect the time of the
|
|
|
21
21
|
|
|
22
22
|
- Creating an Issue or Pull Request requires a [GitHub](http://github.com) account.
|
|
23
23
|
- Issue reports should be **clear**, **concise** and **reproducible**. Check to see if your issue has already been resolved in the [master]() branch or already reported in Chai's [GitHub Issue Tracker](https://github.com/chaijs/chai/issues).
|
|
24
|
-
- Pull Requests must adhere to strict [coding style guidelines](https://github.com/chaijs/chai/wiki/Chai-Coding-Style-Guide).
|
|
25
24
|
- In general, avoid submitting PRs for new Assertions without asking core contributors first. More than likely it would be better implemented as a plugin.
|
|
26
25
|
- Additional support is available via the [Google Group](http://groups.google.com/group/chaijs) or on irc.freenode.net#chaijs.
|
|
27
26
|
- **IMPORTANT**: By submitting a patch, you agree to allow the project owner to license your work under the same license as that used by the project.
|
|
@@ -91,7 +90,7 @@ Good pull requests - patches, improvements, new features - are a fantastic help.
|
|
|
91
90
|
|
|
92
91
|
**Please ask first** before embarking on any significant pull request (e.g. implementing features, refactoring code), otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project.
|
|
93
92
|
|
|
94
|
-
Please adhere to the coding conventions used throughout a project (indentation, accurate comments, etc.) and any other requirements (such as test coverage).
|
|
93
|
+
Please adhere to the coding conventions used throughout a project (indentation, accurate comments, etc.) and any other requirements (such as test coverage).
|
|
95
94
|
|
|
96
95
|
Follow this process if you'd like your work considered for inclusion in the project:
|
|
97
96
|
|
|
@@ -185,11 +184,6 @@ For most of the documentation you are going to want to visit [ChaiJS.com](http:/
|
|
|
185
184
|
- [API Reference](http://chaijs.com/api/)
|
|
186
185
|
- [Plugins](http://chaijs.com/plugins/)
|
|
187
186
|
|
|
188
|
-
Alternatively, the [wiki](https://github.com/chaijs/chai/wiki) might be what you are looking for.
|
|
189
|
-
|
|
190
|
-
- [Chai Coding Style Guide](https://github.com/chaijs/chai/wiki/Chai-Coding-Style-Guide)
|
|
191
|
-
- [Third-party Resources](https://github.com/chaijs/chai/wiki/Third-Party-Resources)
|
|
192
|
-
|
|
193
187
|
Or finally, you may find a core-contributor or like-minded developer in any of our support channels.
|
|
194
188
|
|
|
195
189
|
- IRC: irc.freenode.org #chaijs
|
package/History.md
CHANGED
package/chai.js
CHANGED
|
@@ -14,7 +14,7 @@ var used = [];
|
|
|
14
14
|
* Chai version
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
exports.version = '4.3.
|
|
17
|
+
exports.version = '4.3.8';
|
|
18
18
|
|
|
19
19
|
/*!
|
|
20
20
|
* Assertion Error
|
|
@@ -8608,6 +8608,7 @@ var config = require('../config');
|
|
|
8608
8608
|
* messages or should be truncated.
|
|
8609
8609
|
*
|
|
8610
8610
|
* @param {Mixed} javascript object to inspect
|
|
8611
|
+
* @returns {string} stringified object
|
|
8611
8612
|
* @name objDisplay
|
|
8612
8613
|
* @namespace Utils
|
|
8613
8614
|
* @api public
|
|
@@ -9062,7 +9063,7 @@ var flag = require('./flag');
|
|
|
9062
9063
|
/**
|
|
9063
9064
|
* ### .test(object, expression)
|
|
9064
9065
|
*
|
|
9065
|
-
* Test
|
|
9066
|
+
* Test an object for expression.
|
|
9066
9067
|
*
|
|
9067
9068
|
* @param {Object} object (constructed Assertion)
|
|
9068
9069
|
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
|
@@ -9250,6 +9251,7 @@ AssertionError.prototype.toJSON = function (stack) {
|
|
|
9250
9251
|
* MIT Licensed
|
|
9251
9252
|
*/
|
|
9252
9253
|
|
|
9254
|
+
var getFunctionName = require('get-func-name');
|
|
9253
9255
|
/**
|
|
9254
9256
|
* ### .checkError
|
|
9255
9257
|
*
|
|
@@ -9329,34 +9331,6 @@ function compatibleMessage(thrown, errMatcher) {
|
|
|
9329
9331
|
return false;
|
|
9330
9332
|
}
|
|
9331
9333
|
|
|
9332
|
-
/**
|
|
9333
|
-
* ### .getFunctionName(constructorFn)
|
|
9334
|
-
*
|
|
9335
|
-
* Returns the name of a function.
|
|
9336
|
-
* This also includes a polyfill function if `constructorFn.name` is not defined.
|
|
9337
|
-
*
|
|
9338
|
-
* @name getFunctionName
|
|
9339
|
-
* @param {Function} constructorFn
|
|
9340
|
-
* @namespace Utils
|
|
9341
|
-
* @api private
|
|
9342
|
-
*/
|
|
9343
|
-
|
|
9344
|
-
var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\(\/]+)/;
|
|
9345
|
-
function getFunctionName(constructorFn) {
|
|
9346
|
-
var name = '';
|
|
9347
|
-
if (typeof constructorFn.name === 'undefined') {
|
|
9348
|
-
// Here we run a polyfill if constructorFn.name is not defined
|
|
9349
|
-
var match = String(constructorFn).match(functionNameMatch);
|
|
9350
|
-
if (match) {
|
|
9351
|
-
name = match[1];
|
|
9352
|
-
}
|
|
9353
|
-
} else {
|
|
9354
|
-
name = constructorFn.name;
|
|
9355
|
-
}
|
|
9356
|
-
|
|
9357
|
-
return name;
|
|
9358
|
-
}
|
|
9359
|
-
|
|
9360
9334
|
/**
|
|
9361
9335
|
* ### .getConstructorName(errorLike)
|
|
9362
9336
|
*
|
|
@@ -9376,8 +9350,11 @@ function getConstructorName(errorLike) {
|
|
|
9376
9350
|
// If `err` is not an instance of Error it is an error constructor itself or another function.
|
|
9377
9351
|
// If we've got a common function we get its name, otherwise we may need to create a new instance
|
|
9378
9352
|
// of the error just in case it's a poorly-constructed error. Please see chaijs/chai/issues/45 to know more.
|
|
9379
|
-
constructorName = getFunctionName(errorLike)
|
|
9380
|
-
|
|
9353
|
+
constructorName = getFunctionName(errorLike);
|
|
9354
|
+
if (constructorName === '') {
|
|
9355
|
+
var newConstructorName = getFunctionName(new errorLike()); // eslint-disable-line new-cap
|
|
9356
|
+
constructorName = newConstructorName || constructorName;
|
|
9357
|
+
}
|
|
9381
9358
|
}
|
|
9382
9359
|
|
|
9383
9360
|
return constructorName;
|
|
@@ -9415,7 +9392,7 @@ module.exports = {
|
|
|
9415
9392
|
getConstructorName: getConstructorName,
|
|
9416
9393
|
};
|
|
9417
9394
|
|
|
9418
|
-
},{}],35:[function(require,module,exports){
|
|
9395
|
+
},{"get-func-name":36}],35:[function(require,module,exports){
|
|
9419
9396
|
'use strict';
|
|
9420
9397
|
/* globals Symbol: false, Uint8Array: false, WeakMap: false */
|
|
9421
9398
|
/*!
|
|
@@ -9810,8 +9787,15 @@ function getEnumerableKeys(target) {
|
|
|
9810
9787
|
return keys;
|
|
9811
9788
|
}
|
|
9812
9789
|
|
|
9813
|
-
function
|
|
9814
|
-
var keys =
|
|
9790
|
+
function getEnumerableSymbols(target) {
|
|
9791
|
+
var keys = [];
|
|
9792
|
+
var allKeys = Object.getOwnPropertySymbols(target);
|
|
9793
|
+
for (var i = 0; i < allKeys.length; i += 1) {
|
|
9794
|
+
var key = allKeys[i];
|
|
9795
|
+
if (Object.getOwnPropertyDescriptor(target, key).enumerable) {
|
|
9796
|
+
keys.push(key);
|
|
9797
|
+
}
|
|
9798
|
+
}
|
|
9815
9799
|
return keys;
|
|
9816
9800
|
}
|
|
9817
9801
|
|
|
@@ -9850,8 +9834,8 @@ function keysEqual(leftHandOperand, rightHandOperand, keys, options) {
|
|
|
9850
9834
|
function objectEqual(leftHandOperand, rightHandOperand, options) {
|
|
9851
9835
|
var leftHandKeys = getEnumerableKeys(leftHandOperand);
|
|
9852
9836
|
var rightHandKeys = getEnumerableKeys(rightHandOperand);
|
|
9853
|
-
var leftHandSymbols =
|
|
9854
|
-
var rightHandSymbols =
|
|
9837
|
+
var leftHandSymbols = getEnumerableSymbols(leftHandOperand);
|
|
9838
|
+
var rightHandSymbols = getEnumerableSymbols(rightHandOperand);
|
|
9855
9839
|
leftHandKeys = leftHandKeys.concat(leftHandSymbols);
|
|
9856
9840
|
rightHandKeys = rightHandKeys.concat(rightHandSymbols);
|
|
9857
9841
|
|
|
@@ -9927,6 +9911,7 @@ function mapSymbols(arr) {
|
|
|
9927
9911
|
|
|
9928
9912
|
var toString = Function.prototype.toString;
|
|
9929
9913
|
var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\s\(\/]+)/;
|
|
9914
|
+
var maxFunctionSourceLength = 512;
|
|
9930
9915
|
function getFuncName(aFunc) {
|
|
9931
9916
|
if (typeof aFunc !== 'function') {
|
|
9932
9917
|
return null;
|
|
@@ -9934,8 +9919,15 @@ function getFuncName(aFunc) {
|
|
|
9934
9919
|
|
|
9935
9920
|
var name = '';
|
|
9936
9921
|
if (typeof Function.prototype.name === 'undefined' && typeof aFunc.name === 'undefined') {
|
|
9922
|
+
// eslint-disable-next-line prefer-reflect
|
|
9923
|
+
var functionSource = toString.call(aFunc);
|
|
9924
|
+
// To avoid unconstrained resource consumption due to pathalogically large function names,
|
|
9925
|
+
// we limit the available return value to be less than 512 characters.
|
|
9926
|
+
if (functionSource.indexOf('(') > maxFunctionSourceLength) {
|
|
9927
|
+
return name;
|
|
9928
|
+
}
|
|
9937
9929
|
// Here we run a polyfill if Function does not support the `name` property and if aFunc.name is not defined
|
|
9938
|
-
var match =
|
|
9930
|
+
var match = functionSource.match(functionNameMatch);
|
|
9939
9931
|
if (match) {
|
|
9940
9932
|
name = match[1];
|
|
9941
9933
|
}
|
|
@@ -10331,9 +10323,15 @@ module.exports = getFuncName;
|
|
|
10331
10323
|
}
|
|
10332
10324
|
|
|
10333
10325
|
function inspectDate(dateObject, options) {
|
|
10334
|
-
|
|
10335
|
-
|
|
10336
|
-
|
|
10326
|
+
var stringRepresentation = dateObject.toJSON();
|
|
10327
|
+
|
|
10328
|
+
if (stringRepresentation === null) {
|
|
10329
|
+
return 'Invalid Date';
|
|
10330
|
+
}
|
|
10331
|
+
|
|
10332
|
+
var split = stringRepresentation.split('T');
|
|
10333
|
+
var date = split[0]; // If we need to - truncate the time portion, but never the date
|
|
10334
|
+
|
|
10337
10335
|
return options.stylize("".concat(date, "T").concat(truncate(split[1], options.truncate - date.length - 1)), 'date');
|
|
10338
10336
|
}
|
|
10339
10337
|
|
|
@@ -10630,7 +10628,32 @@ module.exports = getFuncName;
|
|
|
10630
10628
|
nodeInspect = false;
|
|
10631
10629
|
}
|
|
10632
10630
|
|
|
10633
|
-
|
|
10631
|
+
function FakeMap() {
|
|
10632
|
+
// eslint-disable-next-line prefer-template
|
|
10633
|
+
this.key = 'chai/loupe__' + Math.random() + Date.now();
|
|
10634
|
+
}
|
|
10635
|
+
|
|
10636
|
+
FakeMap.prototype = {
|
|
10637
|
+
// eslint-disable-next-line object-shorthand
|
|
10638
|
+
get: function get(key) {
|
|
10639
|
+
return key[this.key];
|
|
10640
|
+
},
|
|
10641
|
+
// eslint-disable-next-line object-shorthand
|
|
10642
|
+
has: function has(key) {
|
|
10643
|
+
return this.key in key;
|
|
10644
|
+
},
|
|
10645
|
+
// eslint-disable-next-line object-shorthand
|
|
10646
|
+
set: function set(key, value) {
|
|
10647
|
+
if (Object.isExtensible(key)) {
|
|
10648
|
+
Object.defineProperty(key, this.key, {
|
|
10649
|
+
// eslint-disable-next-line object-shorthand
|
|
10650
|
+
value: value,
|
|
10651
|
+
configurable: true
|
|
10652
|
+
});
|
|
10653
|
+
}
|
|
10654
|
+
}
|
|
10655
|
+
};
|
|
10656
|
+
var constructorMap = new (typeof WeakMap === 'function' ? WeakMap : FakeMap)();
|
|
10634
10657
|
var stringTagMap = {};
|
|
10635
10658
|
var baseTypesMap = {
|
|
10636
10659
|
undefined: function undefined$1(value, options) {
|
|
@@ -10764,6 +10787,11 @@ module.exports = getFuncName;
|
|
|
10764
10787
|
} // If it is an object with an anonymous prototype, display it as an object.
|
|
10765
10788
|
|
|
10766
10789
|
|
|
10790
|
+
return inspectObject(value, options);
|
|
10791
|
+
} // last chance to check if it's an object
|
|
10792
|
+
|
|
10793
|
+
|
|
10794
|
+
if (value === Object(value)) {
|
|
10767
10795
|
return inspectObject(value, options);
|
|
10768
10796
|
} // We have run out of options! Just stringify the value
|
|
10769
10797
|
|
|
@@ -10775,7 +10803,7 @@ module.exports = getFuncName;
|
|
|
10775
10803
|
return false;
|
|
10776
10804
|
}
|
|
10777
10805
|
|
|
10778
|
-
constructorMap.
|
|
10806
|
+
constructorMap.set(constructor, inspector);
|
|
10779
10807
|
return true;
|
|
10780
10808
|
}
|
|
10781
10809
|
function registerStringTag(stringTag, inspector) {
|
package/lib/chai/utils/test.js
CHANGED
|
@@ -13,7 +13,7 @@ var flag = require('./flag');
|
|
|
13
13
|
/**
|
|
14
14
|
* ### .test(object, expression)
|
|
15
15
|
*
|
|
16
|
-
* Test
|
|
16
|
+
* Test an object for expression.
|
|
17
17
|
*
|
|
18
18
|
* @param {Object} object (constructed Assertion)
|
|
19
19
|
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
package/lib/chai.js
CHANGED
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"Veselin Todorov <hi@vesln.com>",
|
|
18
18
|
"John Firebaugh <john.firebaugh@gmail.com>"
|
|
19
19
|
],
|
|
20
|
-
"version": "4.3.
|
|
20
|
+
"version": "4.3.9",
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
23
|
"url": "https://github.com/chaijs/chai"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"assertion-error": "^1.1.0",
|
|
44
|
-
"check-error": "^1.0.
|
|
44
|
+
"check-error": "^1.0.3",
|
|
45
45
|
"deep-eql": "^4.1.2",
|
|
46
46
|
"get-func-name": "^2.0.0",
|
|
47
47
|
"loupe": "^2.3.1",
|