chai 5.1.2 → 5.2.1
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/.prettierrc.json +10 -0
- package/README.md +1 -1
- package/chai.js +892 -542
- package/eslint.config.js +15 -0
- package/lib/chai/assertion.js +181 -141
- package/lib/chai/config.js +0 -2
- package/lib/chai/core/assertions.js +760 -538
- package/lib/chai/interface/assert.js +437 -260
- package/lib/chai/interface/expect.js +11 -7
- package/lib/chai/interface/should.js +27 -21
- package/lib/chai/utils/addChainableMethod.js +69 -70
- package/lib/chai/utils/addLengthGuard.js +18 -5
- package/lib/chai/utils/addMethod.js +4 -5
- package/lib/chai/utils/addProperty.js +27 -28
- package/lib/chai/utils/expectTypes.js +18 -10
- package/lib/chai/utils/flag.js +4 -3
- package/lib/chai/utils/getMessage.js +18 -12
- package/lib/chai/utils/getOperator.js +7 -7
- package/lib/chai/utils/getProperties.js +2 -2
- package/lib/chai/utils/index.js +8 -2
- package/lib/chai/utils/inspect.js +3 -3
- package/lib/chai/utils/isNaN.js +1 -20
- package/lib/chai/utils/isProxyEnabled.js +4 -2
- package/lib/chai/utils/objDisplay.js +7 -6
- package/lib/chai/utils/overwriteChainableMethod.js +15 -14
- package/lib/chai/utils/overwriteMethod.js +8 -9
- package/lib/chai/utils/overwriteProperty.js +38 -39
- package/lib/chai/utils/proxify.js +40 -29
- package/lib/chai/utils/test.js +2 -2
- package/lib/chai/utils/transferFlags.js +9 -4
- package/lib/chai/utils/type-detect.js +1 -1
- package/lib/chai.js +2 -1
- package/package.json +15 -7
- package/tsconfig.json +18 -0
- package/lib/chai/utils/getEnumerableProperties.js +0 -25
- package/register-assert.cjs +0 -3
- package/register-expect.cjs +0 -3
- package/register-should.cjs +0 -3
package/chai.js
CHANGED
|
@@ -117,7 +117,7 @@ __name(getMessage, "getMessage");
|
|
|
117
117
|
|
|
118
118
|
// lib/chai/utils/flag.js
|
|
119
119
|
function flag(obj, key, value) {
|
|
120
|
-
|
|
120
|
+
let flags = obj.__flags || (obj.__flags = /* @__PURE__ */ Object.create(null));
|
|
121
121
|
if (arguments.length === 3) {
|
|
122
122
|
flags[key] = value;
|
|
123
123
|
} else {
|
|
@@ -128,7 +128,7 @@ __name(flag, "flag");
|
|
|
128
128
|
|
|
129
129
|
// lib/chai/utils/test.js
|
|
130
130
|
function test(obj, args) {
|
|
131
|
-
|
|
131
|
+
let negate = flag(obj, "negate"), expr = args[0];
|
|
132
132
|
return negate ? !expr : expr;
|
|
133
133
|
}
|
|
134
134
|
__name(test, "test");
|
|
@@ -188,20 +188,20 @@ var AssertionError = class _AssertionError extends Error {
|
|
|
188
188
|
|
|
189
189
|
// lib/chai/utils/expectTypes.js
|
|
190
190
|
function expectTypes(obj, types) {
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
let flagMsg = flag(obj, "message");
|
|
192
|
+
let ssfi = flag(obj, "ssfi");
|
|
193
193
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
194
194
|
obj = flag(obj, "object");
|
|
195
195
|
types = types.map(function(t) {
|
|
196
196
|
return t.toLowerCase();
|
|
197
197
|
});
|
|
198
198
|
types.sort();
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
let str = types.map(function(t, index) {
|
|
200
|
+
let art = ~["a", "e", "i", "o", "u"].indexOf(t.charAt(0)) ? "an" : "a";
|
|
201
|
+
let or = types.length > 1 && index === types.length - 1 ? "or " : "";
|
|
202
202
|
return or + art + " " + t;
|
|
203
203
|
}).join(", ");
|
|
204
|
-
|
|
204
|
+
let objType = type(obj).toLowerCase();
|
|
205
205
|
if (!types.some(function(expected) {
|
|
206
206
|
return objType === expected;
|
|
207
207
|
})) {
|
|
@@ -720,10 +720,10 @@ try {
|
|
|
720
720
|
var constructorMap = /* @__PURE__ */ new WeakMap();
|
|
721
721
|
var stringTagMap = {};
|
|
722
722
|
var baseTypesMap = {
|
|
723
|
-
undefined: (value, options) => options.stylize("undefined", "undefined"),
|
|
724
|
-
null: (value, options) => options.stylize("null", "null"),
|
|
725
|
-
boolean: (value, options) => options.stylize(String(value), "boolean"),
|
|
726
|
-
Boolean: (value, options) => options.stylize(String(value), "boolean"),
|
|
723
|
+
undefined: /* @__PURE__ */ __name((value, options) => options.stylize("undefined", "undefined"), "undefined"),
|
|
724
|
+
null: /* @__PURE__ */ __name((value, options) => options.stylize("null", "null"), "null"),
|
|
725
|
+
boolean: /* @__PURE__ */ __name((value, options) => options.stylize(String(value), "boolean"), "boolean"),
|
|
726
|
+
Boolean: /* @__PURE__ */ __name((value, options) => options.stylize(String(value), "boolean"), "Boolean"),
|
|
727
727
|
number: inspectNumber,
|
|
728
728
|
Number: inspectNumber,
|
|
729
729
|
bigint: inspectBigInt,
|
|
@@ -742,8 +742,8 @@ var baseTypesMap = {
|
|
|
742
742
|
RegExp: inspectRegExp,
|
|
743
743
|
Promise: promise_default,
|
|
744
744
|
// WeakSet, WeakMap are totally opaque to us
|
|
745
|
-
WeakSet: (value, options) => options.stylize("WeakSet{\u2026}", "special"),
|
|
746
|
-
WeakMap: (value, options) => options.stylize("WeakMap{\u2026}", "special"),
|
|
745
|
+
WeakSet: /* @__PURE__ */ __name((value, options) => options.stylize("WeakSet{\u2026}", "special"), "WeakSet"),
|
|
746
|
+
WeakMap: /* @__PURE__ */ __name((value, options) => options.stylize("WeakMap{\u2026}", "special"), "WeakMap"),
|
|
747
747
|
Arguments: inspectArguments,
|
|
748
748
|
Int8Array: inspectTypedArray,
|
|
749
749
|
Uint8Array: inspectTypedArray,
|
|
@@ -754,9 +754,9 @@ var baseTypesMap = {
|
|
|
754
754
|
Uint32Array: inspectTypedArray,
|
|
755
755
|
Float32Array: inspectTypedArray,
|
|
756
756
|
Float64Array: inspectTypedArray,
|
|
757
|
-
Generator: () => "",
|
|
758
|
-
DataView: () => "",
|
|
759
|
-
ArrayBuffer: () => "",
|
|
757
|
+
Generator: /* @__PURE__ */ __name(() => "", "Generator"),
|
|
758
|
+
DataView: /* @__PURE__ */ __name(() => "", "DataView"),
|
|
759
|
+
ArrayBuffer: /* @__PURE__ */ __name(() => "", "ArrayBuffer"),
|
|
760
760
|
Error: inspectObject2,
|
|
761
761
|
HTMLCollection: inspectHTMLCollection,
|
|
762
762
|
NodeList: inspectHTMLCollection
|
|
@@ -929,7 +929,7 @@ var config = {
|
|
|
929
929
|
|
|
930
930
|
// lib/chai/utils/inspect.js
|
|
931
931
|
function inspect2(obj, showHidden, depth, colors) {
|
|
932
|
-
|
|
932
|
+
let options = {
|
|
933
933
|
colors,
|
|
934
934
|
depth: typeof depth === "undefined" ? 2 : depth,
|
|
935
935
|
showHidden,
|
|
@@ -941,14 +941,14 @@ __name(inspect2, "inspect");
|
|
|
941
941
|
|
|
942
942
|
// lib/chai/utils/objDisplay.js
|
|
943
943
|
function objDisplay(obj) {
|
|
944
|
-
|
|
944
|
+
let str = inspect2(obj), type3 = Object.prototype.toString.call(obj);
|
|
945
945
|
if (config.truncateThreshold && str.length >= config.truncateThreshold) {
|
|
946
946
|
if (type3 === "[object Function]") {
|
|
947
947
|
return !obj.name || obj.name === "" ? "[Function]" : "[Function: " + obj.name + "]";
|
|
948
948
|
} else if (type3 === "[object Array]") {
|
|
949
949
|
return "[ Array(" + obj.length + ") ]";
|
|
950
950
|
} else if (type3 === "[object Object]") {
|
|
951
|
-
|
|
951
|
+
let keys = Object.keys(obj), kstr = keys.length > 2 ? keys.splice(0, 2).join(", ") + ", ..." : keys.join(", ");
|
|
952
952
|
return "{ Object (" + kstr + ") }";
|
|
953
953
|
} else {
|
|
954
954
|
return str;
|
|
@@ -961,9 +961,13 @@ __name(objDisplay, "objDisplay");
|
|
|
961
961
|
|
|
962
962
|
// lib/chai/utils/getMessage.js
|
|
963
963
|
function getMessage2(obj, args) {
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
964
|
+
let negate = flag(obj, "negate");
|
|
965
|
+
let val = flag(obj, "object");
|
|
966
|
+
let expected = args[3];
|
|
967
|
+
let actual = getActual(obj, args);
|
|
968
|
+
let msg = negate ? args[2] : args[1];
|
|
969
|
+
let flagMsg = flag(obj, "message");
|
|
970
|
+
if (typeof msg === "function") msg = msg();
|
|
967
971
|
msg = msg || "";
|
|
968
972
|
msg = msg.replace(/#\{this\}/g, function() {
|
|
969
973
|
return objDisplay(val);
|
|
@@ -978,12 +982,12 @@ __name(getMessage2, "getMessage");
|
|
|
978
982
|
|
|
979
983
|
// lib/chai/utils/transferFlags.js
|
|
980
984
|
function transferFlags(assertion, object, includeAll) {
|
|
981
|
-
|
|
985
|
+
let flags = assertion.__flags || (assertion.__flags = /* @__PURE__ */ Object.create(null));
|
|
982
986
|
if (!object.__flags) {
|
|
983
987
|
object.__flags = /* @__PURE__ */ Object.create(null);
|
|
984
988
|
}
|
|
985
989
|
includeAll = arguments.length === 3 ? includeAll : true;
|
|
986
|
-
for (
|
|
990
|
+
for (let flag3 in flags) {
|
|
987
991
|
if (includeAll || flag3 !== "object" && flag3 !== "ssfi" && flag3 !== "lockSsfi" && flag3 != "message") {
|
|
988
992
|
object.__flags[flag3] = flags[flag3];
|
|
989
993
|
}
|
|
@@ -1377,92 +1381,183 @@ function getPathInfo(obj, path) {
|
|
|
1377
1381
|
__name(getPathInfo, "getPathInfo");
|
|
1378
1382
|
|
|
1379
1383
|
// lib/chai/assertion.js
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1384
|
+
var Assertion = class _Assertion {
|
|
1385
|
+
static {
|
|
1386
|
+
__name(this, "Assertion");
|
|
1387
|
+
}
|
|
1388
|
+
/** @type {{}} */
|
|
1389
|
+
__flags = {};
|
|
1390
|
+
/**
|
|
1391
|
+
* Creates object for chaining.
|
|
1392
|
+
* `Assertion` objects contain metadata in the form of flags. Three flags can
|
|
1393
|
+
* be assigned during instantiation by passing arguments to this constructor:
|
|
1394
|
+
*
|
|
1395
|
+
* - `object`: This flag contains the target of the assertion. For example, in
|
|
1396
|
+
* the assertion `expect(numKittens).to.equal(7);`, the `object` flag will
|
|
1397
|
+
* contain `numKittens` so that the `equal` assertion can reference it when
|
|
1398
|
+
* needed.
|
|
1399
|
+
*
|
|
1400
|
+
* - `message`: This flag contains an optional custom error message to be
|
|
1401
|
+
* prepended to the error message that's generated by the assertion when it
|
|
1402
|
+
* fails.
|
|
1403
|
+
*
|
|
1404
|
+
* - `ssfi`: This flag stands for "start stack function indicator". It
|
|
1405
|
+
* contains a function reference that serves as the starting point for
|
|
1406
|
+
* removing frames from the stack trace of the error that's created by the
|
|
1407
|
+
* assertion when it fails. The goal is to provide a cleaner stack trace to
|
|
1408
|
+
* end users by removing Chai's internal functions. Note that it only works
|
|
1409
|
+
* in environments that support `Error.captureStackTrace`, and only when
|
|
1410
|
+
* `Chai.config.includeStack` hasn't been set to `false`.
|
|
1411
|
+
*
|
|
1412
|
+
* - `lockSsfi`: This flag controls whether or not the given `ssfi` flag
|
|
1413
|
+
* should retain its current value, even as assertions are chained off of
|
|
1414
|
+
* this object. This is usually set to `true` when creating a new assertion
|
|
1415
|
+
* from within another assertion. It's also temporarily set to `true` before
|
|
1416
|
+
* an overwritten assertion gets called by the overwriting assertion.
|
|
1417
|
+
*
|
|
1418
|
+
* - `eql`: This flag contains the deepEqual function to be used by the assertion.
|
|
1419
|
+
*
|
|
1420
|
+
* @param {unknown} obj target of the assertion
|
|
1421
|
+
* @param {string} [msg] (optional) custom error message
|
|
1422
|
+
* @param {Function} [ssfi] (optional) starting point for removing stack frames
|
|
1423
|
+
* @param {boolean} [lockSsfi] (optional) whether or not the ssfi flag is locked
|
|
1424
|
+
*/
|
|
1425
|
+
constructor(obj, msg, ssfi, lockSsfi) {
|
|
1426
|
+
flag(this, "ssfi", ssfi || _Assertion);
|
|
1427
|
+
flag(this, "lockSsfi", lockSsfi);
|
|
1428
|
+
flag(this, "object", obj);
|
|
1429
|
+
flag(this, "message", msg);
|
|
1430
|
+
flag(this, "eql", config.deepEqual || deep_eql_default);
|
|
1431
|
+
return proxify(this);
|
|
1432
|
+
}
|
|
1433
|
+
/** @returns {boolean} */
|
|
1434
|
+
static get includeStack() {
|
|
1435
|
+
console.warn(
|
|
1436
|
+
"Assertion.includeStack is deprecated, use chai.config.includeStack instead."
|
|
1437
|
+
);
|
|
1392
1438
|
return config.includeStack;
|
|
1393
|
-
}
|
|
1394
|
-
|
|
1395
|
-
|
|
1439
|
+
}
|
|
1440
|
+
/** @param {boolean} value */
|
|
1441
|
+
static set includeStack(value) {
|
|
1442
|
+
console.warn(
|
|
1443
|
+
"Assertion.includeStack is deprecated, use chai.config.includeStack instead."
|
|
1444
|
+
);
|
|
1396
1445
|
config.includeStack = value;
|
|
1397
1446
|
}
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1447
|
+
/** @returns {boolean} */
|
|
1448
|
+
static get showDiff() {
|
|
1449
|
+
console.warn(
|
|
1450
|
+
"Assertion.showDiff is deprecated, use chai.config.showDiff instead."
|
|
1451
|
+
);
|
|
1402
1452
|
return config.showDiff;
|
|
1403
|
-
},
|
|
1404
|
-
set: function(value) {
|
|
1405
|
-
console.warn("Assertion.showDiff is deprecated, use chai.config.showDiff instead.");
|
|
1406
|
-
config.showDiff = value;
|
|
1407
1453
|
}
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
Assertion.addMethod = function(name, fn) {
|
|
1413
|
-
addMethod(this.prototype, name, fn);
|
|
1414
|
-
};
|
|
1415
|
-
Assertion.addChainableMethod = function(name, fn, chainingBehavior) {
|
|
1416
|
-
addChainableMethod(this.prototype, name, fn, chainingBehavior);
|
|
1417
|
-
};
|
|
1418
|
-
Assertion.overwriteProperty = function(name, fn) {
|
|
1419
|
-
overwriteProperty(this.prototype, name, fn);
|
|
1420
|
-
};
|
|
1421
|
-
Assertion.overwriteMethod = function(name, fn) {
|
|
1422
|
-
overwriteMethod(this.prototype, name, fn);
|
|
1423
|
-
};
|
|
1424
|
-
Assertion.overwriteChainableMethod = function(name, fn, chainingBehavior) {
|
|
1425
|
-
overwriteChainableMethod(this.prototype, name, fn, chainingBehavior);
|
|
1426
|
-
};
|
|
1427
|
-
Assertion.prototype.assert = function(expr, msg, negateMsg, expected, _actual, showDiff) {
|
|
1428
|
-
var ok = test(this, arguments);
|
|
1429
|
-
if (false !== showDiff)
|
|
1430
|
-
showDiff = true;
|
|
1431
|
-
if (void 0 === expected && void 0 === _actual)
|
|
1432
|
-
showDiff = false;
|
|
1433
|
-
if (true !== config.showDiff)
|
|
1434
|
-
showDiff = false;
|
|
1435
|
-
if (!ok) {
|
|
1436
|
-
msg = getMessage2(this, arguments);
|
|
1437
|
-
var actual = getActual(this, arguments);
|
|
1438
|
-
var assertionErrorObjectProperties = {
|
|
1439
|
-
actual,
|
|
1440
|
-
expected,
|
|
1441
|
-
showDiff
|
|
1442
|
-
};
|
|
1443
|
-
var operator = getOperator(this, arguments);
|
|
1444
|
-
if (operator) {
|
|
1445
|
-
assertionErrorObjectProperties.operator = operator;
|
|
1446
|
-
}
|
|
1447
|
-
throw new AssertionError(
|
|
1448
|
-
msg,
|
|
1449
|
-
assertionErrorObjectProperties,
|
|
1450
|
-
config.includeStack ? this.assert : flag(this, "ssfi")
|
|
1454
|
+
/** @param {boolean} value */
|
|
1455
|
+
static set showDiff(value) {
|
|
1456
|
+
console.warn(
|
|
1457
|
+
"Assertion.showDiff is deprecated, use chai.config.showDiff instead."
|
|
1451
1458
|
);
|
|
1459
|
+
config.showDiff = value;
|
|
1452
1460
|
}
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
{
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1461
|
+
/**
|
|
1462
|
+
* @param {string} name
|
|
1463
|
+
* @param {Function} fn
|
|
1464
|
+
*/
|
|
1465
|
+
static addProperty(name, fn) {
|
|
1466
|
+
addProperty(this.prototype, name, fn);
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* @param {string} name
|
|
1470
|
+
* @param {Function} fn
|
|
1471
|
+
*/
|
|
1472
|
+
static addMethod(name, fn) {
|
|
1473
|
+
addMethod(this.prototype, name, fn);
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* @param {string} name
|
|
1477
|
+
* @param {Function} fn
|
|
1478
|
+
* @param {Function} chainingBehavior
|
|
1479
|
+
*/
|
|
1480
|
+
static addChainableMethod(name, fn, chainingBehavior) {
|
|
1481
|
+
addChainableMethod(this.prototype, name, fn, chainingBehavior);
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* @param {string} name
|
|
1485
|
+
* @param {Function} fn
|
|
1486
|
+
*/
|
|
1487
|
+
static overwriteProperty(name, fn) {
|
|
1488
|
+
overwriteProperty(this.prototype, name, fn);
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* @param {string} name
|
|
1492
|
+
* @param {Function} fn
|
|
1493
|
+
*/
|
|
1494
|
+
static overwriteMethod(name, fn) {
|
|
1495
|
+
overwriteMethod(this.prototype, name, fn);
|
|
1496
|
+
}
|
|
1497
|
+
/**
|
|
1498
|
+
* @param {string} name
|
|
1499
|
+
* @param {Function} fn
|
|
1500
|
+
* @param {Function} chainingBehavior
|
|
1501
|
+
*/
|
|
1502
|
+
static overwriteChainableMethod(name, fn, chainingBehavior) {
|
|
1503
|
+
overwriteChainableMethod(this.prototype, name, fn, chainingBehavior);
|
|
1504
|
+
}
|
|
1505
|
+
/**
|
|
1506
|
+
* ### .assert(expression, message, negateMessage, expected, actual, showDiff)
|
|
1507
|
+
*
|
|
1508
|
+
* Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass.
|
|
1509
|
+
*
|
|
1510
|
+
* @name assert
|
|
1511
|
+
* @param {unknown} _expr to be tested
|
|
1512
|
+
* @param {string | Function} msg or function that returns message to display if expression fails
|
|
1513
|
+
* @param {string | Function} _negateMsg or function that returns negatedMessage to display if negated expression fails
|
|
1514
|
+
* @param {unknown} expected value (remember to check for negation)
|
|
1515
|
+
* @param {unknown} _actual (optional) will default to `this.obj`
|
|
1516
|
+
* @param {boolean} showDiff (optional) when set to `true`, assert will display a diff in addition to the message if expression fails
|
|
1517
|
+
* @returns {void}
|
|
1518
|
+
*/
|
|
1519
|
+
assert(_expr, msg, _negateMsg, expected, _actual, showDiff) {
|
|
1520
|
+
const ok = test(this, arguments);
|
|
1521
|
+
if (false !== showDiff) showDiff = true;
|
|
1522
|
+
if (void 0 === expected && void 0 === _actual) showDiff = false;
|
|
1523
|
+
if (true !== config.showDiff) showDiff = false;
|
|
1524
|
+
if (!ok) {
|
|
1525
|
+
msg = getMessage2(this, arguments);
|
|
1526
|
+
const actual = getActual(this, arguments);
|
|
1527
|
+
const assertionErrorObjectProperties = {
|
|
1528
|
+
actual,
|
|
1529
|
+
expected,
|
|
1530
|
+
showDiff
|
|
1531
|
+
};
|
|
1532
|
+
const operator = getOperator(this, arguments);
|
|
1533
|
+
if (operator) {
|
|
1534
|
+
assertionErrorObjectProperties.operator = operator;
|
|
1535
|
+
}
|
|
1536
|
+
throw new AssertionError(
|
|
1537
|
+
msg,
|
|
1538
|
+
assertionErrorObjectProperties,
|
|
1539
|
+
// @ts-expect-error Not sure what to do about these types yet
|
|
1540
|
+
config.includeStack ? this.assert : flag(this, "ssfi")
|
|
1541
|
+
);
|
|
1463
1542
|
}
|
|
1464
1543
|
}
|
|
1465
|
-
|
|
1544
|
+
/**
|
|
1545
|
+
* Quick reference to stored `actual` value for plugin developers.
|
|
1546
|
+
*
|
|
1547
|
+
* @returns {unknown}
|
|
1548
|
+
*/
|
|
1549
|
+
get _obj() {
|
|
1550
|
+
return flag(this, "object");
|
|
1551
|
+
}
|
|
1552
|
+
/**
|
|
1553
|
+
* Quick reference to stored `actual` value for plugin developers.
|
|
1554
|
+
*
|
|
1555
|
+
* @param {unknown} val
|
|
1556
|
+
*/
|
|
1557
|
+
set _obj(val) {
|
|
1558
|
+
flag(this, "object", val);
|
|
1559
|
+
}
|
|
1560
|
+
};
|
|
1466
1561
|
|
|
1467
1562
|
// lib/chai/utils/isProxyEnabled.js
|
|
1468
1563
|
function isProxyEnabled() {
|
|
@@ -1474,24 +1569,19 @@ __name(isProxyEnabled, "isProxyEnabled");
|
|
|
1474
1569
|
function addProperty(ctx, name, getter) {
|
|
1475
1570
|
getter = getter === void 0 ? function() {
|
|
1476
1571
|
} : getter;
|
|
1477
|
-
Object.defineProperty(
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
return newAssertion;
|
|
1491
|
-
}, "propertyGetter"),
|
|
1492
|
-
configurable: true
|
|
1493
|
-
}
|
|
1494
|
-
);
|
|
1572
|
+
Object.defineProperty(ctx, name, {
|
|
1573
|
+
get: /* @__PURE__ */ __name(function propertyGetter() {
|
|
1574
|
+
if (!isProxyEnabled() && !flag(this, "lockSsfi")) {
|
|
1575
|
+
flag(this, "ssfi", propertyGetter);
|
|
1576
|
+
}
|
|
1577
|
+
let result = getter.call(this);
|
|
1578
|
+
if (result !== void 0) return result;
|
|
1579
|
+
let newAssertion = new Assertion();
|
|
1580
|
+
transferFlags(this, newAssertion);
|
|
1581
|
+
return newAssertion;
|
|
1582
|
+
}, "propertyGetter"),
|
|
1583
|
+
configurable: true
|
|
1584
|
+
});
|
|
1495
1585
|
}
|
|
1496
1586
|
__name(addProperty, "addProperty");
|
|
1497
1587
|
|
|
@@ -1499,15 +1589,18 @@ __name(addProperty, "addProperty");
|
|
|
1499
1589
|
var fnLengthDesc = Object.getOwnPropertyDescriptor(function() {
|
|
1500
1590
|
}, "length");
|
|
1501
1591
|
function addLengthGuard(fn, assertionName, isChainable) {
|
|
1502
|
-
if (!fnLengthDesc.configurable)
|
|
1503
|
-
return fn;
|
|
1592
|
+
if (!fnLengthDesc.configurable) return fn;
|
|
1504
1593
|
Object.defineProperty(fn, "length", {
|
|
1505
|
-
get: function() {
|
|
1594
|
+
get: /* @__PURE__ */ __name(function() {
|
|
1506
1595
|
if (isChainable) {
|
|
1507
|
-
throw Error(
|
|
1596
|
+
throw Error(
|
|
1597
|
+
"Invalid Chai property: " + assertionName + '.length. Due to a compatibility issue, "length" cannot directly follow "' + assertionName + '". Use "' + assertionName + '.lengthOf" instead.'
|
|
1598
|
+
);
|
|
1508
1599
|
}
|
|
1509
|
-
throw Error(
|
|
1510
|
-
|
|
1600
|
+
throw Error(
|
|
1601
|
+
"Invalid Chai property: " + assertionName + '.length. See docs for proper usage of "' + assertionName + '".'
|
|
1602
|
+
);
|
|
1603
|
+
}, "get")
|
|
1511
1604
|
});
|
|
1512
1605
|
return fn;
|
|
1513
1606
|
}
|
|
@@ -1515,14 +1608,14 @@ __name(addLengthGuard, "addLengthGuard");
|
|
|
1515
1608
|
|
|
1516
1609
|
// lib/chai/utils/getProperties.js
|
|
1517
1610
|
function getProperties(object) {
|
|
1518
|
-
|
|
1611
|
+
let result = Object.getOwnPropertyNames(object);
|
|
1519
1612
|
function addProperty2(property) {
|
|
1520
1613
|
if (result.indexOf(property) === -1) {
|
|
1521
1614
|
result.push(property);
|
|
1522
1615
|
}
|
|
1523
1616
|
}
|
|
1524
1617
|
__name(addProperty2, "addProperty");
|
|
1525
|
-
|
|
1618
|
+
let proto = Object.getPrototypeOf(object);
|
|
1526
1619
|
while (proto !== null) {
|
|
1527
1620
|
Object.getOwnPropertyNames(proto).forEach(addProperty2);
|
|
1528
1621
|
proto = Object.getPrototypeOf(proto);
|
|
@@ -1534,23 +1627,24 @@ __name(getProperties, "getProperties");
|
|
|
1534
1627
|
// lib/chai/utils/proxify.js
|
|
1535
1628
|
var builtins = ["__flags", "__methods", "_obj", "assert"];
|
|
1536
1629
|
function proxify(obj, nonChainableMethodName) {
|
|
1537
|
-
if (!isProxyEnabled())
|
|
1538
|
-
return obj;
|
|
1630
|
+
if (!isProxyEnabled()) return obj;
|
|
1539
1631
|
return new Proxy(obj, {
|
|
1540
1632
|
get: /* @__PURE__ */ __name(function proxyGetter(target, property) {
|
|
1541
1633
|
if (typeof property === "string" && config.proxyExcludedKeys.indexOf(property) === -1 && !Reflect.has(target, property)) {
|
|
1542
1634
|
if (nonChainableMethodName) {
|
|
1543
|
-
throw Error(
|
|
1635
|
+
throw Error(
|
|
1636
|
+
"Invalid Chai property: " + nonChainableMethodName + "." + property + '. See docs for proper usage of "' + nonChainableMethodName + '".'
|
|
1637
|
+
);
|
|
1544
1638
|
}
|
|
1545
|
-
|
|
1546
|
-
|
|
1639
|
+
let suggestion = null;
|
|
1640
|
+
let suggestionDistance = 4;
|
|
1547
1641
|
getProperties(target).forEach(function(prop) {
|
|
1548
|
-
if (
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
);
|
|
1642
|
+
if (
|
|
1643
|
+
// we actually mean to check `Object.prototype` here
|
|
1644
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
1645
|
+
!Object.prototype.hasOwnProperty(prop) && builtins.indexOf(prop) === -1
|
|
1646
|
+
) {
|
|
1647
|
+
let dist = stringDistanceCapped(property, prop, suggestionDistance);
|
|
1554
1648
|
if (dist < suggestionDistance) {
|
|
1555
1649
|
suggestion = prop;
|
|
1556
1650
|
suggestionDistance = dist;
|
|
@@ -1558,7 +1652,9 @@ function proxify(obj, nonChainableMethodName) {
|
|
|
1558
1652
|
}
|
|
1559
1653
|
});
|
|
1560
1654
|
if (suggestion !== null) {
|
|
1561
|
-
throw Error(
|
|
1655
|
+
throw Error(
|
|
1656
|
+
"Invalid Chai property: " + property + '. Did you mean "' + suggestion + '"?'
|
|
1657
|
+
);
|
|
1562
1658
|
} else {
|
|
1563
1659
|
throw Error("Invalid Chai property: " + property);
|
|
1564
1660
|
}
|
|
@@ -1575,17 +1671,17 @@ function stringDistanceCapped(strA, strB, cap) {
|
|
|
1575
1671
|
if (Math.abs(strA.length - strB.length) >= cap) {
|
|
1576
1672
|
return cap;
|
|
1577
1673
|
}
|
|
1578
|
-
|
|
1579
|
-
for (
|
|
1674
|
+
let memo = [];
|
|
1675
|
+
for (let i = 0; i <= strA.length; i++) {
|
|
1580
1676
|
memo[i] = Array(strB.length + 1).fill(0);
|
|
1581
1677
|
memo[i][0] = i;
|
|
1582
1678
|
}
|
|
1583
|
-
for (
|
|
1679
|
+
for (let j = 0; j < strB.length; j++) {
|
|
1584
1680
|
memo[0][j] = j;
|
|
1585
1681
|
}
|
|
1586
|
-
for (
|
|
1587
|
-
|
|
1588
|
-
for (
|
|
1682
|
+
for (let i = 1; i <= strA.length; i++) {
|
|
1683
|
+
let ch = strA.charCodeAt(i - 1);
|
|
1684
|
+
for (let j = 1; j <= strB.length; j++) {
|
|
1589
1685
|
if (Math.abs(i - j) >= cap) {
|
|
1590
1686
|
memo[i][j] = cap;
|
|
1591
1687
|
continue;
|
|
@@ -1603,14 +1699,13 @@ __name(stringDistanceCapped, "stringDistanceCapped");
|
|
|
1603
1699
|
|
|
1604
1700
|
// lib/chai/utils/addMethod.js
|
|
1605
1701
|
function addMethod(ctx, name, method) {
|
|
1606
|
-
|
|
1702
|
+
let methodWrapper = /* @__PURE__ */ __name(function() {
|
|
1607
1703
|
if (!flag(this, "lockSsfi")) {
|
|
1608
1704
|
flag(this, "ssfi", methodWrapper);
|
|
1609
1705
|
}
|
|
1610
|
-
|
|
1611
|
-
if (result !== void 0)
|
|
1612
|
-
|
|
1613
|
-
var newAssertion = new Assertion();
|
|
1706
|
+
let result = method.apply(this, arguments);
|
|
1707
|
+
if (result !== void 0) return result;
|
|
1708
|
+
let newAssertion = new Assertion();
|
|
1614
1709
|
transferFlags(this, newAssertion);
|
|
1615
1710
|
return newAssertion;
|
|
1616
1711
|
}, "methodWrapper");
|
|
@@ -1621,54 +1716,48 @@ __name(addMethod, "addMethod");
|
|
|
1621
1716
|
|
|
1622
1717
|
// lib/chai/utils/overwriteProperty.js
|
|
1623
1718
|
function overwriteProperty(ctx, name, getter) {
|
|
1624
|
-
|
|
1719
|
+
let _get = Object.getOwnPropertyDescriptor(ctx, name), _super = /* @__PURE__ */ __name(function() {
|
|
1625
1720
|
}, "_super");
|
|
1626
|
-
if (_get && "function" === typeof _get.get)
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
return newAssertion;
|
|
1646
|
-
}, "overwritingPropertyGetter"),
|
|
1647
|
-
configurable: true
|
|
1648
|
-
}
|
|
1649
|
-
);
|
|
1721
|
+
if (_get && "function" === typeof _get.get) _super = _get.get;
|
|
1722
|
+
Object.defineProperty(ctx, name, {
|
|
1723
|
+
get: /* @__PURE__ */ __name(function overwritingPropertyGetter() {
|
|
1724
|
+
if (!isProxyEnabled() && !flag(this, "lockSsfi")) {
|
|
1725
|
+
flag(this, "ssfi", overwritingPropertyGetter);
|
|
1726
|
+
}
|
|
1727
|
+
let origLockSsfi = flag(this, "lockSsfi");
|
|
1728
|
+
flag(this, "lockSsfi", true);
|
|
1729
|
+
let result = getter(_super).call(this);
|
|
1730
|
+
flag(this, "lockSsfi", origLockSsfi);
|
|
1731
|
+
if (result !== void 0) {
|
|
1732
|
+
return result;
|
|
1733
|
+
}
|
|
1734
|
+
let newAssertion = new Assertion();
|
|
1735
|
+
transferFlags(this, newAssertion);
|
|
1736
|
+
return newAssertion;
|
|
1737
|
+
}, "overwritingPropertyGetter"),
|
|
1738
|
+
configurable: true
|
|
1739
|
+
});
|
|
1650
1740
|
}
|
|
1651
1741
|
__name(overwriteProperty, "overwriteProperty");
|
|
1652
1742
|
|
|
1653
1743
|
// lib/chai/utils/overwriteMethod.js
|
|
1654
1744
|
function overwriteMethod(ctx, name, method) {
|
|
1655
|
-
|
|
1745
|
+
let _method = ctx[name], _super = /* @__PURE__ */ __name(function() {
|
|
1656
1746
|
throw new Error(name + " is not a function");
|
|
1657
1747
|
}, "_super");
|
|
1658
|
-
if (_method && "function" === typeof _method)
|
|
1659
|
-
|
|
1660
|
-
var overwritingMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
1748
|
+
if (_method && "function" === typeof _method) _super = _method;
|
|
1749
|
+
let overwritingMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
1661
1750
|
if (!flag(this, "lockSsfi")) {
|
|
1662
1751
|
flag(this, "ssfi", overwritingMethodWrapper);
|
|
1663
1752
|
}
|
|
1664
|
-
|
|
1753
|
+
let origLockSsfi = flag(this, "lockSsfi");
|
|
1665
1754
|
flag(this, "lockSsfi", true);
|
|
1666
|
-
|
|
1755
|
+
let result = method(_super).apply(this, arguments);
|
|
1667
1756
|
flag(this, "lockSsfi", origLockSsfi);
|
|
1668
1757
|
if (result !== void 0) {
|
|
1669
1758
|
return result;
|
|
1670
1759
|
}
|
|
1671
|
-
|
|
1760
|
+
let newAssertion = new Assertion();
|
|
1672
1761
|
transferFlags(this, newAssertion);
|
|
1673
1762
|
return newAssertion;
|
|
1674
1763
|
}, "overwritingMethodWrapper");
|
|
@@ -1682,9 +1771,8 @@ var canSetPrototype = typeof Object.setPrototypeOf === "function";
|
|
|
1682
1771
|
var testFn = /* @__PURE__ */ __name(function() {
|
|
1683
1772
|
}, "testFn");
|
|
1684
1773
|
var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) {
|
|
1685
|
-
|
|
1686
|
-
if (typeof propDesc !== "object")
|
|
1687
|
-
return true;
|
|
1774
|
+
let propDesc = Object.getOwnPropertyDescriptor(testFn, name);
|
|
1775
|
+
if (typeof propDesc !== "object") return true;
|
|
1688
1776
|
return !propDesc.configurable;
|
|
1689
1777
|
});
|
|
1690
1778
|
var call = Function.prototype.call;
|
|
@@ -1694,7 +1782,7 @@ function addChainableMethod(ctx, name, method, chainingBehavior) {
|
|
|
1694
1782
|
chainingBehavior = /* @__PURE__ */ __name(function() {
|
|
1695
1783
|
}, "chainingBehavior");
|
|
1696
1784
|
}
|
|
1697
|
-
|
|
1785
|
+
let chainableBehavior = {
|
|
1698
1786
|
method,
|
|
1699
1787
|
chainingBehavior
|
|
1700
1788
|
};
|
|
@@ -1702,69 +1790,65 @@ function addChainableMethod(ctx, name, method, chainingBehavior) {
|
|
|
1702
1790
|
ctx.__methods = {};
|
|
1703
1791
|
}
|
|
1704
1792
|
ctx.__methods[name] = chainableBehavior;
|
|
1705
|
-
Object.defineProperty(
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
var chainableMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
1712
|
-
if (!flag(this, "lockSsfi")) {
|
|
1713
|
-
flag(this, "ssfi", chainableMethodWrapper);
|
|
1714
|
-
}
|
|
1715
|
-
var result = chainableBehavior.method.apply(this, arguments);
|
|
1716
|
-
if (result !== void 0) {
|
|
1717
|
-
return result;
|
|
1718
|
-
}
|
|
1719
|
-
var newAssertion = new Assertion();
|
|
1720
|
-
transferFlags(this, newAssertion);
|
|
1721
|
-
return newAssertion;
|
|
1722
|
-
}, "chainableMethodWrapper");
|
|
1723
|
-
addLengthGuard(chainableMethodWrapper, name, true);
|
|
1724
|
-
if (canSetPrototype) {
|
|
1725
|
-
var prototype = Object.create(this);
|
|
1726
|
-
prototype.call = call;
|
|
1727
|
-
prototype.apply = apply;
|
|
1728
|
-
Object.setPrototypeOf(chainableMethodWrapper, prototype);
|
|
1729
|
-
} else {
|
|
1730
|
-
var asserterNames = Object.getOwnPropertyNames(ctx);
|
|
1731
|
-
asserterNames.forEach(function(asserterName) {
|
|
1732
|
-
if (excludeNames.indexOf(asserterName) !== -1) {
|
|
1733
|
-
return;
|
|
1734
|
-
}
|
|
1735
|
-
var pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
|
|
1736
|
-
Object.defineProperty(chainableMethodWrapper, asserterName, pd);
|
|
1737
|
-
});
|
|
1793
|
+
Object.defineProperty(ctx, name, {
|
|
1794
|
+
get: /* @__PURE__ */ __name(function chainableMethodGetter() {
|
|
1795
|
+
chainableBehavior.chainingBehavior.call(this);
|
|
1796
|
+
let chainableMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
1797
|
+
if (!flag(this, "lockSsfi")) {
|
|
1798
|
+
flag(this, "ssfi", chainableMethodWrapper);
|
|
1738
1799
|
}
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1800
|
+
let result = chainableBehavior.method.apply(this, arguments);
|
|
1801
|
+
if (result !== void 0) {
|
|
1802
|
+
return result;
|
|
1803
|
+
}
|
|
1804
|
+
let newAssertion = new Assertion();
|
|
1805
|
+
transferFlags(this, newAssertion);
|
|
1806
|
+
return newAssertion;
|
|
1807
|
+
}, "chainableMethodWrapper");
|
|
1808
|
+
addLengthGuard(chainableMethodWrapper, name, true);
|
|
1809
|
+
if (canSetPrototype) {
|
|
1810
|
+
let prototype = Object.create(this);
|
|
1811
|
+
prototype.call = call;
|
|
1812
|
+
prototype.apply = apply;
|
|
1813
|
+
Object.setPrototypeOf(chainableMethodWrapper, prototype);
|
|
1814
|
+
} else {
|
|
1815
|
+
let asserterNames = Object.getOwnPropertyNames(ctx);
|
|
1816
|
+
asserterNames.forEach(function(asserterName) {
|
|
1817
|
+
if (excludeNames.indexOf(asserterName) !== -1) {
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1820
|
+
let pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
|
|
1821
|
+
Object.defineProperty(chainableMethodWrapper, asserterName, pd);
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1824
|
+
transferFlags(this, chainableMethodWrapper);
|
|
1825
|
+
return proxify(chainableMethodWrapper);
|
|
1826
|
+
}, "chainableMethodGetter"),
|
|
1827
|
+
configurable: true
|
|
1828
|
+
});
|
|
1745
1829
|
}
|
|
1746
1830
|
__name(addChainableMethod, "addChainableMethod");
|
|
1747
1831
|
|
|
1748
1832
|
// lib/chai/utils/overwriteChainableMethod.js
|
|
1749
1833
|
function overwriteChainableMethod(ctx, name, method, chainingBehavior) {
|
|
1750
|
-
|
|
1751
|
-
|
|
1834
|
+
let chainableBehavior = ctx.__methods[name];
|
|
1835
|
+
let _chainingBehavior = chainableBehavior.chainingBehavior;
|
|
1752
1836
|
chainableBehavior.chainingBehavior = /* @__PURE__ */ __name(function overwritingChainableMethodGetter() {
|
|
1753
|
-
|
|
1837
|
+
let result = chainingBehavior(_chainingBehavior).call(this);
|
|
1754
1838
|
if (result !== void 0) {
|
|
1755
1839
|
return result;
|
|
1756
1840
|
}
|
|
1757
|
-
|
|
1841
|
+
let newAssertion = new Assertion();
|
|
1758
1842
|
transferFlags(this, newAssertion);
|
|
1759
1843
|
return newAssertion;
|
|
1760
1844
|
}, "overwritingChainableMethodGetter");
|
|
1761
|
-
|
|
1845
|
+
let _method = chainableBehavior.method;
|
|
1762
1846
|
chainableBehavior.method = /* @__PURE__ */ __name(function overwritingChainableMethodWrapper() {
|
|
1763
|
-
|
|
1847
|
+
let result = method(_method).apply(this, arguments);
|
|
1764
1848
|
if (result !== void 0) {
|
|
1765
1849
|
return result;
|
|
1766
1850
|
}
|
|
1767
|
-
|
|
1851
|
+
let newAssertion = new Assertion();
|
|
1768
1852
|
transferFlags(this, newAssertion);
|
|
1769
1853
|
return newAssertion;
|
|
1770
1854
|
}, "overwritingChainableMethodWrapper");
|
|
@@ -1779,8 +1863,7 @@ __name(compareByInspect, "compareByInspect");
|
|
|
1779
1863
|
|
|
1780
1864
|
// lib/chai/utils/getOwnEnumerablePropertySymbols.js
|
|
1781
1865
|
function getOwnEnumerablePropertySymbols(obj) {
|
|
1782
|
-
if (typeof Object.getOwnPropertySymbols !== "function")
|
|
1783
|
-
return [];
|
|
1866
|
+
if (typeof Object.getOwnPropertySymbols !== "function") return [];
|
|
1784
1867
|
return Object.getOwnPropertySymbols(obj).filter(function(sym) {
|
|
1785
1868
|
return Object.getOwnPropertyDescriptor(obj, sym).enumerable;
|
|
1786
1869
|
});
|
|
@@ -1794,29 +1877,24 @@ function getOwnEnumerableProperties(obj) {
|
|
|
1794
1877
|
__name(getOwnEnumerableProperties, "getOwnEnumerableProperties");
|
|
1795
1878
|
|
|
1796
1879
|
// lib/chai/utils/isNaN.js
|
|
1797
|
-
|
|
1798
|
-
return value !== value;
|
|
1799
|
-
}
|
|
1800
|
-
__name(_isNaN, "_isNaN");
|
|
1801
|
-
var isNaN2 = Number.isNaN || _isNaN;
|
|
1880
|
+
var isNaN2 = Number.isNaN;
|
|
1802
1881
|
|
|
1803
1882
|
// lib/chai/utils/getOperator.js
|
|
1804
1883
|
function isObjectType(obj) {
|
|
1805
|
-
|
|
1806
|
-
|
|
1884
|
+
let objectType = type(obj);
|
|
1885
|
+
let objectTypes = ["Array", "Object", "Function"];
|
|
1807
1886
|
return objectTypes.indexOf(objectType) !== -1;
|
|
1808
1887
|
}
|
|
1809
1888
|
__name(isObjectType, "isObjectType");
|
|
1810
1889
|
function getOperator(obj, args) {
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1890
|
+
let operator = flag(obj, "operator");
|
|
1891
|
+
let negate = flag(obj, "negate");
|
|
1892
|
+
let expected = args[3];
|
|
1893
|
+
let msg = negate ? args[2] : args[1];
|
|
1815
1894
|
if (operator) {
|
|
1816
1895
|
return operator;
|
|
1817
1896
|
}
|
|
1818
|
-
if (typeof msg === "function")
|
|
1819
|
-
msg = msg();
|
|
1897
|
+
if (typeof msg === "function") msg = msg();
|
|
1820
1898
|
msg = msg || "";
|
|
1821
1899
|
if (!msg) {
|
|
1822
1900
|
return void 0;
|
|
@@ -1824,7 +1902,7 @@ function getOperator(obj, args) {
|
|
|
1824
1902
|
if (/\shave\s/.test(msg)) {
|
|
1825
1903
|
return void 0;
|
|
1826
1904
|
}
|
|
1827
|
-
|
|
1905
|
+
let isObject = isObjectType(expected);
|
|
1828
1906
|
if (/\snot\s/.test(msg)) {
|
|
1829
1907
|
return isObject ? "notDeepStrictEqual" : "notStrictEqual";
|
|
1830
1908
|
}
|
|
@@ -1893,16 +1971,20 @@ Assertion.addProperty("all", function() {
|
|
|
1893
1971
|
flag2(this, "any", false);
|
|
1894
1972
|
});
|
|
1895
1973
|
var functionTypes = {
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1974
|
+
function: [
|
|
1975
|
+
"function",
|
|
1976
|
+
"asyncfunction",
|
|
1977
|
+
"generatorfunction",
|
|
1978
|
+
"asyncgeneratorfunction"
|
|
1979
|
+
],
|
|
1980
|
+
asyncfunction: ["asyncfunction", "asyncgeneratorfunction"],
|
|
1981
|
+
generatorfunction: ["generatorfunction", "asyncgeneratorfunction"],
|
|
1982
|
+
asyncgeneratorfunction: ["asyncgeneratorfunction"]
|
|
1900
1983
|
};
|
|
1901
1984
|
function an(type3, msg) {
|
|
1902
|
-
if (msg)
|
|
1903
|
-
flag2(this, "message", msg);
|
|
1985
|
+
if (msg) flag2(this, "message", msg);
|
|
1904
1986
|
type3 = type3.toLowerCase();
|
|
1905
|
-
|
|
1987
|
+
let obj = flag2(this, "object"), article = ~["a", "e", "i", "o", "u"].indexOf(type3.charAt(0)) ? "an " : "a ";
|
|
1906
1988
|
const detectedType = type(obj).toLowerCase();
|
|
1907
1989
|
if (functionTypes["function"].includes(type3)) {
|
|
1908
1990
|
this.assert(
|
|
@@ -1930,11 +2012,10 @@ function includeChainingBehavior() {
|
|
|
1930
2012
|
}
|
|
1931
2013
|
__name(includeChainingBehavior, "includeChainingBehavior");
|
|
1932
2014
|
function include(val, msg) {
|
|
1933
|
-
if (msg)
|
|
1934
|
-
|
|
1935
|
-
var obj = flag2(this, "object"), objType = type(obj).toLowerCase(), flagMsg = flag2(this, "message"), negate = flag2(this, "negate"), ssfi = flag2(this, "ssfi"), isDeep = flag2(this, "deep"), descriptor = isDeep ? "deep " : "", isEql = isDeep ? flag2(this, "eql") : SameValueZero;
|
|
2015
|
+
if (msg) flag2(this, "message", msg);
|
|
2016
|
+
let obj = flag2(this, "object"), objType = type(obj).toLowerCase(), flagMsg = flag2(this, "message"), negate = flag2(this, "negate"), ssfi = flag2(this, "ssfi"), isDeep = flag2(this, "deep"), descriptor = isDeep ? "deep " : "", isEql = isDeep ? flag2(this, "eql") : SameValueZero;
|
|
1936
2017
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
1937
|
-
|
|
2018
|
+
let included = false;
|
|
1938
2019
|
switch (objType) {
|
|
1939
2020
|
case "string":
|
|
1940
2021
|
included = obj.indexOf(val) !== -1;
|
|
@@ -1972,7 +2053,7 @@ function include(val, msg) {
|
|
|
1972
2053
|
included = obj.indexOf(val) !== -1;
|
|
1973
2054
|
}
|
|
1974
2055
|
break;
|
|
1975
|
-
default:
|
|
2056
|
+
default: {
|
|
1976
2057
|
if (val !== Object(val)) {
|
|
1977
2058
|
throw new AssertionError(
|
|
1978
2059
|
flagMsg + "the given combination of arguments (" + objType + " and " + type(val).toLowerCase() + ") is invalid for this assertion. You can use an array, a map, an object, a set, a string, or a weakset instead of a " + type(val).toLowerCase(),
|
|
@@ -1980,9 +2061,11 @@ function include(val, msg) {
|
|
|
1980
2061
|
ssfi
|
|
1981
2062
|
);
|
|
1982
2063
|
}
|
|
1983
|
-
|
|
2064
|
+
let props = Object.keys(val);
|
|
2065
|
+
let firstErr = null;
|
|
2066
|
+
let numErrs = 0;
|
|
1984
2067
|
props.forEach(function(prop) {
|
|
1985
|
-
|
|
2068
|
+
let propAssertion = new Assertion(obj);
|
|
1986
2069
|
transferFlags(this, propAssertion, true);
|
|
1987
2070
|
flag2(propAssertion, "lockSsfi", true);
|
|
1988
2071
|
if (!negate || props.length === 1) {
|
|
@@ -1995,8 +2078,7 @@ function include(val, msg) {
|
|
|
1995
2078
|
if (!check_error_exports.compatibleConstructor(err, AssertionError)) {
|
|
1996
2079
|
throw err;
|
|
1997
2080
|
}
|
|
1998
|
-
if (firstErr === null)
|
|
1999
|
-
firstErr = err;
|
|
2081
|
+
if (firstErr === null) firstErr = err;
|
|
2000
2082
|
numErrs++;
|
|
2001
2083
|
}
|
|
2002
2084
|
}, this);
|
|
@@ -2004,6 +2086,7 @@ function include(val, msg) {
|
|
|
2004
2086
|
throw firstErr;
|
|
2005
2087
|
}
|
|
2006
2088
|
return;
|
|
2089
|
+
}
|
|
2007
2090
|
}
|
|
2008
2091
|
this.assert(
|
|
2009
2092
|
included,
|
|
@@ -2047,13 +2130,14 @@ Assertion.addProperty("callable", function() {
|
|
|
2047
2130
|
const msg = message ? `${message}: ` : "";
|
|
2048
2131
|
const negate = flag2(this, "negate");
|
|
2049
2132
|
const assertionMessage = negate ? `${msg}expected ${inspect2(val)} not to be a callable function` : `${msg}expected ${inspect2(val)} to be a callable function`;
|
|
2050
|
-
const isCallable = [
|
|
2133
|
+
const isCallable = [
|
|
2134
|
+
"Function",
|
|
2135
|
+
"AsyncFunction",
|
|
2136
|
+
"GeneratorFunction",
|
|
2137
|
+
"AsyncGeneratorFunction"
|
|
2138
|
+
].includes(type(val));
|
|
2051
2139
|
if (isCallable && negate || !isCallable && !negate) {
|
|
2052
|
-
throw new AssertionError(
|
|
2053
|
-
assertionMessage,
|
|
2054
|
-
void 0,
|
|
2055
|
-
ssfi
|
|
2056
|
-
);
|
|
2140
|
+
throw new AssertionError(assertionMessage, void 0, ssfi);
|
|
2057
2141
|
}
|
|
2058
2142
|
});
|
|
2059
2143
|
Assertion.addProperty("false", function() {
|
|
@@ -2086,7 +2170,7 @@ Assertion.addProperty("NaN", function() {
|
|
|
2086
2170
|
);
|
|
2087
2171
|
});
|
|
2088
2172
|
function assertExist() {
|
|
2089
|
-
|
|
2173
|
+
let val = flag2(this, "object");
|
|
2090
2174
|
this.assert(
|
|
2091
2175
|
val !== null && val !== void 0,
|
|
2092
2176
|
"expected #{this} to exist",
|
|
@@ -2097,7 +2181,7 @@ __name(assertExist, "assertExist");
|
|
|
2097
2181
|
Assertion.addProperty("exist", assertExist);
|
|
2098
2182
|
Assertion.addProperty("exists", assertExist);
|
|
2099
2183
|
Assertion.addProperty("empty", function() {
|
|
2100
|
-
|
|
2184
|
+
let val = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), itemsCount;
|
|
2101
2185
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2102
2186
|
switch (type(val).toLowerCase()) {
|
|
2103
2187
|
case "array":
|
|
@@ -2115,9 +2199,10 @@ Assertion.addProperty("empty", function() {
|
|
|
2115
2199
|
void 0,
|
|
2116
2200
|
ssfi
|
|
2117
2201
|
);
|
|
2118
|
-
case "function":
|
|
2119
|
-
|
|
2202
|
+
case "function": {
|
|
2203
|
+
const msg = flagMsg + ".empty was passed a function " + getName(val);
|
|
2120
2204
|
throw new AssertionError(msg.trim(), void 0, ssfi);
|
|
2205
|
+
}
|
|
2121
2206
|
default:
|
|
2122
2207
|
if (val !== Object(val)) {
|
|
2123
2208
|
throw new AssertionError(
|
|
@@ -2135,7 +2220,7 @@ Assertion.addProperty("empty", function() {
|
|
|
2135
2220
|
);
|
|
2136
2221
|
});
|
|
2137
2222
|
function checkArguments() {
|
|
2138
|
-
|
|
2223
|
+
let obj = flag2(this, "object"), type3 = type(obj);
|
|
2139
2224
|
this.assert(
|
|
2140
2225
|
"Arguments" === type3,
|
|
2141
2226
|
"expected #{this} to be arguments but got " + type3,
|
|
@@ -2146,11 +2231,10 @@ __name(checkArguments, "checkArguments");
|
|
|
2146
2231
|
Assertion.addProperty("arguments", checkArguments);
|
|
2147
2232
|
Assertion.addProperty("Arguments", checkArguments);
|
|
2148
2233
|
function assertEqual(val, msg) {
|
|
2149
|
-
if (msg)
|
|
2150
|
-
|
|
2151
|
-
var obj = flag2(this, "object");
|
|
2234
|
+
if (msg) flag2(this, "message", msg);
|
|
2235
|
+
let obj = flag2(this, "object");
|
|
2152
2236
|
if (flag2(this, "deep")) {
|
|
2153
|
-
|
|
2237
|
+
let prevLockSsfi = flag2(this, "lockSsfi");
|
|
2154
2238
|
flag2(this, "lockSsfi", true);
|
|
2155
2239
|
this.eql(val);
|
|
2156
2240
|
flag2(this, "lockSsfi", prevLockSsfi);
|
|
@@ -2170,9 +2254,8 @@ Assertion.addMethod("equal", assertEqual);
|
|
|
2170
2254
|
Assertion.addMethod("equals", assertEqual);
|
|
2171
2255
|
Assertion.addMethod("eq", assertEqual);
|
|
2172
2256
|
function assertEql(obj, msg) {
|
|
2173
|
-
if (msg)
|
|
2174
|
-
|
|
2175
|
-
var eql = flag2(this, "eql");
|
|
2257
|
+
if (msg) flag2(this, "message", msg);
|
|
2258
|
+
let eql = flag2(this, "eql");
|
|
2176
2259
|
this.assert(
|
|
2177
2260
|
eql(obj, flag2(this, "object")),
|
|
2178
2261
|
"expected #{this} to deeply equal #{exp}",
|
|
@@ -2186,22 +2269,33 @@ __name(assertEql, "assertEql");
|
|
|
2186
2269
|
Assertion.addMethod("eql", assertEql);
|
|
2187
2270
|
Assertion.addMethod("eqls", assertEql);
|
|
2188
2271
|
function assertAbove(n, msg) {
|
|
2189
|
-
if (msg)
|
|
2190
|
-
|
|
2191
|
-
var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase();
|
|
2272
|
+
if (msg) flag2(this, "message", msg);
|
|
2273
|
+
let obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase();
|
|
2192
2274
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2193
2275
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2194
2276
|
}
|
|
2195
|
-
if (!doLength &&
|
|
2196
|
-
throw new AssertionError(
|
|
2277
|
+
if (!doLength && objType === "date" && nType !== "date") {
|
|
2278
|
+
throw new AssertionError(
|
|
2279
|
+
msgPrefix + "the argument to above must be a date",
|
|
2280
|
+
void 0,
|
|
2281
|
+
ssfi
|
|
2282
|
+
);
|
|
2197
2283
|
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2198
|
-
throw new AssertionError(
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2284
|
+
throw new AssertionError(
|
|
2285
|
+
msgPrefix + "the argument to above must be a number",
|
|
2286
|
+
void 0,
|
|
2287
|
+
ssfi
|
|
2288
|
+
);
|
|
2289
|
+
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2290
|
+
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2291
|
+
throw new AssertionError(
|
|
2292
|
+
msgPrefix + "expected " + printObj + " to be a number or a date",
|
|
2293
|
+
void 0,
|
|
2294
|
+
ssfi
|
|
2295
|
+
);
|
|
2202
2296
|
}
|
|
2203
2297
|
if (doLength) {
|
|
2204
|
-
|
|
2298
|
+
let descriptor = "length", itemsCount;
|
|
2205
2299
|
if (objType === "map" || objType === "set") {
|
|
2206
2300
|
descriptor = "size";
|
|
2207
2301
|
itemsCount = obj.size;
|
|
@@ -2229,18 +2323,17 @@ Assertion.addMethod("above", assertAbove);
|
|
|
2229
2323
|
Assertion.addMethod("gt", assertAbove);
|
|
2230
2324
|
Assertion.addMethod("greaterThan", assertAbove);
|
|
2231
2325
|
function assertLeast(n, msg) {
|
|
2232
|
-
if (msg)
|
|
2233
|
-
|
|
2234
|
-
var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
|
|
2326
|
+
if (msg) flag2(this, "message", msg);
|
|
2327
|
+
let obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
|
|
2235
2328
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2236
2329
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2237
2330
|
}
|
|
2238
|
-
if (!doLength &&
|
|
2331
|
+
if (!doLength && objType === "date" && nType !== "date") {
|
|
2239
2332
|
errorMessage = msgPrefix + "the argument to least must be a date";
|
|
2240
2333
|
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2241
2334
|
errorMessage = msgPrefix + "the argument to least must be a number";
|
|
2242
|
-
} else if (!doLength &&
|
|
2243
|
-
|
|
2335
|
+
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2336
|
+
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2244
2337
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2245
2338
|
} else {
|
|
2246
2339
|
shouldThrow = false;
|
|
@@ -2249,7 +2342,7 @@ function assertLeast(n, msg) {
|
|
|
2249
2342
|
throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2250
2343
|
}
|
|
2251
2344
|
if (doLength) {
|
|
2252
|
-
|
|
2345
|
+
let descriptor = "length", itemsCount;
|
|
2253
2346
|
if (objType === "map" || objType === "set") {
|
|
2254
2347
|
descriptor = "size";
|
|
2255
2348
|
itemsCount = obj.size;
|
|
@@ -2277,18 +2370,17 @@ Assertion.addMethod("least", assertLeast);
|
|
|
2277
2370
|
Assertion.addMethod("gte", assertLeast);
|
|
2278
2371
|
Assertion.addMethod("greaterThanOrEqual", assertLeast);
|
|
2279
2372
|
function assertBelow(n, msg) {
|
|
2280
|
-
if (msg)
|
|
2281
|
-
|
|
2282
|
-
var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
|
|
2373
|
+
if (msg) flag2(this, "message", msg);
|
|
2374
|
+
let obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
|
|
2283
2375
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2284
2376
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2285
2377
|
}
|
|
2286
|
-
if (!doLength &&
|
|
2378
|
+
if (!doLength && objType === "date" && nType !== "date") {
|
|
2287
2379
|
errorMessage = msgPrefix + "the argument to below must be a date";
|
|
2288
2380
|
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2289
2381
|
errorMessage = msgPrefix + "the argument to below must be a number";
|
|
2290
|
-
} else if (!doLength &&
|
|
2291
|
-
|
|
2382
|
+
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2383
|
+
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2292
2384
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2293
2385
|
} else {
|
|
2294
2386
|
shouldThrow = false;
|
|
@@ -2297,7 +2389,7 @@ function assertBelow(n, msg) {
|
|
|
2297
2389
|
throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2298
2390
|
}
|
|
2299
2391
|
if (doLength) {
|
|
2300
|
-
|
|
2392
|
+
let descriptor = "length", itemsCount;
|
|
2301
2393
|
if (objType === "map" || objType === "set") {
|
|
2302
2394
|
descriptor = "size";
|
|
2303
2395
|
itemsCount = obj.size;
|
|
@@ -2325,18 +2417,17 @@ Assertion.addMethod("below", assertBelow);
|
|
|
2325
2417
|
Assertion.addMethod("lt", assertBelow);
|
|
2326
2418
|
Assertion.addMethod("lessThan", assertBelow);
|
|
2327
2419
|
function assertMost(n, msg) {
|
|
2328
|
-
if (msg)
|
|
2329
|
-
|
|
2330
|
-
var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
|
|
2420
|
+
if (msg) flag2(this, "message", msg);
|
|
2421
|
+
let obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
|
|
2331
2422
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2332
2423
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2333
2424
|
}
|
|
2334
|
-
if (!doLength &&
|
|
2425
|
+
if (!doLength && objType === "date" && nType !== "date") {
|
|
2335
2426
|
errorMessage = msgPrefix + "the argument to most must be a date";
|
|
2336
2427
|
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2337
2428
|
errorMessage = msgPrefix + "the argument to most must be a number";
|
|
2338
|
-
} else if (!doLength &&
|
|
2339
|
-
|
|
2429
|
+
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2430
|
+
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2340
2431
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2341
2432
|
} else {
|
|
2342
2433
|
shouldThrow = false;
|
|
@@ -2345,7 +2436,7 @@ function assertMost(n, msg) {
|
|
|
2345
2436
|
throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2346
2437
|
}
|
|
2347
2438
|
if (doLength) {
|
|
2348
|
-
|
|
2439
|
+
let descriptor = "length", itemsCount;
|
|
2349
2440
|
if (objType === "map" || objType === "set") {
|
|
2350
2441
|
descriptor = "size";
|
|
2351
2442
|
itemsCount = obj.size;
|
|
@@ -2373,18 +2464,17 @@ Assertion.addMethod("most", assertMost);
|
|
|
2373
2464
|
Assertion.addMethod("lte", assertMost);
|
|
2374
2465
|
Assertion.addMethod("lessThanOrEqual", assertMost);
|
|
2375
2466
|
Assertion.addMethod("within", function(start, finish, msg) {
|
|
2376
|
-
if (msg)
|
|
2377
|
-
|
|
2378
|
-
var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), startType = type(start).toLowerCase(), finishType = type(finish).toLowerCase(), errorMessage, shouldThrow = true, range = startType === "date" && finishType === "date" ? start.toISOString() + ".." + finish.toISOString() : start + ".." + finish;
|
|
2467
|
+
if (msg) flag2(this, "message", msg);
|
|
2468
|
+
let obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), startType = type(start).toLowerCase(), finishType = type(finish).toLowerCase(), errorMessage, shouldThrow = true, range = startType === "date" && finishType === "date" ? start.toISOString() + ".." + finish.toISOString() : start + ".." + finish;
|
|
2379
2469
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2380
2470
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2381
2471
|
}
|
|
2382
|
-
if (!doLength &&
|
|
2472
|
+
if (!doLength && objType === "date" && (startType !== "date" || finishType !== "date")) {
|
|
2383
2473
|
errorMessage = msgPrefix + "the arguments to within must be dates";
|
|
2384
2474
|
} else if ((!isNumeric(start) || !isNumeric(finish)) && (doLength || isNumeric(obj))) {
|
|
2385
2475
|
errorMessage = msgPrefix + "the arguments to within must be numbers";
|
|
2386
|
-
} else if (!doLength &&
|
|
2387
|
-
|
|
2476
|
+
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2477
|
+
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2388
2478
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2389
2479
|
} else {
|
|
2390
2480
|
shouldThrow = false;
|
|
@@ -2393,7 +2483,7 @@ Assertion.addMethod("within", function(start, finish, msg) {
|
|
|
2393
2483
|
throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2394
2484
|
}
|
|
2395
2485
|
if (doLength) {
|
|
2396
|
-
|
|
2486
|
+
let descriptor = "length", itemsCount;
|
|
2397
2487
|
if (objType === "map" || objType === "set") {
|
|
2398
2488
|
descriptor = "size";
|
|
2399
2489
|
itemsCount = obj.size;
|
|
@@ -2414,13 +2504,13 @@ Assertion.addMethod("within", function(start, finish, msg) {
|
|
|
2414
2504
|
}
|
|
2415
2505
|
});
|
|
2416
2506
|
function assertInstanceOf(constructor, msg) {
|
|
2417
|
-
if (msg)
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2507
|
+
if (msg) flag2(this, "message", msg);
|
|
2508
|
+
let target = flag2(this, "object");
|
|
2509
|
+
let ssfi = flag2(this, "ssfi");
|
|
2510
|
+
let flagMsg = flag2(this, "message");
|
|
2511
|
+
let isInstanceOf;
|
|
2422
2512
|
try {
|
|
2423
|
-
|
|
2513
|
+
isInstanceOf = target instanceof constructor;
|
|
2424
2514
|
} catch (err) {
|
|
2425
2515
|
if (err instanceof TypeError) {
|
|
2426
2516
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
@@ -2432,7 +2522,7 @@ function assertInstanceOf(constructor, msg) {
|
|
|
2432
2522
|
}
|
|
2433
2523
|
throw err;
|
|
2434
2524
|
}
|
|
2435
|
-
|
|
2525
|
+
let name = getName(constructor);
|
|
2436
2526
|
if (name == null) {
|
|
2437
2527
|
name = "an unnamed constructor";
|
|
2438
2528
|
}
|
|
@@ -2446,9 +2536,8 @@ __name(assertInstanceOf, "assertInstanceOf");
|
|
|
2446
2536
|
Assertion.addMethod("instanceof", assertInstanceOf);
|
|
2447
2537
|
Assertion.addMethod("instanceOf", assertInstanceOf);
|
|
2448
2538
|
function assertProperty(name, val, msg) {
|
|
2449
|
-
if (msg)
|
|
2450
|
-
|
|
2451
|
-
var isNested = flag2(this, "nested"), isOwn = flag2(this, "own"), flagMsg = flag2(this, "message"), obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), nameType = typeof name;
|
|
2539
|
+
if (msg) flag2(this, "message", msg);
|
|
2540
|
+
let isNested = flag2(this, "nested"), isOwn = flag2(this, "own"), flagMsg = flag2(this, "message"), obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), nameType = typeof name;
|
|
2452
2541
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2453
2542
|
if (isNested) {
|
|
2454
2543
|
if (nameType !== "string") {
|
|
@@ -2481,22 +2570,16 @@ function assertProperty(name, val, msg) {
|
|
|
2481
2570
|
ssfi
|
|
2482
2571
|
);
|
|
2483
2572
|
}
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
if (isDeep)
|
|
2487
|
-
|
|
2488
|
-
if (
|
|
2489
|
-
descriptor += "own ";
|
|
2490
|
-
if (isNested)
|
|
2491
|
-
descriptor += "nested ";
|
|
2573
|
+
let isDeep = flag2(this, "deep"), negate = flag2(this, "negate"), pathInfo = isNested ? getPathInfo(obj, name) : null, value = isNested ? pathInfo.value : obj[name], isEql = isDeep ? flag2(this, "eql") : (val1, val2) => val1 === val2;
|
|
2574
|
+
let descriptor = "";
|
|
2575
|
+
if (isDeep) descriptor += "deep ";
|
|
2576
|
+
if (isOwn) descriptor += "own ";
|
|
2577
|
+
if (isNested) descriptor += "nested ";
|
|
2492
2578
|
descriptor += "property ";
|
|
2493
|
-
|
|
2494
|
-
if (isOwn)
|
|
2495
|
-
|
|
2496
|
-
else
|
|
2497
|
-
hasProperty2 = pathInfo.exists;
|
|
2498
|
-
else
|
|
2499
|
-
hasProperty2 = hasProperty(obj, name);
|
|
2579
|
+
let hasProperty2;
|
|
2580
|
+
if (isOwn) hasProperty2 = Object.prototype.hasOwnProperty.call(obj, name);
|
|
2581
|
+
else if (isNested) hasProperty2 = pathInfo.exists;
|
|
2582
|
+
else hasProperty2 = hasProperty(obj, name);
|
|
2500
2583
|
if (!negate || arguments.length === 1) {
|
|
2501
2584
|
this.assert(
|
|
2502
2585
|
hasProperty2,
|
|
@@ -2517,7 +2600,7 @@ function assertProperty(name, val, msg) {
|
|
|
2517
2600
|
}
|
|
2518
2601
|
__name(assertProperty, "assertProperty");
|
|
2519
2602
|
Assertion.addMethod("property", assertProperty);
|
|
2520
|
-
function assertOwnProperty(
|
|
2603
|
+
function assertOwnProperty(_name, _value, _msg) {
|
|
2521
2604
|
flag2(this, "own", true);
|
|
2522
2605
|
assertProperty.apply(this, arguments);
|
|
2523
2606
|
}
|
|
@@ -2529,11 +2612,10 @@ function assertOwnPropertyDescriptor(name, descriptor, msg) {
|
|
|
2529
2612
|
msg = descriptor;
|
|
2530
2613
|
descriptor = null;
|
|
2531
2614
|
}
|
|
2532
|
-
if (msg)
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
var eql = flag2(this, "eql");
|
|
2615
|
+
if (msg) flag2(this, "message", msg);
|
|
2616
|
+
let obj = flag2(this, "object");
|
|
2617
|
+
let actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name);
|
|
2618
|
+
let eql = flag2(this, "eql");
|
|
2537
2619
|
if (actualDescriptor && descriptor) {
|
|
2538
2620
|
this.assert(
|
|
2539
2621
|
eql(descriptor, actualDescriptor),
|
|
@@ -2560,9 +2642,8 @@ function assertLengthChain() {
|
|
|
2560
2642
|
}
|
|
2561
2643
|
__name(assertLengthChain, "assertLengthChain");
|
|
2562
2644
|
function assertLength(n, msg) {
|
|
2563
|
-
if (msg)
|
|
2564
|
-
|
|
2565
|
-
var obj = flag2(this, "object"), objType = type(obj).toLowerCase(), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi"), descriptor = "length", itemsCount;
|
|
2645
|
+
if (msg) flag2(this, "message", msg);
|
|
2646
|
+
let obj = flag2(this, "object"), objType = type(obj).toLowerCase(), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi"), descriptor = "length", itemsCount;
|
|
2566
2647
|
switch (objType) {
|
|
2567
2648
|
case "map":
|
|
2568
2649
|
case "set":
|
|
@@ -2585,9 +2666,8 @@ __name(assertLength, "assertLength");
|
|
|
2585
2666
|
Assertion.addChainableMethod("length", assertLength, assertLengthChain);
|
|
2586
2667
|
Assertion.addChainableMethod("lengthOf", assertLength, assertLengthChain);
|
|
2587
2668
|
function assertMatch(re, msg) {
|
|
2588
|
-
if (msg)
|
|
2589
|
-
|
|
2590
|
-
var obj = flag2(this, "object");
|
|
2669
|
+
if (msg) flag2(this, "message", msg);
|
|
2670
|
+
let obj = flag2(this, "object");
|
|
2591
2671
|
this.assert(
|
|
2592
2672
|
re.exec(obj),
|
|
2593
2673
|
"expected #{this} to match " + re,
|
|
@@ -2598,9 +2678,8 @@ __name(assertMatch, "assertMatch");
|
|
|
2598
2678
|
Assertion.addMethod("match", assertMatch);
|
|
2599
2679
|
Assertion.addMethod("matches", assertMatch);
|
|
2600
2680
|
Assertion.addMethod("string", function(str, msg) {
|
|
2601
|
-
if (msg)
|
|
2602
|
-
|
|
2603
|
-
var obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
2681
|
+
if (msg) flag2(this, "message", msg);
|
|
2682
|
+
let obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
2604
2683
|
new Assertion(obj, flagMsg, ssfi, true).is.a("string");
|
|
2605
2684
|
this.assert(
|
|
2606
2685
|
~obj.indexOf(str),
|
|
@@ -2609,9 +2688,9 @@ Assertion.addMethod("string", function(str, msg) {
|
|
|
2609
2688
|
);
|
|
2610
2689
|
});
|
|
2611
2690
|
function assertKeys(keys) {
|
|
2612
|
-
|
|
2691
|
+
let obj = flag2(this, "object"), objType = type(obj), keysType = type(keys), ssfi = flag2(this, "ssfi"), isDeep = flag2(this, "deep"), str, deepStr = "", actual, ok = true, flagMsg = flag2(this, "message");
|
|
2613
2692
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2614
|
-
|
|
2693
|
+
let mixedArgsMsg = flagMsg + "when testing keys against an object or an array you must give a single Array|Object|String argument or multiple String arguments";
|
|
2615
2694
|
if (objType === "Map" || objType === "Set") {
|
|
2616
2695
|
deepStr = isDeep ? "deeply " : "";
|
|
2617
2696
|
actual = [];
|
|
@@ -2645,7 +2724,7 @@ function assertKeys(keys) {
|
|
|
2645
2724
|
if (!keys.length) {
|
|
2646
2725
|
throw new AssertionError(flagMsg + "keys required", void 0, ssfi);
|
|
2647
2726
|
}
|
|
2648
|
-
|
|
2727
|
+
let len = keys.length, any = flag2(this, "any"), all = flag2(this, "all"), expected = keys, isEql = isDeep ? flag2(this, "eql") : (val1, val2) => val1 === val2;
|
|
2649
2728
|
if (!any && !all) {
|
|
2650
2729
|
all = true;
|
|
2651
2730
|
}
|
|
@@ -2670,7 +2749,7 @@ function assertKeys(keys) {
|
|
|
2670
2749
|
keys = keys.map(function(key) {
|
|
2671
2750
|
return inspect2(key);
|
|
2672
2751
|
});
|
|
2673
|
-
|
|
2752
|
+
let last = keys.pop();
|
|
2674
2753
|
if (all) {
|
|
2675
2754
|
str = keys.join(", ") + ", and " + last;
|
|
2676
2755
|
}
|
|
@@ -2695,9 +2774,8 @@ __name(assertKeys, "assertKeys");
|
|
|
2695
2774
|
Assertion.addMethod("keys", assertKeys);
|
|
2696
2775
|
Assertion.addMethod("key", assertKeys);
|
|
2697
2776
|
function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
2698
|
-
if (msg)
|
|
2699
|
-
|
|
2700
|
-
var obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), negate = flag2(this, "negate") || false;
|
|
2777
|
+
if (msg) flag2(this, "message", msg);
|
|
2778
|
+
let obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), negate = flag2(this, "negate") || false;
|
|
2701
2779
|
new Assertion(obj, flagMsg, ssfi, true).is.a("function");
|
|
2702
2780
|
if (isRegExp2(errorLike) || typeof errorLike === "string") {
|
|
2703
2781
|
errMsgMatcher = errorLike;
|
|
@@ -2711,12 +2789,12 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
2711
2789
|
errorWasThrown = true;
|
|
2712
2790
|
caughtErr = err;
|
|
2713
2791
|
}
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2792
|
+
let everyArgIsUndefined = errorLike === void 0 && errMsgMatcher === void 0;
|
|
2793
|
+
let everyArgIsDefined = Boolean(errorLike && errMsgMatcher);
|
|
2794
|
+
let errorLikeFail = false;
|
|
2795
|
+
let errMsgMatcherFail = false;
|
|
2718
2796
|
if (everyArgIsUndefined || !everyArgIsUndefined && !negate) {
|
|
2719
|
-
|
|
2797
|
+
let errorLikeString = "an error";
|
|
2720
2798
|
if (errorLike instanceof Error) {
|
|
2721
2799
|
errorLikeString = "#{exp}";
|
|
2722
2800
|
} else if (errorLike) {
|
|
@@ -2743,7 +2821,10 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
2743
2821
|
}
|
|
2744
2822
|
if (errorLike && caughtErr) {
|
|
2745
2823
|
if (errorLike instanceof Error) {
|
|
2746
|
-
|
|
2824
|
+
let isCompatibleInstance = check_error_exports.compatibleInstance(
|
|
2825
|
+
caughtErr,
|
|
2826
|
+
errorLike
|
|
2827
|
+
);
|
|
2747
2828
|
if (isCompatibleInstance === negate) {
|
|
2748
2829
|
if (everyArgIsDefined && negate) {
|
|
2749
2830
|
errorLikeFail = true;
|
|
@@ -2758,7 +2839,10 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
2758
2839
|
}
|
|
2759
2840
|
}
|
|
2760
2841
|
}
|
|
2761
|
-
|
|
2842
|
+
let isCompatibleConstructor = check_error_exports.compatibleConstructor(
|
|
2843
|
+
caughtErr,
|
|
2844
|
+
errorLike
|
|
2845
|
+
);
|
|
2762
2846
|
if (isCompatibleConstructor === negate) {
|
|
2763
2847
|
if (everyArgIsDefined && negate) {
|
|
2764
2848
|
errorLikeFail = true;
|
|
@@ -2774,11 +2858,14 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
2774
2858
|
}
|
|
2775
2859
|
}
|
|
2776
2860
|
if (caughtErr && errMsgMatcher !== void 0 && errMsgMatcher !== null) {
|
|
2777
|
-
|
|
2861
|
+
let placeholder = "including";
|
|
2778
2862
|
if (isRegExp2(errMsgMatcher)) {
|
|
2779
2863
|
placeholder = "matching";
|
|
2780
2864
|
}
|
|
2781
|
-
|
|
2865
|
+
let isCompatibleMessage = check_error_exports.compatibleMessage(
|
|
2866
|
+
caughtErr,
|
|
2867
|
+
errMsgMatcher
|
|
2868
|
+
);
|
|
2782
2869
|
if (isCompatibleMessage === negate) {
|
|
2783
2870
|
if (everyArgIsDefined && negate) {
|
|
2784
2871
|
errMsgMatcherFail = true;
|
|
@@ -2809,9 +2896,8 @@ Assertion.addMethod("throw", assertThrows);
|
|
|
2809
2896
|
Assertion.addMethod("throws", assertThrows);
|
|
2810
2897
|
Assertion.addMethod("Throw", assertThrows);
|
|
2811
2898
|
function respondTo(method, msg) {
|
|
2812
|
-
if (msg)
|
|
2813
|
-
|
|
2814
|
-
var obj = flag2(this, "object"), itself = flag2(this, "itself"), context = "function" === typeof obj && !itself ? obj.prototype[method] : obj[method];
|
|
2899
|
+
if (msg) flag2(this, "message", msg);
|
|
2900
|
+
let obj = flag2(this, "object"), itself = flag2(this, "itself"), context = "function" === typeof obj && !itself ? obj.prototype[method] : obj[method];
|
|
2815
2901
|
this.assert(
|
|
2816
2902
|
"function" === typeof context,
|
|
2817
2903
|
"expected #{this} to respond to " + inspect2(method),
|
|
@@ -2825,10 +2911,9 @@ Assertion.addProperty("itself", function() {
|
|
|
2825
2911
|
flag2(this, "itself", true);
|
|
2826
2912
|
});
|
|
2827
2913
|
function satisfy(matcher, msg) {
|
|
2828
|
-
if (msg)
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
var result = matcher(obj);
|
|
2914
|
+
if (msg) flag2(this, "message", msg);
|
|
2915
|
+
let obj = flag2(this, "object");
|
|
2916
|
+
let result = matcher(obj);
|
|
2832
2917
|
this.assert(
|
|
2833
2918
|
result,
|
|
2834
2919
|
"expected #{this} to satisfy " + objDisplay(matcher),
|
|
@@ -2841,21 +2926,31 @@ __name(satisfy, "satisfy");
|
|
|
2841
2926
|
Assertion.addMethod("satisfy", satisfy);
|
|
2842
2927
|
Assertion.addMethod("satisfies", satisfy);
|
|
2843
2928
|
function closeTo(expected, delta, msg) {
|
|
2844
|
-
if (msg)
|
|
2845
|
-
|
|
2846
|
-
var obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
2929
|
+
if (msg) flag2(this, "message", msg);
|
|
2930
|
+
let obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
2847
2931
|
new Assertion(obj, flagMsg, ssfi, true).is.numeric;
|
|
2848
2932
|
let message = "A `delta` value is required for `closeTo`";
|
|
2849
|
-
if (delta == void 0)
|
|
2850
|
-
throw new AssertionError(
|
|
2933
|
+
if (delta == void 0) {
|
|
2934
|
+
throw new AssertionError(
|
|
2935
|
+
flagMsg ? `${flagMsg}: ${message}` : message,
|
|
2936
|
+
void 0,
|
|
2937
|
+
ssfi
|
|
2938
|
+
);
|
|
2939
|
+
}
|
|
2851
2940
|
new Assertion(delta, flagMsg, ssfi, true).is.numeric;
|
|
2852
2941
|
message = "A `expected` value is required for `closeTo`";
|
|
2853
|
-
if (expected == void 0)
|
|
2854
|
-
throw new AssertionError(
|
|
2942
|
+
if (expected == void 0) {
|
|
2943
|
+
throw new AssertionError(
|
|
2944
|
+
flagMsg ? `${flagMsg}: ${message}` : message,
|
|
2945
|
+
void 0,
|
|
2946
|
+
ssfi
|
|
2947
|
+
);
|
|
2948
|
+
}
|
|
2855
2949
|
new Assertion(expected, flagMsg, ssfi, true).is.numeric;
|
|
2856
2950
|
const abs = /* @__PURE__ */ __name((x) => x < 0n ? -x : x, "abs");
|
|
2951
|
+
const strip = /* @__PURE__ */ __name((number) => parseFloat(parseFloat(number).toPrecision(12)), "strip");
|
|
2857
2952
|
this.assert(
|
|
2858
|
-
abs(obj - expected) <= delta,
|
|
2953
|
+
strip(abs(obj - expected)) <= delta,
|
|
2859
2954
|
"expected #{this} to be close to " + expected + " +/- " + delta,
|
|
2860
2955
|
"expected #{this} not to be close to " + expected + " +/- " + delta
|
|
2861
2956
|
);
|
|
@@ -2867,40 +2962,33 @@ function isSubsetOf(_subset, _superset, cmp, contains, ordered) {
|
|
|
2867
2962
|
let superset = Array.from(_superset);
|
|
2868
2963
|
let subset = Array.from(_subset);
|
|
2869
2964
|
if (!contains) {
|
|
2870
|
-
if (subset.length !== superset.length)
|
|
2871
|
-
return false;
|
|
2965
|
+
if (subset.length !== superset.length) return false;
|
|
2872
2966
|
superset = superset.slice();
|
|
2873
2967
|
}
|
|
2874
2968
|
return subset.every(function(elem, idx) {
|
|
2875
|
-
if (ordered)
|
|
2876
|
-
return cmp ? cmp(elem, superset[idx]) : elem === superset[idx];
|
|
2969
|
+
if (ordered) return cmp ? cmp(elem, superset[idx]) : elem === superset[idx];
|
|
2877
2970
|
if (!cmp) {
|
|
2878
|
-
|
|
2879
|
-
if (matchIdx === -1)
|
|
2880
|
-
|
|
2881
|
-
if (!contains)
|
|
2882
|
-
superset.splice(matchIdx, 1);
|
|
2971
|
+
let matchIdx = superset.indexOf(elem);
|
|
2972
|
+
if (matchIdx === -1) return false;
|
|
2973
|
+
if (!contains) superset.splice(matchIdx, 1);
|
|
2883
2974
|
return true;
|
|
2884
2975
|
}
|
|
2885
|
-
return superset.some(function(elem2,
|
|
2886
|
-
if (!cmp(elem, elem2))
|
|
2887
|
-
|
|
2888
|
-
if (!contains)
|
|
2889
|
-
superset.splice(matchIdx2, 1);
|
|
2976
|
+
return superset.some(function(elem2, matchIdx) {
|
|
2977
|
+
if (!cmp(elem, elem2)) return false;
|
|
2978
|
+
if (!contains) superset.splice(matchIdx, 1);
|
|
2890
2979
|
return true;
|
|
2891
2980
|
});
|
|
2892
2981
|
});
|
|
2893
2982
|
}
|
|
2894
2983
|
__name(isSubsetOf, "isSubsetOf");
|
|
2895
2984
|
Assertion.addMethod("members", function(subset, msg) {
|
|
2896
|
-
if (msg)
|
|
2897
|
-
|
|
2898
|
-
var obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
2985
|
+
if (msg) flag2(this, "message", msg);
|
|
2986
|
+
let obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
2899
2987
|
new Assertion(obj, flagMsg, ssfi, true).to.be.iterable;
|
|
2900
2988
|
new Assertion(subset, flagMsg, ssfi, true).to.be.iterable;
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2989
|
+
let contains = flag2(this, "contains");
|
|
2990
|
+
let ordered = flag2(this, "ordered");
|
|
2991
|
+
let subject, failMsg, failNegateMsg;
|
|
2904
2992
|
if (contains) {
|
|
2905
2993
|
subject = ordered ? "an ordered superset" : "a superset";
|
|
2906
2994
|
failMsg = "expected #{this} to be " + subject + " of #{exp}";
|
|
@@ -2910,7 +2998,7 @@ Assertion.addMethod("members", function(subset, msg) {
|
|
|
2910
2998
|
failMsg = "expected #{this} to have the same " + subject + " as #{exp}";
|
|
2911
2999
|
failNegateMsg = "expected #{this} to not have the same " + subject + " as #{exp}";
|
|
2912
3000
|
}
|
|
2913
|
-
|
|
3001
|
+
let cmp = flag2(this, "deep") ? flag2(this, "eql") : void 0;
|
|
2914
3002
|
this.assert(
|
|
2915
3003
|
isSubsetOf(subset, obj, cmp, contains, ordered),
|
|
2916
3004
|
failMsg,
|
|
@@ -2921,9 +3009,8 @@ Assertion.addMethod("members", function(subset, msg) {
|
|
|
2921
3009
|
);
|
|
2922
3010
|
});
|
|
2923
3011
|
Assertion.addProperty("iterable", function(msg) {
|
|
2924
|
-
if (msg)
|
|
2925
|
-
|
|
2926
|
-
var obj = flag2(this, "object");
|
|
3012
|
+
if (msg) flag2(this, "message", msg);
|
|
3013
|
+
let obj = flag2(this, "object");
|
|
2927
3014
|
this.assert(
|
|
2928
3015
|
obj != void 0 && obj[Symbol.iterator],
|
|
2929
3016
|
"expected #{this} to be an iterable",
|
|
@@ -2932,9 +3019,8 @@ Assertion.addProperty("iterable", function(msg) {
|
|
|
2932
3019
|
);
|
|
2933
3020
|
});
|
|
2934
3021
|
function oneOf(list, msg) {
|
|
2935
|
-
if (msg)
|
|
2936
|
-
|
|
2937
|
-
var expected = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi"), contains = flag2(this, "contains"), isDeep = flag2(this, "deep"), eql = flag2(this, "eql");
|
|
3022
|
+
if (msg) flag2(this, "message", msg);
|
|
3023
|
+
let expected = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi"), contains = flag2(this, "contains"), isDeep = flag2(this, "deep"), eql = flag2(this, "eql");
|
|
2938
3024
|
new Assertion(list, flagMsg, ssfi, true).to.be.an("array");
|
|
2939
3025
|
if (contains) {
|
|
2940
3026
|
this.assert(
|
|
@@ -2971,11 +3057,10 @@ function oneOf(list, msg) {
|
|
|
2971
3057
|
__name(oneOf, "oneOf");
|
|
2972
3058
|
Assertion.addMethod("oneOf", oneOf);
|
|
2973
3059
|
function assertChanges(subject, prop, msg) {
|
|
2974
|
-
if (msg)
|
|
2975
|
-
|
|
2976
|
-
var fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
3060
|
+
if (msg) flag2(this, "message", msg);
|
|
3061
|
+
let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
2977
3062
|
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
2978
|
-
|
|
3063
|
+
let initial;
|
|
2979
3064
|
if (!prop) {
|
|
2980
3065
|
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
2981
3066
|
initial = subject();
|
|
@@ -2984,8 +3069,8 @@ function assertChanges(subject, prop, msg) {
|
|
|
2984
3069
|
initial = subject[prop];
|
|
2985
3070
|
}
|
|
2986
3071
|
fn();
|
|
2987
|
-
|
|
2988
|
-
|
|
3072
|
+
let final = prop === void 0 || prop === null ? subject() : subject[prop];
|
|
3073
|
+
let msgObj = prop === void 0 || prop === null ? initial : "." + prop;
|
|
2989
3074
|
flag2(this, "deltaMsgObj", msgObj);
|
|
2990
3075
|
flag2(this, "initialDeltaValue", initial);
|
|
2991
3076
|
flag2(this, "finalDeltaValue", final);
|
|
@@ -3001,11 +3086,10 @@ __name(assertChanges, "assertChanges");
|
|
|
3001
3086
|
Assertion.addMethod("change", assertChanges);
|
|
3002
3087
|
Assertion.addMethod("changes", assertChanges);
|
|
3003
3088
|
function assertIncreases(subject, prop, msg) {
|
|
3004
|
-
if (msg)
|
|
3005
|
-
|
|
3006
|
-
var fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
3089
|
+
if (msg) flag2(this, "message", msg);
|
|
3090
|
+
let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
3007
3091
|
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
3008
|
-
|
|
3092
|
+
let initial;
|
|
3009
3093
|
if (!prop) {
|
|
3010
3094
|
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
3011
3095
|
initial = subject();
|
|
@@ -3015,8 +3099,8 @@ function assertIncreases(subject, prop, msg) {
|
|
|
3015
3099
|
}
|
|
3016
3100
|
new Assertion(initial, flagMsg, ssfi, true).is.a("number");
|
|
3017
3101
|
fn();
|
|
3018
|
-
|
|
3019
|
-
|
|
3102
|
+
let final = prop === void 0 || prop === null ? subject() : subject[prop];
|
|
3103
|
+
let msgObj = prop === void 0 || prop === null ? initial : "." + prop;
|
|
3020
3104
|
flag2(this, "deltaMsgObj", msgObj);
|
|
3021
3105
|
flag2(this, "initialDeltaValue", initial);
|
|
3022
3106
|
flag2(this, "finalDeltaValue", final);
|
|
@@ -3032,11 +3116,10 @@ __name(assertIncreases, "assertIncreases");
|
|
|
3032
3116
|
Assertion.addMethod("increase", assertIncreases);
|
|
3033
3117
|
Assertion.addMethod("increases", assertIncreases);
|
|
3034
3118
|
function assertDecreases(subject, prop, msg) {
|
|
3035
|
-
if (msg)
|
|
3036
|
-
|
|
3037
|
-
var fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
3119
|
+
if (msg) flag2(this, "message", msg);
|
|
3120
|
+
let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
3038
3121
|
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
3039
|
-
|
|
3122
|
+
let initial;
|
|
3040
3123
|
if (!prop) {
|
|
3041
3124
|
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
3042
3125
|
initial = subject();
|
|
@@ -3046,8 +3129,8 @@ function assertDecreases(subject, prop, msg) {
|
|
|
3046
3129
|
}
|
|
3047
3130
|
new Assertion(initial, flagMsg, ssfi, true).is.a("number");
|
|
3048
3131
|
fn();
|
|
3049
|
-
|
|
3050
|
-
|
|
3132
|
+
let final = prop === void 0 || prop === null ? subject() : subject[prop];
|
|
3133
|
+
let msgObj = prop === void 0 || prop === null ? initial : "." + prop;
|
|
3051
3134
|
flag2(this, "deltaMsgObj", msgObj);
|
|
3052
3135
|
flag2(this, "initialDeltaValue", initial);
|
|
3053
3136
|
flag2(this, "finalDeltaValue", final);
|
|
@@ -3063,14 +3146,13 @@ __name(assertDecreases, "assertDecreases");
|
|
|
3063
3146
|
Assertion.addMethod("decrease", assertDecreases);
|
|
3064
3147
|
Assertion.addMethod("decreases", assertDecreases);
|
|
3065
3148
|
function assertDelta(delta, msg) {
|
|
3066
|
-
if (msg)
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
var expression;
|
|
3149
|
+
if (msg) flag2(this, "message", msg);
|
|
3150
|
+
let msgObj = flag2(this, "deltaMsgObj");
|
|
3151
|
+
let initial = flag2(this, "initialDeltaValue");
|
|
3152
|
+
let final = flag2(this, "finalDeltaValue");
|
|
3153
|
+
let behavior = flag2(this, "deltaBehavior");
|
|
3154
|
+
let realDelta = flag2(this, "realDelta");
|
|
3155
|
+
let expression;
|
|
3074
3156
|
if (behavior === "change") {
|
|
3075
3157
|
expression = Math.abs(final - initial) === Math.abs(delta);
|
|
3076
3158
|
} else {
|
|
@@ -3085,8 +3167,8 @@ function assertDelta(delta, msg) {
|
|
|
3085
3167
|
__name(assertDelta, "assertDelta");
|
|
3086
3168
|
Assertion.addMethod("by", assertDelta);
|
|
3087
3169
|
Assertion.addProperty("extensible", function() {
|
|
3088
|
-
|
|
3089
|
-
|
|
3170
|
+
let obj = flag2(this, "object");
|
|
3171
|
+
let isExtensible = obj === Object(obj) && Object.isExtensible(obj);
|
|
3090
3172
|
this.assert(
|
|
3091
3173
|
isExtensible,
|
|
3092
3174
|
"expected #{this} to be extensible",
|
|
@@ -3094,8 +3176,8 @@ Assertion.addProperty("extensible", function() {
|
|
|
3094
3176
|
);
|
|
3095
3177
|
});
|
|
3096
3178
|
Assertion.addProperty("sealed", function() {
|
|
3097
|
-
|
|
3098
|
-
|
|
3179
|
+
let obj = flag2(this, "object");
|
|
3180
|
+
let isSealed = obj === Object(obj) ? Object.isSealed(obj) : true;
|
|
3099
3181
|
this.assert(
|
|
3100
3182
|
isSealed,
|
|
3101
3183
|
"expected #{this} to be sealed",
|
|
@@ -3103,22 +3185,77 @@ Assertion.addProperty("sealed", function() {
|
|
|
3103
3185
|
);
|
|
3104
3186
|
});
|
|
3105
3187
|
Assertion.addProperty("frozen", function() {
|
|
3106
|
-
|
|
3107
|
-
|
|
3188
|
+
let obj = flag2(this, "object");
|
|
3189
|
+
let isFrozen = obj === Object(obj) ? Object.isFrozen(obj) : true;
|
|
3108
3190
|
this.assert(
|
|
3109
3191
|
isFrozen,
|
|
3110
3192
|
"expected #{this} to be frozen",
|
|
3111
3193
|
"expected #{this} to not be frozen"
|
|
3112
3194
|
);
|
|
3113
3195
|
});
|
|
3114
|
-
Assertion.addProperty("finite", function(
|
|
3115
|
-
|
|
3196
|
+
Assertion.addProperty("finite", function(_msg) {
|
|
3197
|
+
let obj = flag2(this, "object");
|
|
3116
3198
|
this.assert(
|
|
3117
3199
|
typeof obj === "number" && isFinite(obj),
|
|
3118
3200
|
"expected #{this} to be a finite number",
|
|
3119
3201
|
"expected #{this} to not be a finite number"
|
|
3120
3202
|
);
|
|
3121
3203
|
});
|
|
3204
|
+
function compareSubset(expected, actual) {
|
|
3205
|
+
if (expected === actual) {
|
|
3206
|
+
return true;
|
|
3207
|
+
}
|
|
3208
|
+
if (typeof actual !== typeof expected) {
|
|
3209
|
+
return false;
|
|
3210
|
+
}
|
|
3211
|
+
if (typeof expected !== "object" || expected === null) {
|
|
3212
|
+
return expected === actual;
|
|
3213
|
+
}
|
|
3214
|
+
if (!actual) {
|
|
3215
|
+
return false;
|
|
3216
|
+
}
|
|
3217
|
+
if (Array.isArray(expected)) {
|
|
3218
|
+
if (!Array.isArray(actual)) {
|
|
3219
|
+
return false;
|
|
3220
|
+
}
|
|
3221
|
+
return expected.every(function(exp) {
|
|
3222
|
+
return actual.some(function(act) {
|
|
3223
|
+
return compareSubset(exp, act);
|
|
3224
|
+
});
|
|
3225
|
+
});
|
|
3226
|
+
}
|
|
3227
|
+
if (expected instanceof Date) {
|
|
3228
|
+
if (actual instanceof Date) {
|
|
3229
|
+
return expected.getTime() === actual.getTime();
|
|
3230
|
+
} else {
|
|
3231
|
+
return false;
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3234
|
+
return Object.keys(expected).every(function(key) {
|
|
3235
|
+
let expectedValue = expected[key];
|
|
3236
|
+
let actualValue = actual[key];
|
|
3237
|
+
if (typeof expectedValue === "object" && expectedValue !== null && actualValue !== null) {
|
|
3238
|
+
return compareSubset(expectedValue, actualValue);
|
|
3239
|
+
}
|
|
3240
|
+
if (typeof expectedValue === "function") {
|
|
3241
|
+
return expectedValue(actualValue);
|
|
3242
|
+
}
|
|
3243
|
+
return actualValue === expectedValue;
|
|
3244
|
+
});
|
|
3245
|
+
}
|
|
3246
|
+
__name(compareSubset, "compareSubset");
|
|
3247
|
+
Assertion.addMethod("containSubset", function(expected) {
|
|
3248
|
+
const actual = flag(this, "object");
|
|
3249
|
+
const showDiff = config.showDiff;
|
|
3250
|
+
this.assert(
|
|
3251
|
+
compareSubset(expected, actual),
|
|
3252
|
+
"expected #{act} to contain subset #{exp}",
|
|
3253
|
+
"expected #{act} to not contain subset #{exp}",
|
|
3254
|
+
expected,
|
|
3255
|
+
actual,
|
|
3256
|
+
showDiff
|
|
3257
|
+
);
|
|
3258
|
+
});
|
|
3122
3259
|
|
|
3123
3260
|
// lib/chai/interface/expect.js
|
|
3124
3261
|
function expect(val, message) {
|
|
@@ -3131,11 +3268,15 @@ expect.fail = function(actual, expected, message, operator) {
|
|
|
3131
3268
|
actual = void 0;
|
|
3132
3269
|
}
|
|
3133
3270
|
message = message || "expect.fail()";
|
|
3134
|
-
throw new AssertionError(
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3271
|
+
throw new AssertionError(
|
|
3272
|
+
message,
|
|
3273
|
+
{
|
|
3274
|
+
actual,
|
|
3275
|
+
expected,
|
|
3276
|
+
operator
|
|
3277
|
+
},
|
|
3278
|
+
expect.fail
|
|
3279
|
+
);
|
|
3139
3280
|
};
|
|
3140
3281
|
|
|
3141
3282
|
// lib/chai/interface/should.js
|
|
@@ -3166,18 +3307,22 @@ function loadShould() {
|
|
|
3166
3307
|
get: shouldGetter,
|
|
3167
3308
|
configurable: true
|
|
3168
3309
|
});
|
|
3169
|
-
|
|
3310
|
+
let should2 = {};
|
|
3170
3311
|
should2.fail = function(actual, expected, message, operator) {
|
|
3171
3312
|
if (arguments.length < 2) {
|
|
3172
3313
|
message = actual;
|
|
3173
3314
|
actual = void 0;
|
|
3174
3315
|
}
|
|
3175
3316
|
message = message || "should.fail()";
|
|
3176
|
-
throw new AssertionError(
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3317
|
+
throw new AssertionError(
|
|
3318
|
+
message,
|
|
3319
|
+
{
|
|
3320
|
+
actual,
|
|
3321
|
+
expected,
|
|
3322
|
+
operator
|
|
3323
|
+
},
|
|
3324
|
+
should2.fail
|
|
3325
|
+
);
|
|
3181
3326
|
};
|
|
3182
3327
|
should2.equal = function(actual, expected, message) {
|
|
3183
3328
|
new Assertion(actual, message).to.equal(expected);
|
|
@@ -3208,12 +3353,8 @@ var Should = loadShould;
|
|
|
3208
3353
|
|
|
3209
3354
|
// lib/chai/interface/assert.js
|
|
3210
3355
|
function assert(express, errmsg) {
|
|
3211
|
-
|
|
3212
|
-
test2.assert(
|
|
3213
|
-
express,
|
|
3214
|
-
errmsg,
|
|
3215
|
-
"[ negation message unavailable ]"
|
|
3216
|
-
);
|
|
3356
|
+
let test2 = new Assertion(null, null, assert, true);
|
|
3357
|
+
test2.assert(express, errmsg, "[ negation message unavailable ]");
|
|
3217
3358
|
}
|
|
3218
3359
|
__name(assert, "assert");
|
|
3219
3360
|
assert.fail = function(actual, expected, message, operator) {
|
|
@@ -3222,11 +3363,15 @@ assert.fail = function(actual, expected, message, operator) {
|
|
|
3222
3363
|
actual = void 0;
|
|
3223
3364
|
}
|
|
3224
3365
|
message = message || "assert.fail()";
|
|
3225
|
-
throw new AssertionError(
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3366
|
+
throw new AssertionError(
|
|
3367
|
+
message,
|
|
3368
|
+
{
|
|
3369
|
+
actual,
|
|
3370
|
+
expected,
|
|
3371
|
+
operator
|
|
3372
|
+
},
|
|
3373
|
+
assert.fail
|
|
3374
|
+
);
|
|
3230
3375
|
};
|
|
3231
3376
|
assert.isOk = function(val, msg) {
|
|
3232
3377
|
new Assertion(val, msg, assert.isOk, true).is.ok;
|
|
@@ -3235,7 +3380,7 @@ assert.isNotOk = function(val, msg) {
|
|
|
3235
3380
|
new Assertion(val, msg, assert.isNotOk, true).is.not.ok;
|
|
3236
3381
|
};
|
|
3237
3382
|
assert.equal = function(act, exp, msg) {
|
|
3238
|
-
|
|
3383
|
+
let test2 = new Assertion(act, msg, assert.equal, true);
|
|
3239
3384
|
test2.assert(
|
|
3240
3385
|
exp == flag(test2, "object"),
|
|
3241
3386
|
"expected #{this} to equal #{exp}",
|
|
@@ -3246,7 +3391,7 @@ assert.equal = function(act, exp, msg) {
|
|
|
3246
3391
|
);
|
|
3247
3392
|
};
|
|
3248
3393
|
assert.notEqual = function(act, exp, msg) {
|
|
3249
|
-
|
|
3394
|
+
let test2 = new Assertion(act, msg, assert.notEqual, true);
|
|
3250
3395
|
test2.assert(
|
|
3251
3396
|
exp != flag(test2, "object"),
|
|
3252
3397
|
"expected #{this} to not equal #{exp}",
|
|
@@ -3371,7 +3516,9 @@ assert.instanceOf = function(val, type3, msg) {
|
|
|
3371
3516
|
new Assertion(val, msg, assert.instanceOf, true).to.be.instanceOf(type3);
|
|
3372
3517
|
};
|
|
3373
3518
|
assert.notInstanceOf = function(val, type3, msg) {
|
|
3374
|
-
new Assertion(val, msg, assert.notInstanceOf, true).to.not.be.instanceOf(
|
|
3519
|
+
new Assertion(val, msg, assert.notInstanceOf, true).to.not.be.instanceOf(
|
|
3520
|
+
type3
|
|
3521
|
+
);
|
|
3375
3522
|
};
|
|
3376
3523
|
assert.include = function(exp, inc, msg) {
|
|
3377
3524
|
new Assertion(exp, msg, assert.include, true).include(inc);
|
|
@@ -3389,13 +3536,22 @@ assert.nestedInclude = function(exp, inc, msg) {
|
|
|
3389
3536
|
new Assertion(exp, msg, assert.nestedInclude, true).nested.include(inc);
|
|
3390
3537
|
};
|
|
3391
3538
|
assert.notNestedInclude = function(exp, inc, msg) {
|
|
3392
|
-
new Assertion(exp, msg, assert.notNestedInclude, true).not.nested.include(
|
|
3539
|
+
new Assertion(exp, msg, assert.notNestedInclude, true).not.nested.include(
|
|
3540
|
+
inc
|
|
3541
|
+
);
|
|
3393
3542
|
};
|
|
3394
3543
|
assert.deepNestedInclude = function(exp, inc, msg) {
|
|
3395
|
-
new Assertion(exp, msg, assert.deepNestedInclude, true).deep.nested.include(
|
|
3544
|
+
new Assertion(exp, msg, assert.deepNestedInclude, true).deep.nested.include(
|
|
3545
|
+
inc
|
|
3546
|
+
);
|
|
3396
3547
|
};
|
|
3397
3548
|
assert.notDeepNestedInclude = function(exp, inc, msg) {
|
|
3398
|
-
new Assertion(
|
|
3549
|
+
new Assertion(
|
|
3550
|
+
exp,
|
|
3551
|
+
msg,
|
|
3552
|
+
assert.notDeepNestedInclude,
|
|
3553
|
+
true
|
|
3554
|
+
).not.deep.nested.include(inc);
|
|
3399
3555
|
};
|
|
3400
3556
|
assert.ownInclude = function(exp, inc, msg) {
|
|
3401
3557
|
new Assertion(exp, msg, assert.ownInclude, true).own.include(inc);
|
|
@@ -3407,7 +3563,9 @@ assert.deepOwnInclude = function(exp, inc, msg) {
|
|
|
3407
3563
|
new Assertion(exp, msg, assert.deepOwnInclude, true).deep.own.include(inc);
|
|
3408
3564
|
};
|
|
3409
3565
|
assert.notDeepOwnInclude = function(exp, inc, msg) {
|
|
3410
|
-
new Assertion(exp, msg, assert.notDeepOwnInclude, true).not.deep.own.include(
|
|
3566
|
+
new Assertion(exp, msg, assert.notDeepOwnInclude, true).not.deep.own.include(
|
|
3567
|
+
inc
|
|
3568
|
+
);
|
|
3411
3569
|
};
|
|
3412
3570
|
assert.match = function(exp, re, msg) {
|
|
3413
3571
|
new Assertion(exp, msg, assert.match, true).to.match(re);
|
|
@@ -3425,49 +3583,107 @@ assert.propertyVal = function(obj, prop, val, msg) {
|
|
|
3425
3583
|
new Assertion(obj, msg, assert.propertyVal, true).to.have.property(prop, val);
|
|
3426
3584
|
};
|
|
3427
3585
|
assert.notPropertyVal = function(obj, prop, val, msg) {
|
|
3428
|
-
new Assertion(obj, msg, assert.notPropertyVal, true).to.not.have.property(
|
|
3586
|
+
new Assertion(obj, msg, assert.notPropertyVal, true).to.not.have.property(
|
|
3587
|
+
prop,
|
|
3588
|
+
val
|
|
3589
|
+
);
|
|
3429
3590
|
};
|
|
3430
3591
|
assert.deepPropertyVal = function(obj, prop, val, msg) {
|
|
3431
|
-
new Assertion(obj, msg, assert.deepPropertyVal, true).to.have.deep.property(
|
|
3592
|
+
new Assertion(obj, msg, assert.deepPropertyVal, true).to.have.deep.property(
|
|
3593
|
+
prop,
|
|
3594
|
+
val
|
|
3595
|
+
);
|
|
3432
3596
|
};
|
|
3433
3597
|
assert.notDeepPropertyVal = function(obj, prop, val, msg) {
|
|
3434
|
-
new Assertion(
|
|
3598
|
+
new Assertion(
|
|
3599
|
+
obj,
|
|
3600
|
+
msg,
|
|
3601
|
+
assert.notDeepPropertyVal,
|
|
3602
|
+
true
|
|
3603
|
+
).to.not.have.deep.property(prop, val);
|
|
3435
3604
|
};
|
|
3436
3605
|
assert.ownProperty = function(obj, prop, msg) {
|
|
3437
3606
|
new Assertion(obj, msg, assert.ownProperty, true).to.have.own.property(prop);
|
|
3438
3607
|
};
|
|
3439
3608
|
assert.notOwnProperty = function(obj, prop, msg) {
|
|
3440
|
-
new Assertion(obj, msg, assert.notOwnProperty, true).to.not.have.own.property(
|
|
3609
|
+
new Assertion(obj, msg, assert.notOwnProperty, true).to.not.have.own.property(
|
|
3610
|
+
prop
|
|
3611
|
+
);
|
|
3441
3612
|
};
|
|
3442
3613
|
assert.ownPropertyVal = function(obj, prop, value, msg) {
|
|
3443
|
-
new Assertion(obj, msg, assert.ownPropertyVal, true).to.have.own.property(
|
|
3614
|
+
new Assertion(obj, msg, assert.ownPropertyVal, true).to.have.own.property(
|
|
3615
|
+
prop,
|
|
3616
|
+
value
|
|
3617
|
+
);
|
|
3444
3618
|
};
|
|
3445
3619
|
assert.notOwnPropertyVal = function(obj, prop, value, msg) {
|
|
3446
|
-
new Assertion(
|
|
3620
|
+
new Assertion(
|
|
3621
|
+
obj,
|
|
3622
|
+
msg,
|
|
3623
|
+
assert.notOwnPropertyVal,
|
|
3624
|
+
true
|
|
3625
|
+
).to.not.have.own.property(prop, value);
|
|
3447
3626
|
};
|
|
3448
3627
|
assert.deepOwnPropertyVal = function(obj, prop, value, msg) {
|
|
3449
|
-
new Assertion(
|
|
3628
|
+
new Assertion(
|
|
3629
|
+
obj,
|
|
3630
|
+
msg,
|
|
3631
|
+
assert.deepOwnPropertyVal,
|
|
3632
|
+
true
|
|
3633
|
+
).to.have.deep.own.property(prop, value);
|
|
3450
3634
|
};
|
|
3451
3635
|
assert.notDeepOwnPropertyVal = function(obj, prop, value, msg) {
|
|
3452
|
-
new Assertion(
|
|
3636
|
+
new Assertion(
|
|
3637
|
+
obj,
|
|
3638
|
+
msg,
|
|
3639
|
+
assert.notDeepOwnPropertyVal,
|
|
3640
|
+
true
|
|
3641
|
+
).to.not.have.deep.own.property(prop, value);
|
|
3453
3642
|
};
|
|
3454
3643
|
assert.nestedProperty = function(obj, prop, msg) {
|
|
3455
|
-
new Assertion(obj, msg, assert.nestedProperty, true).to.have.nested.property(
|
|
3644
|
+
new Assertion(obj, msg, assert.nestedProperty, true).to.have.nested.property(
|
|
3645
|
+
prop
|
|
3646
|
+
);
|
|
3456
3647
|
};
|
|
3457
3648
|
assert.notNestedProperty = function(obj, prop, msg) {
|
|
3458
|
-
new Assertion(
|
|
3649
|
+
new Assertion(
|
|
3650
|
+
obj,
|
|
3651
|
+
msg,
|
|
3652
|
+
assert.notNestedProperty,
|
|
3653
|
+
true
|
|
3654
|
+
).to.not.have.nested.property(prop);
|
|
3459
3655
|
};
|
|
3460
3656
|
assert.nestedPropertyVal = function(obj, prop, val, msg) {
|
|
3461
|
-
new Assertion(
|
|
3657
|
+
new Assertion(
|
|
3658
|
+
obj,
|
|
3659
|
+
msg,
|
|
3660
|
+
assert.nestedPropertyVal,
|
|
3661
|
+
true
|
|
3662
|
+
).to.have.nested.property(prop, val);
|
|
3462
3663
|
};
|
|
3463
3664
|
assert.notNestedPropertyVal = function(obj, prop, val, msg) {
|
|
3464
|
-
new Assertion(
|
|
3665
|
+
new Assertion(
|
|
3666
|
+
obj,
|
|
3667
|
+
msg,
|
|
3668
|
+
assert.notNestedPropertyVal,
|
|
3669
|
+
true
|
|
3670
|
+
).to.not.have.nested.property(prop, val);
|
|
3465
3671
|
};
|
|
3466
3672
|
assert.deepNestedPropertyVal = function(obj, prop, val, msg) {
|
|
3467
|
-
new Assertion(
|
|
3673
|
+
new Assertion(
|
|
3674
|
+
obj,
|
|
3675
|
+
msg,
|
|
3676
|
+
assert.deepNestedPropertyVal,
|
|
3677
|
+
true
|
|
3678
|
+
).to.have.deep.nested.property(prop, val);
|
|
3468
3679
|
};
|
|
3469
3680
|
assert.notDeepNestedPropertyVal = function(obj, prop, val, msg) {
|
|
3470
|
-
new Assertion(
|
|
3681
|
+
new Assertion(
|
|
3682
|
+
obj,
|
|
3683
|
+
msg,
|
|
3684
|
+
assert.notDeepNestedPropertyVal,
|
|
3685
|
+
true
|
|
3686
|
+
).to.not.have.deep.nested.property(prop, val);
|
|
3471
3687
|
};
|
|
3472
3688
|
assert.lengthOf = function(exp, len, msg) {
|
|
3473
3689
|
new Assertion(exp, msg, assert.lengthOf, true).to.have.lengthOf(len);
|
|
@@ -3479,35 +3695,63 @@ assert.hasAllKeys = function(obj, keys, msg) {
|
|
|
3479
3695
|
new Assertion(obj, msg, assert.hasAllKeys, true).to.have.all.keys(keys);
|
|
3480
3696
|
};
|
|
3481
3697
|
assert.containsAllKeys = function(obj, keys, msg) {
|
|
3482
|
-
new Assertion(obj, msg, assert.containsAllKeys, true).to.contain.all.keys(
|
|
3698
|
+
new Assertion(obj, msg, assert.containsAllKeys, true).to.contain.all.keys(
|
|
3699
|
+
keys
|
|
3700
|
+
);
|
|
3483
3701
|
};
|
|
3484
3702
|
assert.doesNotHaveAnyKeys = function(obj, keys, msg) {
|
|
3485
|
-
new Assertion(obj, msg, assert.doesNotHaveAnyKeys, true).to.not.have.any.keys(
|
|
3703
|
+
new Assertion(obj, msg, assert.doesNotHaveAnyKeys, true).to.not.have.any.keys(
|
|
3704
|
+
keys
|
|
3705
|
+
);
|
|
3486
3706
|
};
|
|
3487
3707
|
assert.doesNotHaveAllKeys = function(obj, keys, msg) {
|
|
3488
|
-
new Assertion(obj, msg, assert.doesNotHaveAllKeys, true).to.not.have.all.keys(
|
|
3708
|
+
new Assertion(obj, msg, assert.doesNotHaveAllKeys, true).to.not.have.all.keys(
|
|
3709
|
+
keys
|
|
3710
|
+
);
|
|
3489
3711
|
};
|
|
3490
3712
|
assert.hasAnyDeepKeys = function(obj, keys, msg) {
|
|
3491
|
-
new Assertion(obj, msg, assert.hasAnyDeepKeys, true).to.have.any.deep.keys(
|
|
3713
|
+
new Assertion(obj, msg, assert.hasAnyDeepKeys, true).to.have.any.deep.keys(
|
|
3714
|
+
keys
|
|
3715
|
+
);
|
|
3492
3716
|
};
|
|
3493
3717
|
assert.hasAllDeepKeys = function(obj, keys, msg) {
|
|
3494
|
-
new Assertion(obj, msg, assert.hasAllDeepKeys, true).to.have.all.deep.keys(
|
|
3718
|
+
new Assertion(obj, msg, assert.hasAllDeepKeys, true).to.have.all.deep.keys(
|
|
3719
|
+
keys
|
|
3720
|
+
);
|
|
3495
3721
|
};
|
|
3496
3722
|
assert.containsAllDeepKeys = function(obj, keys, msg) {
|
|
3497
|
-
new Assertion(
|
|
3723
|
+
new Assertion(
|
|
3724
|
+
obj,
|
|
3725
|
+
msg,
|
|
3726
|
+
assert.containsAllDeepKeys,
|
|
3727
|
+
true
|
|
3728
|
+
).to.contain.all.deep.keys(keys);
|
|
3498
3729
|
};
|
|
3499
3730
|
assert.doesNotHaveAnyDeepKeys = function(obj, keys, msg) {
|
|
3500
|
-
new Assertion(
|
|
3731
|
+
new Assertion(
|
|
3732
|
+
obj,
|
|
3733
|
+
msg,
|
|
3734
|
+
assert.doesNotHaveAnyDeepKeys,
|
|
3735
|
+
true
|
|
3736
|
+
).to.not.have.any.deep.keys(keys);
|
|
3501
3737
|
};
|
|
3502
3738
|
assert.doesNotHaveAllDeepKeys = function(obj, keys, msg) {
|
|
3503
|
-
new Assertion(
|
|
3739
|
+
new Assertion(
|
|
3740
|
+
obj,
|
|
3741
|
+
msg,
|
|
3742
|
+
assert.doesNotHaveAllDeepKeys,
|
|
3743
|
+
true
|
|
3744
|
+
).to.not.have.all.deep.keys(keys);
|
|
3504
3745
|
};
|
|
3505
3746
|
assert.throws = function(fn, errorLike, errMsgMatcher, msg) {
|
|
3506
3747
|
if ("string" === typeof errorLike || errorLike instanceof RegExp) {
|
|
3507
3748
|
errMsgMatcher = errorLike;
|
|
3508
3749
|
errorLike = null;
|
|
3509
3750
|
}
|
|
3510
|
-
|
|
3751
|
+
let assertErr = new Assertion(fn, msg, assert.throws, true).to.throw(
|
|
3752
|
+
errorLike,
|
|
3753
|
+
errMsgMatcher
|
|
3754
|
+
);
|
|
3511
3755
|
return flag(assertErr, "object");
|
|
3512
3756
|
};
|
|
3513
3757
|
assert.doesNotThrow = function(fn, errorLike, errMsgMatcher, message) {
|
|
@@ -3515,10 +3759,13 @@ assert.doesNotThrow = function(fn, errorLike, errMsgMatcher, message) {
|
|
|
3515
3759
|
errMsgMatcher = errorLike;
|
|
3516
3760
|
errorLike = null;
|
|
3517
3761
|
}
|
|
3518
|
-
new Assertion(fn, message, assert.doesNotThrow, true).to.not.throw(
|
|
3762
|
+
new Assertion(fn, message, assert.doesNotThrow, true).to.not.throw(
|
|
3763
|
+
errorLike,
|
|
3764
|
+
errMsgMatcher
|
|
3765
|
+
);
|
|
3519
3766
|
};
|
|
3520
3767
|
assert.operator = function(val, operator, val2, msg) {
|
|
3521
|
-
|
|
3768
|
+
let ok;
|
|
3522
3769
|
switch (operator) {
|
|
3523
3770
|
case "==":
|
|
3524
3771
|
ok = val == val2;
|
|
@@ -3552,7 +3799,7 @@ assert.operator = function(val, operator, val2, msg) {
|
|
|
3552
3799
|
assert.operator
|
|
3553
3800
|
);
|
|
3554
3801
|
}
|
|
3555
|
-
|
|
3802
|
+
let test2 = new Assertion(ok, msg, assert.operator, true);
|
|
3556
3803
|
test2.assert(
|
|
3557
3804
|
true === flag(test2, "object"),
|
|
3558
3805
|
"expected " + inspect2(val) + " to be " + operator + " " + inspect2(val2),
|
|
@@ -3563,55 +3810,130 @@ assert.closeTo = function(act, exp, delta, msg) {
|
|
|
3563
3810
|
new Assertion(act, msg, assert.closeTo, true).to.be.closeTo(exp, delta);
|
|
3564
3811
|
};
|
|
3565
3812
|
assert.approximately = function(act, exp, delta, msg) {
|
|
3566
|
-
new Assertion(act, msg, assert.approximately, true).to.be.approximately(
|
|
3813
|
+
new Assertion(act, msg, assert.approximately, true).to.be.approximately(
|
|
3814
|
+
exp,
|
|
3815
|
+
delta
|
|
3816
|
+
);
|
|
3567
3817
|
};
|
|
3568
3818
|
assert.sameMembers = function(set1, set2, msg) {
|
|
3569
3819
|
new Assertion(set1, msg, assert.sameMembers, true).to.have.same.members(set2);
|
|
3570
3820
|
};
|
|
3571
3821
|
assert.notSameMembers = function(set1, set2, msg) {
|
|
3572
|
-
new Assertion(
|
|
3822
|
+
new Assertion(
|
|
3823
|
+
set1,
|
|
3824
|
+
msg,
|
|
3825
|
+
assert.notSameMembers,
|
|
3826
|
+
true
|
|
3827
|
+
).to.not.have.same.members(set2);
|
|
3573
3828
|
};
|
|
3574
3829
|
assert.sameDeepMembers = function(set1, set2, msg) {
|
|
3575
|
-
new Assertion(
|
|
3830
|
+
new Assertion(
|
|
3831
|
+
set1,
|
|
3832
|
+
msg,
|
|
3833
|
+
assert.sameDeepMembers,
|
|
3834
|
+
true
|
|
3835
|
+
).to.have.same.deep.members(set2);
|
|
3576
3836
|
};
|
|
3577
3837
|
assert.notSameDeepMembers = function(set1, set2, msg) {
|
|
3578
|
-
new Assertion(
|
|
3838
|
+
new Assertion(
|
|
3839
|
+
set1,
|
|
3840
|
+
msg,
|
|
3841
|
+
assert.notSameDeepMembers,
|
|
3842
|
+
true
|
|
3843
|
+
).to.not.have.same.deep.members(set2);
|
|
3579
3844
|
};
|
|
3580
3845
|
assert.sameOrderedMembers = function(set1, set2, msg) {
|
|
3581
|
-
new Assertion(
|
|
3846
|
+
new Assertion(
|
|
3847
|
+
set1,
|
|
3848
|
+
msg,
|
|
3849
|
+
assert.sameOrderedMembers,
|
|
3850
|
+
true
|
|
3851
|
+
).to.have.same.ordered.members(set2);
|
|
3582
3852
|
};
|
|
3583
3853
|
assert.notSameOrderedMembers = function(set1, set2, msg) {
|
|
3584
|
-
new Assertion(
|
|
3854
|
+
new Assertion(
|
|
3855
|
+
set1,
|
|
3856
|
+
msg,
|
|
3857
|
+
assert.notSameOrderedMembers,
|
|
3858
|
+
true
|
|
3859
|
+
).to.not.have.same.ordered.members(set2);
|
|
3585
3860
|
};
|
|
3586
3861
|
assert.sameDeepOrderedMembers = function(set1, set2, msg) {
|
|
3587
|
-
new Assertion(
|
|
3862
|
+
new Assertion(
|
|
3863
|
+
set1,
|
|
3864
|
+
msg,
|
|
3865
|
+
assert.sameDeepOrderedMembers,
|
|
3866
|
+
true
|
|
3867
|
+
).to.have.same.deep.ordered.members(set2);
|
|
3588
3868
|
};
|
|
3589
3869
|
assert.notSameDeepOrderedMembers = function(set1, set2, msg) {
|
|
3590
|
-
new Assertion(
|
|
3870
|
+
new Assertion(
|
|
3871
|
+
set1,
|
|
3872
|
+
msg,
|
|
3873
|
+
assert.notSameDeepOrderedMembers,
|
|
3874
|
+
true
|
|
3875
|
+
).to.not.have.same.deep.ordered.members(set2);
|
|
3591
3876
|
};
|
|
3592
3877
|
assert.includeMembers = function(superset, subset, msg) {
|
|
3593
|
-
new Assertion(superset, msg, assert.includeMembers, true).to.include.members(
|
|
3878
|
+
new Assertion(superset, msg, assert.includeMembers, true).to.include.members(
|
|
3879
|
+
subset
|
|
3880
|
+
);
|
|
3594
3881
|
};
|
|
3595
3882
|
assert.notIncludeMembers = function(superset, subset, msg) {
|
|
3596
|
-
new Assertion(
|
|
3883
|
+
new Assertion(
|
|
3884
|
+
superset,
|
|
3885
|
+
msg,
|
|
3886
|
+
assert.notIncludeMembers,
|
|
3887
|
+
true
|
|
3888
|
+
).to.not.include.members(subset);
|
|
3597
3889
|
};
|
|
3598
3890
|
assert.includeDeepMembers = function(superset, subset, msg) {
|
|
3599
|
-
new Assertion(
|
|
3891
|
+
new Assertion(
|
|
3892
|
+
superset,
|
|
3893
|
+
msg,
|
|
3894
|
+
assert.includeDeepMembers,
|
|
3895
|
+
true
|
|
3896
|
+
).to.include.deep.members(subset);
|
|
3600
3897
|
};
|
|
3601
3898
|
assert.notIncludeDeepMembers = function(superset, subset, msg) {
|
|
3602
|
-
new Assertion(
|
|
3899
|
+
new Assertion(
|
|
3900
|
+
superset,
|
|
3901
|
+
msg,
|
|
3902
|
+
assert.notIncludeDeepMembers,
|
|
3903
|
+
true
|
|
3904
|
+
).to.not.include.deep.members(subset);
|
|
3603
3905
|
};
|
|
3604
3906
|
assert.includeOrderedMembers = function(superset, subset, msg) {
|
|
3605
|
-
new Assertion(
|
|
3907
|
+
new Assertion(
|
|
3908
|
+
superset,
|
|
3909
|
+
msg,
|
|
3910
|
+
assert.includeOrderedMembers,
|
|
3911
|
+
true
|
|
3912
|
+
).to.include.ordered.members(subset);
|
|
3606
3913
|
};
|
|
3607
3914
|
assert.notIncludeOrderedMembers = function(superset, subset, msg) {
|
|
3608
|
-
new Assertion(
|
|
3915
|
+
new Assertion(
|
|
3916
|
+
superset,
|
|
3917
|
+
msg,
|
|
3918
|
+
assert.notIncludeOrderedMembers,
|
|
3919
|
+
true
|
|
3920
|
+
).to.not.include.ordered.members(subset);
|
|
3609
3921
|
};
|
|
3610
3922
|
assert.includeDeepOrderedMembers = function(superset, subset, msg) {
|
|
3611
|
-
new Assertion(
|
|
3923
|
+
new Assertion(
|
|
3924
|
+
superset,
|
|
3925
|
+
msg,
|
|
3926
|
+
assert.includeDeepOrderedMembers,
|
|
3927
|
+
true
|
|
3928
|
+
).to.include.deep.ordered.members(subset);
|
|
3612
3929
|
};
|
|
3613
3930
|
assert.notIncludeDeepOrderedMembers = function(superset, subset, msg) {
|
|
3614
|
-
new Assertion(
|
|
3931
|
+
new Assertion(
|
|
3932
|
+
superset,
|
|
3933
|
+
msg,
|
|
3934
|
+
assert.notIncludeDeepOrderedMembers,
|
|
3935
|
+
true
|
|
3936
|
+
).to.not.include.deep.ordered.members(subset);
|
|
3615
3937
|
};
|
|
3616
3938
|
assert.oneOf = function(inList, list, msg) {
|
|
3617
3939
|
new Assertion(inList, msg, assert.oneOf, true).to.be.oneOf(list);
|
|
@@ -3619,11 +3941,7 @@ assert.oneOf = function(inList, list, msg) {
|
|
|
3619
3941
|
assert.isIterable = function(obj, msg) {
|
|
3620
3942
|
if (obj == void 0 || !obj[Symbol.iterator]) {
|
|
3621
3943
|
msg = msg ? `${msg} expected ${inspect2(obj)} to be an iterable` : `expected ${inspect2(obj)} to be an iterable`;
|
|
3622
|
-
throw new AssertionError(
|
|
3623
|
-
msg,
|
|
3624
|
-
void 0,
|
|
3625
|
-
assert.isIterable
|
|
3626
|
-
);
|
|
3944
|
+
throw new AssertionError(msg, void 0, assert.isIterable);
|
|
3627
3945
|
}
|
|
3628
3946
|
};
|
|
3629
3947
|
assert.changes = function(fn, obj, prop, msg) {
|
|
@@ -3635,7 +3953,7 @@ assert.changes = function(fn, obj, prop, msg) {
|
|
|
3635
3953
|
};
|
|
3636
3954
|
assert.changesBy = function(fn, obj, prop, delta, msg) {
|
|
3637
3955
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
3638
|
-
|
|
3956
|
+
let tmpMsg = delta;
|
|
3639
3957
|
delta = prop;
|
|
3640
3958
|
msg = tmpMsg;
|
|
3641
3959
|
} else if (arguments.length === 3) {
|
|
@@ -3649,11 +3967,14 @@ assert.doesNotChange = function(fn, obj, prop, msg) {
|
|
|
3649
3967
|
msg = prop;
|
|
3650
3968
|
prop = null;
|
|
3651
3969
|
}
|
|
3652
|
-
return new Assertion(fn, msg, assert.doesNotChange, true).to.not.change(
|
|
3970
|
+
return new Assertion(fn, msg, assert.doesNotChange, true).to.not.change(
|
|
3971
|
+
obj,
|
|
3972
|
+
prop
|
|
3973
|
+
);
|
|
3653
3974
|
};
|
|
3654
3975
|
assert.changesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
3655
3976
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
3656
|
-
|
|
3977
|
+
let tmpMsg = delta;
|
|
3657
3978
|
delta = prop;
|
|
3658
3979
|
msg = tmpMsg;
|
|
3659
3980
|
} else if (arguments.length === 3) {
|
|
@@ -3671,7 +3992,7 @@ assert.increases = function(fn, obj, prop, msg) {
|
|
|
3671
3992
|
};
|
|
3672
3993
|
assert.increasesBy = function(fn, obj, prop, delta, msg) {
|
|
3673
3994
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
3674
|
-
|
|
3995
|
+
let tmpMsg = delta;
|
|
3675
3996
|
delta = prop;
|
|
3676
3997
|
msg = tmpMsg;
|
|
3677
3998
|
} else if (arguments.length === 3) {
|
|
@@ -3685,11 +4006,14 @@ assert.doesNotIncrease = function(fn, obj, prop, msg) {
|
|
|
3685
4006
|
msg = prop;
|
|
3686
4007
|
prop = null;
|
|
3687
4008
|
}
|
|
3688
|
-
return new Assertion(fn, msg, assert.doesNotIncrease, true).to.not.increase(
|
|
4009
|
+
return new Assertion(fn, msg, assert.doesNotIncrease, true).to.not.increase(
|
|
4010
|
+
obj,
|
|
4011
|
+
prop
|
|
4012
|
+
);
|
|
3689
4013
|
};
|
|
3690
4014
|
assert.increasesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
3691
4015
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
3692
|
-
|
|
4016
|
+
let tmpMsg = delta;
|
|
3693
4017
|
delta = prop;
|
|
3694
4018
|
msg = tmpMsg;
|
|
3695
4019
|
} else if (arguments.length === 3) {
|
|
@@ -3707,7 +4031,7 @@ assert.decreases = function(fn, obj, prop, msg) {
|
|
|
3707
4031
|
};
|
|
3708
4032
|
assert.decreasesBy = function(fn, obj, prop, delta, msg) {
|
|
3709
4033
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
3710
|
-
|
|
4034
|
+
let tmpMsg = delta;
|
|
3711
4035
|
delta = prop;
|
|
3712
4036
|
msg = tmpMsg;
|
|
3713
4037
|
} else if (arguments.length === 3) {
|
|
@@ -3721,11 +4045,14 @@ assert.doesNotDecrease = function(fn, obj, prop, msg) {
|
|
|
3721
4045
|
msg = prop;
|
|
3722
4046
|
prop = null;
|
|
3723
4047
|
}
|
|
3724
|
-
return new Assertion(fn, msg, assert.doesNotDecrease, true).to.not.decrease(
|
|
4048
|
+
return new Assertion(fn, msg, assert.doesNotDecrease, true).to.not.decrease(
|
|
4049
|
+
obj,
|
|
4050
|
+
prop
|
|
4051
|
+
);
|
|
3725
4052
|
};
|
|
3726
4053
|
assert.doesNotDecreaseBy = function(fn, obj, prop, delta, msg) {
|
|
3727
4054
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
3728
|
-
|
|
4055
|
+
let tmpMsg = delta;
|
|
3729
4056
|
delta = prop;
|
|
3730
4057
|
msg = tmpMsg;
|
|
3731
4058
|
} else if (arguments.length === 3) {
|
|
@@ -3736,7 +4063,7 @@ assert.doesNotDecreaseBy = function(fn, obj, prop, delta, msg) {
|
|
|
3736
4063
|
};
|
|
3737
4064
|
assert.decreasesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
3738
4065
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
3739
|
-
|
|
4066
|
+
let tmpMsg = delta;
|
|
3740
4067
|
delta = prop;
|
|
3741
4068
|
msg = tmpMsg;
|
|
3742
4069
|
} else if (arguments.length === 3) {
|
|
@@ -3774,15 +4101,38 @@ assert.isEmpty = function(val, msg) {
|
|
|
3774
4101
|
assert.isNotEmpty = function(val, msg) {
|
|
3775
4102
|
new Assertion(val, msg, assert.isNotEmpty, true).to.not.be.empty;
|
|
3776
4103
|
};
|
|
3777
|
-
|
|
4104
|
+
assert.containsSubset = function(val, exp, msg) {
|
|
4105
|
+
new Assertion(val, msg).to.containSubset(exp);
|
|
4106
|
+
};
|
|
4107
|
+
assert.doesNotContainSubset = function(val, exp, msg) {
|
|
4108
|
+
new Assertion(val, msg).to.not.containSubset(exp);
|
|
4109
|
+
};
|
|
4110
|
+
var aliases = [
|
|
4111
|
+
["isOk", "ok"],
|
|
4112
|
+
["isNotOk", "notOk"],
|
|
4113
|
+
["throws", "throw"],
|
|
4114
|
+
["throws", "Throw"],
|
|
4115
|
+
["isExtensible", "extensible"],
|
|
4116
|
+
["isNotExtensible", "notExtensible"],
|
|
4117
|
+
["isSealed", "sealed"],
|
|
4118
|
+
["isNotSealed", "notSealed"],
|
|
4119
|
+
["isFrozen", "frozen"],
|
|
4120
|
+
["isNotFrozen", "notFrozen"],
|
|
4121
|
+
["isEmpty", "empty"],
|
|
4122
|
+
["isNotEmpty", "notEmpty"],
|
|
4123
|
+
["isCallable", "isFunction"],
|
|
4124
|
+
["isNotCallable", "isNotFunction"],
|
|
4125
|
+
["containsSubset", "containSubset"]
|
|
4126
|
+
];
|
|
4127
|
+
for (const [name, as] of aliases) {
|
|
3778
4128
|
assert[as] = assert[name];
|
|
3779
|
-
|
|
3780
|
-
}, "alias"))("isOk", "ok")("isNotOk", "notOk")("throws", "throw")("throws", "Throw")("isExtensible", "extensible")("isNotExtensible", "notExtensible")("isSealed", "sealed")("isNotSealed", "notSealed")("isFrozen", "frozen")("isNotFrozen", "notFrozen")("isEmpty", "empty")("isNotEmpty", "notEmpty")("isCallable", "isFunction")("isNotCallable", "isNotFunction");
|
|
4129
|
+
}
|
|
3781
4130
|
|
|
3782
4131
|
// lib/chai.js
|
|
3783
4132
|
var used = [];
|
|
3784
4133
|
function use(fn) {
|
|
3785
4134
|
const exports = {
|
|
4135
|
+
use,
|
|
3786
4136
|
AssertionError,
|
|
3787
4137
|
util: utils_exports,
|
|
3788
4138
|
config,
|