chai 5.2.0 → 5.2.2
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/README.md +1 -1
- package/chai.js +397 -347
- package/lib/chai/assertion.js +167 -143
- package/lib/chai/core/assertions.js +108 -109
- package/lib/chai/interface/assert.js +13 -13
- package/lib/chai/interface/should.js +1 -1
- package/lib/chai/utils/addChainableMethod.js +12 -12
- package/lib/chai/utils/addMethod.js +3 -3
- package/lib/chai/utils/addProperty.js +2 -2
- package/lib/chai/utils/expectTypes.js +6 -6
- package/lib/chai/utils/flag.js +4 -3
- package/lib/chai/utils/getMessage.js +8 -8
- package/lib/chai/utils/getOperator.js +7 -7
- package/lib/chai/utils/getProperties.js +2 -2
- package/lib/chai/utils/inspect.js +1 -1
- package/lib/chai/utils/objDisplay.js +2 -2
- package/lib/chai/utils/overwriteChainableMethod.js +7 -7
- package/lib/chai/utils/overwriteMethod.js +5 -5
- package/lib/chai/utils/overwriteProperty.js +4 -4
- package/lib/chai/utils/proxify.js +10 -9
- package/lib/chai/utils/test.js +1 -1
- package/lib/chai/utils/transferFlags.js +2 -2
- package/package.json +12 -4
- package/.prettierrc.json +0 -10
- package/CODEOWNERS +0 -1
- package/CODE_OF_CONDUCT.md +0 -58
- package/CONTRIBUTING.md +0 -218
- package/History.md +0 -1059
- package/ReleaseNotes.md +0 -737
- package/eslint.config.js +0 -26
- package/web-test-runner.config.js +0 -20
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,96 +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
|
-
|
|
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() {
|
|
1391
1435
|
console.warn(
|
|
1392
1436
|
"Assertion.includeStack is deprecated, use chai.config.includeStack instead."
|
|
1393
1437
|
);
|
|
1394
1438
|
return config.includeStack;
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1439
|
+
}
|
|
1440
|
+
/** @param {boolean} value */
|
|
1441
|
+
static set includeStack(value) {
|
|
1397
1442
|
console.warn(
|
|
1398
1443
|
"Assertion.includeStack is deprecated, use chai.config.includeStack instead."
|
|
1399
1444
|
);
|
|
1400
1445
|
config.includeStack = value;
|
|
1401
1446
|
}
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
get: function() {
|
|
1447
|
+
/** @returns {boolean} */
|
|
1448
|
+
static get showDiff() {
|
|
1405
1449
|
console.warn(
|
|
1406
1450
|
"Assertion.showDiff is deprecated, use chai.config.showDiff instead."
|
|
1407
1451
|
);
|
|
1408
1452
|
return config.showDiff;
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1453
|
+
}
|
|
1454
|
+
/** @param {boolean} value */
|
|
1455
|
+
static set showDiff(value) {
|
|
1411
1456
|
console.warn(
|
|
1412
1457
|
"Assertion.showDiff is deprecated, use chai.config.showDiff instead."
|
|
1413
1458
|
);
|
|
1414
1459
|
config.showDiff = value;
|
|
1415
1460
|
}
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
}
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
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
|
+
);
|
|
1454
1542
|
}
|
|
1455
|
-
throw new AssertionError(
|
|
1456
|
-
msg,
|
|
1457
|
-
assertionErrorObjectProperties,
|
|
1458
|
-
config.includeStack ? this.assert : flag(this, "ssfi")
|
|
1459
|
-
);
|
|
1460
1543
|
}
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1544
|
+
/**
|
|
1545
|
+
* Quick reference to stored `actual` value for plugin developers.
|
|
1546
|
+
*
|
|
1547
|
+
* @returns {unknown}
|
|
1548
|
+
*/
|
|
1549
|
+
get _obj() {
|
|
1464
1550
|
return flag(this, "object");
|
|
1465
|
-
}
|
|
1466
|
-
|
|
1551
|
+
}
|
|
1552
|
+
/**
|
|
1553
|
+
* Quick reference to stored `actual` value for plugin developers.
|
|
1554
|
+
*
|
|
1555
|
+
* @param {unknown} val
|
|
1556
|
+
*/
|
|
1557
|
+
set _obj(val) {
|
|
1467
1558
|
flag(this, "object", val);
|
|
1468
1559
|
}
|
|
1469
|
-
}
|
|
1560
|
+
};
|
|
1470
1561
|
|
|
1471
1562
|
// lib/chai/utils/isProxyEnabled.js
|
|
1472
1563
|
function isProxyEnabled() {
|
|
@@ -1483,10 +1574,9 @@ function addProperty(ctx, name, getter) {
|
|
|
1483
1574
|
if (!isProxyEnabled() && !flag(this, "lockSsfi")) {
|
|
1484
1575
|
flag(this, "ssfi", propertyGetter);
|
|
1485
1576
|
}
|
|
1486
|
-
|
|
1487
|
-
if (result !== void 0)
|
|
1488
|
-
|
|
1489
|
-
var newAssertion = new Assertion();
|
|
1577
|
+
let result = getter.call(this);
|
|
1578
|
+
if (result !== void 0) return result;
|
|
1579
|
+
let newAssertion = new Assertion();
|
|
1490
1580
|
transferFlags(this, newAssertion);
|
|
1491
1581
|
return newAssertion;
|
|
1492
1582
|
}, "propertyGetter"),
|
|
@@ -1499,10 +1589,9 @@ __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
1596
|
throw Error(
|
|
1508
1597
|
"Invalid Chai property: " + assertionName + '.length. Due to a compatibility issue, "length" cannot directly follow "' + assertionName + '". Use "' + assertionName + '.lengthOf" instead.'
|
|
@@ -1511,7 +1600,7 @@ function addLengthGuard(fn, assertionName, isChainable) {
|
|
|
1511
1600
|
throw Error(
|
|
1512
1601
|
"Invalid Chai property: " + assertionName + '.length. See docs for proper usage of "' + assertionName + '".'
|
|
1513
1602
|
);
|
|
1514
|
-
}
|
|
1603
|
+
}, "get")
|
|
1515
1604
|
});
|
|
1516
1605
|
return fn;
|
|
1517
1606
|
}
|
|
@@ -1519,14 +1608,14 @@ __name(addLengthGuard, "addLengthGuard");
|
|
|
1519
1608
|
|
|
1520
1609
|
// lib/chai/utils/getProperties.js
|
|
1521
1610
|
function getProperties(object) {
|
|
1522
|
-
|
|
1611
|
+
let result = Object.getOwnPropertyNames(object);
|
|
1523
1612
|
function addProperty2(property) {
|
|
1524
1613
|
if (result.indexOf(property) === -1) {
|
|
1525
1614
|
result.push(property);
|
|
1526
1615
|
}
|
|
1527
1616
|
}
|
|
1528
1617
|
__name(addProperty2, "addProperty");
|
|
1529
|
-
|
|
1618
|
+
let proto = Object.getPrototypeOf(object);
|
|
1530
1619
|
while (proto !== null) {
|
|
1531
1620
|
Object.getOwnPropertyNames(proto).forEach(addProperty2);
|
|
1532
1621
|
proto = Object.getPrototypeOf(proto);
|
|
@@ -1538,8 +1627,7 @@ __name(getProperties, "getProperties");
|
|
|
1538
1627
|
// lib/chai/utils/proxify.js
|
|
1539
1628
|
var builtins = ["__flags", "__methods", "_obj", "assert"];
|
|
1540
1629
|
function proxify(obj, nonChainableMethodName) {
|
|
1541
|
-
if (!isProxyEnabled())
|
|
1542
|
-
return obj;
|
|
1630
|
+
if (!isProxyEnabled()) return obj;
|
|
1543
1631
|
return new Proxy(obj, {
|
|
1544
1632
|
get: /* @__PURE__ */ __name(function proxyGetter(target, property) {
|
|
1545
1633
|
if (typeof property === "string" && config.proxyExcludedKeys.indexOf(property) === -1 && !Reflect.has(target, property)) {
|
|
@@ -1548,15 +1636,15 @@ function proxify(obj, nonChainableMethodName) {
|
|
|
1548
1636
|
"Invalid Chai property: " + nonChainableMethodName + "." + property + '. See docs for proper usage of "' + nonChainableMethodName + '".'
|
|
1549
1637
|
);
|
|
1550
1638
|
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1639
|
+
let suggestion = null;
|
|
1640
|
+
let suggestionDistance = 4;
|
|
1553
1641
|
getProperties(target).forEach(function(prop) {
|
|
1554
1642
|
if (
|
|
1555
1643
|
// we actually mean to check `Object.prototype` here
|
|
1556
1644
|
// eslint-disable-next-line no-prototype-builtins
|
|
1557
1645
|
!Object.prototype.hasOwnProperty(prop) && builtins.indexOf(prop) === -1
|
|
1558
1646
|
) {
|
|
1559
|
-
|
|
1647
|
+
let dist = stringDistanceCapped(property, prop, suggestionDistance);
|
|
1560
1648
|
if (dist < suggestionDistance) {
|
|
1561
1649
|
suggestion = prop;
|
|
1562
1650
|
suggestionDistance = dist;
|
|
@@ -1583,7 +1671,7 @@ function stringDistanceCapped(strA, strB, cap) {
|
|
|
1583
1671
|
if (Math.abs(strA.length - strB.length) >= cap) {
|
|
1584
1672
|
return cap;
|
|
1585
1673
|
}
|
|
1586
|
-
|
|
1674
|
+
let memo = [];
|
|
1587
1675
|
for (let i = 0; i <= strA.length; i++) {
|
|
1588
1676
|
memo[i] = Array(strB.length + 1).fill(0);
|
|
1589
1677
|
memo[i][0] = i;
|
|
@@ -1592,7 +1680,7 @@ function stringDistanceCapped(strA, strB, cap) {
|
|
|
1592
1680
|
memo[0][j] = j;
|
|
1593
1681
|
}
|
|
1594
1682
|
for (let i = 1; i <= strA.length; i++) {
|
|
1595
|
-
|
|
1683
|
+
let ch = strA.charCodeAt(i - 1);
|
|
1596
1684
|
for (let j = 1; j <= strB.length; j++) {
|
|
1597
1685
|
if (Math.abs(i - j) >= cap) {
|
|
1598
1686
|
memo[i][j] = cap;
|
|
@@ -1611,14 +1699,13 @@ __name(stringDistanceCapped, "stringDistanceCapped");
|
|
|
1611
1699
|
|
|
1612
1700
|
// lib/chai/utils/addMethod.js
|
|
1613
1701
|
function addMethod(ctx, name, method) {
|
|
1614
|
-
|
|
1702
|
+
let methodWrapper = /* @__PURE__ */ __name(function() {
|
|
1615
1703
|
if (!flag(this, "lockSsfi")) {
|
|
1616
1704
|
flag(this, "ssfi", methodWrapper);
|
|
1617
1705
|
}
|
|
1618
|
-
|
|
1619
|
-
if (result !== void 0)
|
|
1620
|
-
|
|
1621
|
-
var newAssertion = new Assertion();
|
|
1706
|
+
let result = method.apply(this, arguments);
|
|
1707
|
+
if (result !== void 0) return result;
|
|
1708
|
+
let newAssertion = new Assertion();
|
|
1622
1709
|
transferFlags(this, newAssertion);
|
|
1623
1710
|
return newAssertion;
|
|
1624
1711
|
}, "methodWrapper");
|
|
@@ -1629,23 +1716,22 @@ __name(addMethod, "addMethod");
|
|
|
1629
1716
|
|
|
1630
1717
|
// lib/chai/utils/overwriteProperty.js
|
|
1631
1718
|
function overwriteProperty(ctx, name, getter) {
|
|
1632
|
-
|
|
1719
|
+
let _get = Object.getOwnPropertyDescriptor(ctx, name), _super = /* @__PURE__ */ __name(function() {
|
|
1633
1720
|
}, "_super");
|
|
1634
|
-
if (_get && "function" === typeof _get.get)
|
|
1635
|
-
_super = _get.get;
|
|
1721
|
+
if (_get && "function" === typeof _get.get) _super = _get.get;
|
|
1636
1722
|
Object.defineProperty(ctx, name, {
|
|
1637
1723
|
get: /* @__PURE__ */ __name(function overwritingPropertyGetter() {
|
|
1638
1724
|
if (!isProxyEnabled() && !flag(this, "lockSsfi")) {
|
|
1639
1725
|
flag(this, "ssfi", overwritingPropertyGetter);
|
|
1640
1726
|
}
|
|
1641
|
-
|
|
1727
|
+
let origLockSsfi = flag(this, "lockSsfi");
|
|
1642
1728
|
flag(this, "lockSsfi", true);
|
|
1643
|
-
|
|
1729
|
+
let result = getter(_super).call(this);
|
|
1644
1730
|
flag(this, "lockSsfi", origLockSsfi);
|
|
1645
1731
|
if (result !== void 0) {
|
|
1646
1732
|
return result;
|
|
1647
1733
|
}
|
|
1648
|
-
|
|
1734
|
+
let newAssertion = new Assertion();
|
|
1649
1735
|
transferFlags(this, newAssertion);
|
|
1650
1736
|
return newAssertion;
|
|
1651
1737
|
}, "overwritingPropertyGetter"),
|
|
@@ -1656,23 +1742,22 @@ __name(overwriteProperty, "overwriteProperty");
|
|
|
1656
1742
|
|
|
1657
1743
|
// lib/chai/utils/overwriteMethod.js
|
|
1658
1744
|
function overwriteMethod(ctx, name, method) {
|
|
1659
|
-
|
|
1745
|
+
let _method = ctx[name], _super = /* @__PURE__ */ __name(function() {
|
|
1660
1746
|
throw new Error(name + " is not a function");
|
|
1661
1747
|
}, "_super");
|
|
1662
|
-
if (_method && "function" === typeof _method)
|
|
1663
|
-
|
|
1664
|
-
var overwritingMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
1748
|
+
if (_method && "function" === typeof _method) _super = _method;
|
|
1749
|
+
let overwritingMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
1665
1750
|
if (!flag(this, "lockSsfi")) {
|
|
1666
1751
|
flag(this, "ssfi", overwritingMethodWrapper);
|
|
1667
1752
|
}
|
|
1668
|
-
|
|
1753
|
+
let origLockSsfi = flag(this, "lockSsfi");
|
|
1669
1754
|
flag(this, "lockSsfi", true);
|
|
1670
|
-
|
|
1755
|
+
let result = method(_super).apply(this, arguments);
|
|
1671
1756
|
flag(this, "lockSsfi", origLockSsfi);
|
|
1672
1757
|
if (result !== void 0) {
|
|
1673
1758
|
return result;
|
|
1674
1759
|
}
|
|
1675
|
-
|
|
1760
|
+
let newAssertion = new Assertion();
|
|
1676
1761
|
transferFlags(this, newAssertion);
|
|
1677
1762
|
return newAssertion;
|
|
1678
1763
|
}, "overwritingMethodWrapper");
|
|
@@ -1686,9 +1771,8 @@ var canSetPrototype = typeof Object.setPrototypeOf === "function";
|
|
|
1686
1771
|
var testFn = /* @__PURE__ */ __name(function() {
|
|
1687
1772
|
}, "testFn");
|
|
1688
1773
|
var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) {
|
|
1689
|
-
|
|
1690
|
-
if (typeof propDesc !== "object")
|
|
1691
|
-
return true;
|
|
1774
|
+
let propDesc = Object.getOwnPropertyDescriptor(testFn, name);
|
|
1775
|
+
if (typeof propDesc !== "object") return true;
|
|
1692
1776
|
return !propDesc.configurable;
|
|
1693
1777
|
});
|
|
1694
1778
|
var call = Function.prototype.call;
|
|
@@ -1698,7 +1782,7 @@ function addChainableMethod(ctx, name, method, chainingBehavior) {
|
|
|
1698
1782
|
chainingBehavior = /* @__PURE__ */ __name(function() {
|
|
1699
1783
|
}, "chainingBehavior");
|
|
1700
1784
|
}
|
|
1701
|
-
|
|
1785
|
+
let chainableBehavior = {
|
|
1702
1786
|
method,
|
|
1703
1787
|
chainingBehavior
|
|
1704
1788
|
};
|
|
@@ -1709,31 +1793,31 @@ function addChainableMethod(ctx, name, method, chainingBehavior) {
|
|
|
1709
1793
|
Object.defineProperty(ctx, name, {
|
|
1710
1794
|
get: /* @__PURE__ */ __name(function chainableMethodGetter() {
|
|
1711
1795
|
chainableBehavior.chainingBehavior.call(this);
|
|
1712
|
-
|
|
1796
|
+
let chainableMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
1713
1797
|
if (!flag(this, "lockSsfi")) {
|
|
1714
1798
|
flag(this, "ssfi", chainableMethodWrapper);
|
|
1715
1799
|
}
|
|
1716
|
-
|
|
1800
|
+
let result = chainableBehavior.method.apply(this, arguments);
|
|
1717
1801
|
if (result !== void 0) {
|
|
1718
1802
|
return result;
|
|
1719
1803
|
}
|
|
1720
|
-
|
|
1804
|
+
let newAssertion = new Assertion();
|
|
1721
1805
|
transferFlags(this, newAssertion);
|
|
1722
1806
|
return newAssertion;
|
|
1723
1807
|
}, "chainableMethodWrapper");
|
|
1724
1808
|
addLengthGuard(chainableMethodWrapper, name, true);
|
|
1725
1809
|
if (canSetPrototype) {
|
|
1726
|
-
|
|
1810
|
+
let prototype = Object.create(this);
|
|
1727
1811
|
prototype.call = call;
|
|
1728
1812
|
prototype.apply = apply;
|
|
1729
1813
|
Object.setPrototypeOf(chainableMethodWrapper, prototype);
|
|
1730
1814
|
} else {
|
|
1731
|
-
|
|
1815
|
+
let asserterNames = Object.getOwnPropertyNames(ctx);
|
|
1732
1816
|
asserterNames.forEach(function(asserterName) {
|
|
1733
1817
|
if (excludeNames.indexOf(asserterName) !== -1) {
|
|
1734
1818
|
return;
|
|
1735
1819
|
}
|
|
1736
|
-
|
|
1820
|
+
let pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
|
|
1737
1821
|
Object.defineProperty(chainableMethodWrapper, asserterName, pd);
|
|
1738
1822
|
});
|
|
1739
1823
|
}
|
|
@@ -1747,24 +1831,24 @@ __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
|
});
|
|
@@ -1798,21 +1881,20 @@ var isNaN2 = Number.isNaN;
|
|
|
1798
1881
|
|
|
1799
1882
|
// lib/chai/utils/getOperator.js
|
|
1800
1883
|
function isObjectType(obj) {
|
|
1801
|
-
|
|
1802
|
-
|
|
1884
|
+
let objectType = type(obj);
|
|
1885
|
+
let objectTypes = ["Array", "Object", "Function"];
|
|
1803
1886
|
return objectTypes.indexOf(objectType) !== -1;
|
|
1804
1887
|
}
|
|
1805
1888
|
__name(isObjectType, "isObjectType");
|
|
1806
1889
|
function getOperator(obj, args) {
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
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];
|
|
1811
1894
|
if (operator) {
|
|
1812
1895
|
return operator;
|
|
1813
1896
|
}
|
|
1814
|
-
if (typeof msg === "function")
|
|
1815
|
-
msg = msg();
|
|
1897
|
+
if (typeof msg === "function") msg = msg();
|
|
1816
1898
|
msg = msg || "";
|
|
1817
1899
|
if (!msg) {
|
|
1818
1900
|
return void 0;
|
|
@@ -1820,7 +1902,7 @@ function getOperator(obj, args) {
|
|
|
1820
1902
|
if (/\shave\s/.test(msg)) {
|
|
1821
1903
|
return void 0;
|
|
1822
1904
|
}
|
|
1823
|
-
|
|
1905
|
+
let isObject = isObjectType(expected);
|
|
1824
1906
|
if (/\snot\s/.test(msg)) {
|
|
1825
1907
|
return isObject ? "notDeepStrictEqual" : "notStrictEqual";
|
|
1826
1908
|
}
|
|
@@ -1900,10 +1982,9 @@ var functionTypes = {
|
|
|
1900
1982
|
asyncgeneratorfunction: ["asyncgeneratorfunction"]
|
|
1901
1983
|
};
|
|
1902
1984
|
function an(type3, msg) {
|
|
1903
|
-
if (msg)
|
|
1904
|
-
flag2(this, "message", msg);
|
|
1985
|
+
if (msg) flag2(this, "message", msg);
|
|
1905
1986
|
type3 = type3.toLowerCase();
|
|
1906
|
-
|
|
1987
|
+
let obj = flag2(this, "object"), article = ~["a", "e", "i", "o", "u"].indexOf(type3.charAt(0)) ? "an " : "a ";
|
|
1907
1988
|
const detectedType = type(obj).toLowerCase();
|
|
1908
1989
|
if (functionTypes["function"].includes(type3)) {
|
|
1909
1990
|
this.assert(
|
|
@@ -1931,11 +2012,10 @@ function includeChainingBehavior() {
|
|
|
1931
2012
|
}
|
|
1932
2013
|
__name(includeChainingBehavior, "includeChainingBehavior");
|
|
1933
2014
|
function include(val, msg) {
|
|
1934
|
-
if (msg)
|
|
1935
|
-
|
|
1936
|
-
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;
|
|
1937
2017
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
1938
|
-
|
|
2018
|
+
let included = false;
|
|
1939
2019
|
switch (objType) {
|
|
1940
2020
|
case "string":
|
|
1941
2021
|
included = obj.indexOf(val) !== -1;
|
|
@@ -1973,7 +2053,7 @@ function include(val, msg) {
|
|
|
1973
2053
|
included = obj.indexOf(val) !== -1;
|
|
1974
2054
|
}
|
|
1975
2055
|
break;
|
|
1976
|
-
default:
|
|
2056
|
+
default: {
|
|
1977
2057
|
if (val !== Object(val)) {
|
|
1978
2058
|
throw new AssertionError(
|
|
1979
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(),
|
|
@@ -1981,9 +2061,11 @@ function include(val, msg) {
|
|
|
1981
2061
|
ssfi
|
|
1982
2062
|
);
|
|
1983
2063
|
}
|
|
1984
|
-
|
|
2064
|
+
let props = Object.keys(val);
|
|
2065
|
+
let firstErr = null;
|
|
2066
|
+
let numErrs = 0;
|
|
1985
2067
|
props.forEach(function(prop) {
|
|
1986
|
-
|
|
2068
|
+
let propAssertion = new Assertion(obj);
|
|
1987
2069
|
transferFlags(this, propAssertion, true);
|
|
1988
2070
|
flag2(propAssertion, "lockSsfi", true);
|
|
1989
2071
|
if (!negate || props.length === 1) {
|
|
@@ -1996,8 +2078,7 @@ function include(val, msg) {
|
|
|
1996
2078
|
if (!check_error_exports.compatibleConstructor(err, AssertionError)) {
|
|
1997
2079
|
throw err;
|
|
1998
2080
|
}
|
|
1999
|
-
if (firstErr === null)
|
|
2000
|
-
firstErr = err;
|
|
2081
|
+
if (firstErr === null) firstErr = err;
|
|
2001
2082
|
numErrs++;
|
|
2002
2083
|
}
|
|
2003
2084
|
}, this);
|
|
@@ -2005,6 +2086,7 @@ function include(val, msg) {
|
|
|
2005
2086
|
throw firstErr;
|
|
2006
2087
|
}
|
|
2007
2088
|
return;
|
|
2089
|
+
}
|
|
2008
2090
|
}
|
|
2009
2091
|
this.assert(
|
|
2010
2092
|
included,
|
|
@@ -2088,7 +2170,7 @@ Assertion.addProperty("NaN", function() {
|
|
|
2088
2170
|
);
|
|
2089
2171
|
});
|
|
2090
2172
|
function assertExist() {
|
|
2091
|
-
|
|
2173
|
+
let val = flag2(this, "object");
|
|
2092
2174
|
this.assert(
|
|
2093
2175
|
val !== null && val !== void 0,
|
|
2094
2176
|
"expected #{this} to exist",
|
|
@@ -2099,7 +2181,7 @@ __name(assertExist, "assertExist");
|
|
|
2099
2181
|
Assertion.addProperty("exist", assertExist);
|
|
2100
2182
|
Assertion.addProperty("exists", assertExist);
|
|
2101
2183
|
Assertion.addProperty("empty", function() {
|
|
2102
|
-
|
|
2184
|
+
let val = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), itemsCount;
|
|
2103
2185
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2104
2186
|
switch (type(val).toLowerCase()) {
|
|
2105
2187
|
case "array":
|
|
@@ -2117,9 +2199,10 @@ Assertion.addProperty("empty", function() {
|
|
|
2117
2199
|
void 0,
|
|
2118
2200
|
ssfi
|
|
2119
2201
|
);
|
|
2120
|
-
case "function":
|
|
2121
|
-
|
|
2202
|
+
case "function": {
|
|
2203
|
+
const msg = flagMsg + ".empty was passed a function " + getName(val);
|
|
2122
2204
|
throw new AssertionError(msg.trim(), void 0, ssfi);
|
|
2205
|
+
}
|
|
2123
2206
|
default:
|
|
2124
2207
|
if (val !== Object(val)) {
|
|
2125
2208
|
throw new AssertionError(
|
|
@@ -2137,7 +2220,7 @@ Assertion.addProperty("empty", function() {
|
|
|
2137
2220
|
);
|
|
2138
2221
|
});
|
|
2139
2222
|
function checkArguments() {
|
|
2140
|
-
|
|
2223
|
+
let obj = flag2(this, "object"), type3 = type(obj);
|
|
2141
2224
|
this.assert(
|
|
2142
2225
|
"Arguments" === type3,
|
|
2143
2226
|
"expected #{this} to be arguments but got " + type3,
|
|
@@ -2148,11 +2231,10 @@ __name(checkArguments, "checkArguments");
|
|
|
2148
2231
|
Assertion.addProperty("arguments", checkArguments);
|
|
2149
2232
|
Assertion.addProperty("Arguments", checkArguments);
|
|
2150
2233
|
function assertEqual(val, msg) {
|
|
2151
|
-
if (msg)
|
|
2152
|
-
|
|
2153
|
-
var obj = flag2(this, "object");
|
|
2234
|
+
if (msg) flag2(this, "message", msg);
|
|
2235
|
+
let obj = flag2(this, "object");
|
|
2154
2236
|
if (flag2(this, "deep")) {
|
|
2155
|
-
|
|
2237
|
+
let prevLockSsfi = flag2(this, "lockSsfi");
|
|
2156
2238
|
flag2(this, "lockSsfi", true);
|
|
2157
2239
|
this.eql(val);
|
|
2158
2240
|
flag2(this, "lockSsfi", prevLockSsfi);
|
|
@@ -2172,9 +2254,8 @@ Assertion.addMethod("equal", assertEqual);
|
|
|
2172
2254
|
Assertion.addMethod("equals", assertEqual);
|
|
2173
2255
|
Assertion.addMethod("eq", assertEqual);
|
|
2174
2256
|
function assertEql(obj, msg) {
|
|
2175
|
-
if (msg)
|
|
2176
|
-
|
|
2177
|
-
var eql = flag2(this, "eql");
|
|
2257
|
+
if (msg) flag2(this, "message", msg);
|
|
2258
|
+
let eql = flag2(this, "eql");
|
|
2178
2259
|
this.assert(
|
|
2179
2260
|
eql(obj, flag2(this, "object")),
|
|
2180
2261
|
"expected #{this} to deeply equal #{exp}",
|
|
@@ -2188,9 +2269,8 @@ __name(assertEql, "assertEql");
|
|
|
2188
2269
|
Assertion.addMethod("eql", assertEql);
|
|
2189
2270
|
Assertion.addMethod("eqls", assertEql);
|
|
2190
2271
|
function assertAbove(n, msg) {
|
|
2191
|
-
if (msg)
|
|
2192
|
-
|
|
2193
|
-
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();
|
|
2194
2274
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2195
2275
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2196
2276
|
}
|
|
@@ -2207,7 +2287,7 @@ function assertAbove(n, msg) {
|
|
|
2207
2287
|
ssfi
|
|
2208
2288
|
);
|
|
2209
2289
|
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2210
|
-
|
|
2290
|
+
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2211
2291
|
throw new AssertionError(
|
|
2212
2292
|
msgPrefix + "expected " + printObj + " to be a number or a date",
|
|
2213
2293
|
void 0,
|
|
@@ -2215,7 +2295,7 @@ function assertAbove(n, msg) {
|
|
|
2215
2295
|
);
|
|
2216
2296
|
}
|
|
2217
2297
|
if (doLength) {
|
|
2218
|
-
|
|
2298
|
+
let descriptor = "length", itemsCount;
|
|
2219
2299
|
if (objType === "map" || objType === "set") {
|
|
2220
2300
|
descriptor = "size";
|
|
2221
2301
|
itemsCount = obj.size;
|
|
@@ -2243,9 +2323,8 @@ Assertion.addMethod("above", assertAbove);
|
|
|
2243
2323
|
Assertion.addMethod("gt", assertAbove);
|
|
2244
2324
|
Assertion.addMethod("greaterThan", assertAbove);
|
|
2245
2325
|
function assertLeast(n, msg) {
|
|
2246
|
-
if (msg)
|
|
2247
|
-
|
|
2248
|
-
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;
|
|
2249
2328
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2250
2329
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2251
2330
|
}
|
|
@@ -2254,7 +2333,7 @@ function assertLeast(n, msg) {
|
|
|
2254
2333
|
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2255
2334
|
errorMessage = msgPrefix + "the argument to least must be a number";
|
|
2256
2335
|
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2257
|
-
|
|
2336
|
+
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2258
2337
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2259
2338
|
} else {
|
|
2260
2339
|
shouldThrow = false;
|
|
@@ -2263,7 +2342,7 @@ function assertLeast(n, msg) {
|
|
|
2263
2342
|
throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2264
2343
|
}
|
|
2265
2344
|
if (doLength) {
|
|
2266
|
-
|
|
2345
|
+
let descriptor = "length", itemsCount;
|
|
2267
2346
|
if (objType === "map" || objType === "set") {
|
|
2268
2347
|
descriptor = "size";
|
|
2269
2348
|
itemsCount = obj.size;
|
|
@@ -2291,9 +2370,8 @@ Assertion.addMethod("least", assertLeast);
|
|
|
2291
2370
|
Assertion.addMethod("gte", assertLeast);
|
|
2292
2371
|
Assertion.addMethod("greaterThanOrEqual", assertLeast);
|
|
2293
2372
|
function assertBelow(n, msg) {
|
|
2294
|
-
if (msg)
|
|
2295
|
-
|
|
2296
|
-
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;
|
|
2297
2375
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2298
2376
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2299
2377
|
}
|
|
@@ -2302,7 +2380,7 @@ function assertBelow(n, msg) {
|
|
|
2302
2380
|
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2303
2381
|
errorMessage = msgPrefix + "the argument to below must be a number";
|
|
2304
2382
|
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2305
|
-
|
|
2383
|
+
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2306
2384
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2307
2385
|
} else {
|
|
2308
2386
|
shouldThrow = false;
|
|
@@ -2311,7 +2389,7 @@ function assertBelow(n, msg) {
|
|
|
2311
2389
|
throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2312
2390
|
}
|
|
2313
2391
|
if (doLength) {
|
|
2314
|
-
|
|
2392
|
+
let descriptor = "length", itemsCount;
|
|
2315
2393
|
if (objType === "map" || objType === "set") {
|
|
2316
2394
|
descriptor = "size";
|
|
2317
2395
|
itemsCount = obj.size;
|
|
@@ -2339,9 +2417,8 @@ Assertion.addMethod("below", assertBelow);
|
|
|
2339
2417
|
Assertion.addMethod("lt", assertBelow);
|
|
2340
2418
|
Assertion.addMethod("lessThan", assertBelow);
|
|
2341
2419
|
function assertMost(n, msg) {
|
|
2342
|
-
if (msg)
|
|
2343
|
-
|
|
2344
|
-
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;
|
|
2345
2422
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2346
2423
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2347
2424
|
}
|
|
@@ -2350,7 +2427,7 @@ function assertMost(n, msg) {
|
|
|
2350
2427
|
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2351
2428
|
errorMessage = msgPrefix + "the argument to most must be a number";
|
|
2352
2429
|
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2353
|
-
|
|
2430
|
+
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2354
2431
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2355
2432
|
} else {
|
|
2356
2433
|
shouldThrow = false;
|
|
@@ -2359,7 +2436,7 @@ function assertMost(n, msg) {
|
|
|
2359
2436
|
throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2360
2437
|
}
|
|
2361
2438
|
if (doLength) {
|
|
2362
|
-
|
|
2439
|
+
let descriptor = "length", itemsCount;
|
|
2363
2440
|
if (objType === "map" || objType === "set") {
|
|
2364
2441
|
descriptor = "size";
|
|
2365
2442
|
itemsCount = obj.size;
|
|
@@ -2387,9 +2464,8 @@ Assertion.addMethod("most", assertMost);
|
|
|
2387
2464
|
Assertion.addMethod("lte", assertMost);
|
|
2388
2465
|
Assertion.addMethod("lessThanOrEqual", assertMost);
|
|
2389
2466
|
Assertion.addMethod("within", function(start, finish, msg) {
|
|
2390
|
-
if (msg)
|
|
2391
|
-
|
|
2392
|
-
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;
|
|
2393
2469
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2394
2470
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2395
2471
|
}
|
|
@@ -2398,7 +2474,7 @@ Assertion.addMethod("within", function(start, finish, msg) {
|
|
|
2398
2474
|
} else if ((!isNumeric(start) || !isNumeric(finish)) && (doLength || isNumeric(obj))) {
|
|
2399
2475
|
errorMessage = msgPrefix + "the arguments to within must be numbers";
|
|
2400
2476
|
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2401
|
-
|
|
2477
|
+
let printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2402
2478
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2403
2479
|
} else {
|
|
2404
2480
|
shouldThrow = false;
|
|
@@ -2407,7 +2483,7 @@ Assertion.addMethod("within", function(start, finish, msg) {
|
|
|
2407
2483
|
throw new AssertionError(errorMessage, void 0, ssfi);
|
|
2408
2484
|
}
|
|
2409
2485
|
if (doLength) {
|
|
2410
|
-
|
|
2486
|
+
let descriptor = "length", itemsCount;
|
|
2411
2487
|
if (objType === "map" || objType === "set") {
|
|
2412
2488
|
descriptor = "size";
|
|
2413
2489
|
itemsCount = obj.size;
|
|
@@ -2428,13 +2504,13 @@ Assertion.addMethod("within", function(start, finish, msg) {
|
|
|
2428
2504
|
}
|
|
2429
2505
|
});
|
|
2430
2506
|
function assertInstanceOf(constructor, msg) {
|
|
2431
|
-
if (msg)
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
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;
|
|
2436
2512
|
try {
|
|
2437
|
-
|
|
2513
|
+
isInstanceOf = target instanceof constructor;
|
|
2438
2514
|
} catch (err) {
|
|
2439
2515
|
if (err instanceof TypeError) {
|
|
2440
2516
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
@@ -2446,7 +2522,7 @@ function assertInstanceOf(constructor, msg) {
|
|
|
2446
2522
|
}
|
|
2447
2523
|
throw err;
|
|
2448
2524
|
}
|
|
2449
|
-
|
|
2525
|
+
let name = getName(constructor);
|
|
2450
2526
|
if (name == null) {
|
|
2451
2527
|
name = "an unnamed constructor";
|
|
2452
2528
|
}
|
|
@@ -2460,9 +2536,8 @@ __name(assertInstanceOf, "assertInstanceOf");
|
|
|
2460
2536
|
Assertion.addMethod("instanceof", assertInstanceOf);
|
|
2461
2537
|
Assertion.addMethod("instanceOf", assertInstanceOf);
|
|
2462
2538
|
function assertProperty(name, val, msg) {
|
|
2463
|
-
if (msg)
|
|
2464
|
-
|
|
2465
|
-
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;
|
|
2466
2541
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2467
2542
|
if (isNested) {
|
|
2468
2543
|
if (nameType !== "string") {
|
|
@@ -2495,22 +2570,16 @@ function assertProperty(name, val, msg) {
|
|
|
2495
2570
|
ssfi
|
|
2496
2571
|
);
|
|
2497
2572
|
}
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
if (isDeep)
|
|
2501
|
-
|
|
2502
|
-
if (
|
|
2503
|
-
descriptor += "own ";
|
|
2504
|
-
if (isNested)
|
|
2505
|
-
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 ";
|
|
2506
2578
|
descriptor += "property ";
|
|
2507
|
-
|
|
2508
|
-
if (isOwn)
|
|
2509
|
-
|
|
2510
|
-
else
|
|
2511
|
-
hasProperty2 = pathInfo.exists;
|
|
2512
|
-
else
|
|
2513
|
-
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);
|
|
2514
2583
|
if (!negate || arguments.length === 1) {
|
|
2515
2584
|
this.assert(
|
|
2516
2585
|
hasProperty2,
|
|
@@ -2543,11 +2612,10 @@ function assertOwnPropertyDescriptor(name, descriptor, msg) {
|
|
|
2543
2612
|
msg = descriptor;
|
|
2544
2613
|
descriptor = null;
|
|
2545
2614
|
}
|
|
2546
|
-
if (msg)
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
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");
|
|
2551
2619
|
if (actualDescriptor && descriptor) {
|
|
2552
2620
|
this.assert(
|
|
2553
2621
|
eql(descriptor, actualDescriptor),
|
|
@@ -2574,9 +2642,8 @@ function assertLengthChain() {
|
|
|
2574
2642
|
}
|
|
2575
2643
|
__name(assertLengthChain, "assertLengthChain");
|
|
2576
2644
|
function assertLength(n, msg) {
|
|
2577
|
-
if (msg)
|
|
2578
|
-
|
|
2579
|
-
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;
|
|
2580
2647
|
switch (objType) {
|
|
2581
2648
|
case "map":
|
|
2582
2649
|
case "set":
|
|
@@ -2599,9 +2666,8 @@ __name(assertLength, "assertLength");
|
|
|
2599
2666
|
Assertion.addChainableMethod("length", assertLength, assertLengthChain);
|
|
2600
2667
|
Assertion.addChainableMethod("lengthOf", assertLength, assertLengthChain);
|
|
2601
2668
|
function assertMatch(re, msg) {
|
|
2602
|
-
if (msg)
|
|
2603
|
-
|
|
2604
|
-
var obj = flag2(this, "object");
|
|
2669
|
+
if (msg) flag2(this, "message", msg);
|
|
2670
|
+
let obj = flag2(this, "object");
|
|
2605
2671
|
this.assert(
|
|
2606
2672
|
re.exec(obj),
|
|
2607
2673
|
"expected #{this} to match " + re,
|
|
@@ -2612,9 +2678,8 @@ __name(assertMatch, "assertMatch");
|
|
|
2612
2678
|
Assertion.addMethod("match", assertMatch);
|
|
2613
2679
|
Assertion.addMethod("matches", assertMatch);
|
|
2614
2680
|
Assertion.addMethod("string", function(str, msg) {
|
|
2615
|
-
if (msg)
|
|
2616
|
-
|
|
2617
|
-
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");
|
|
2618
2683
|
new Assertion(obj, flagMsg, ssfi, true).is.a("string");
|
|
2619
2684
|
this.assert(
|
|
2620
2685
|
~obj.indexOf(str),
|
|
@@ -2623,9 +2688,9 @@ Assertion.addMethod("string", function(str, msg) {
|
|
|
2623
2688
|
);
|
|
2624
2689
|
});
|
|
2625
2690
|
function assertKeys(keys) {
|
|
2626
|
-
|
|
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");
|
|
2627
2692
|
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2628
|
-
|
|
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";
|
|
2629
2694
|
if (objType === "Map" || objType === "Set") {
|
|
2630
2695
|
deepStr = isDeep ? "deeply " : "";
|
|
2631
2696
|
actual = [];
|
|
@@ -2659,7 +2724,7 @@ function assertKeys(keys) {
|
|
|
2659
2724
|
if (!keys.length) {
|
|
2660
2725
|
throw new AssertionError(flagMsg + "keys required", void 0, ssfi);
|
|
2661
2726
|
}
|
|
2662
|
-
|
|
2727
|
+
let len = keys.length, any = flag2(this, "any"), all = flag2(this, "all"), expected = keys, isEql = isDeep ? flag2(this, "eql") : (val1, val2) => val1 === val2;
|
|
2663
2728
|
if (!any && !all) {
|
|
2664
2729
|
all = true;
|
|
2665
2730
|
}
|
|
@@ -2684,7 +2749,7 @@ function assertKeys(keys) {
|
|
|
2684
2749
|
keys = keys.map(function(key) {
|
|
2685
2750
|
return inspect2(key);
|
|
2686
2751
|
});
|
|
2687
|
-
|
|
2752
|
+
let last = keys.pop();
|
|
2688
2753
|
if (all) {
|
|
2689
2754
|
str = keys.join(", ") + ", and " + last;
|
|
2690
2755
|
}
|
|
@@ -2709,9 +2774,8 @@ __name(assertKeys, "assertKeys");
|
|
|
2709
2774
|
Assertion.addMethod("keys", assertKeys);
|
|
2710
2775
|
Assertion.addMethod("key", assertKeys);
|
|
2711
2776
|
function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
2712
|
-
if (msg)
|
|
2713
|
-
|
|
2714
|
-
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;
|
|
2715
2779
|
new Assertion(obj, flagMsg, ssfi, true).is.a("function");
|
|
2716
2780
|
if (isRegExp2(errorLike) || typeof errorLike === "string") {
|
|
2717
2781
|
errMsgMatcher = errorLike;
|
|
@@ -2725,12 +2789,12 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
2725
2789
|
errorWasThrown = true;
|
|
2726
2790
|
caughtErr = err;
|
|
2727
2791
|
}
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2792
|
+
let everyArgIsUndefined = errorLike === void 0 && errMsgMatcher === void 0;
|
|
2793
|
+
let everyArgIsDefined = Boolean(errorLike && errMsgMatcher);
|
|
2794
|
+
let errorLikeFail = false;
|
|
2795
|
+
let errMsgMatcherFail = false;
|
|
2732
2796
|
if (everyArgIsUndefined || !everyArgIsUndefined && !negate) {
|
|
2733
|
-
|
|
2797
|
+
let errorLikeString = "an error";
|
|
2734
2798
|
if (errorLike instanceof Error) {
|
|
2735
2799
|
errorLikeString = "#{exp}";
|
|
2736
2800
|
} else if (errorLike) {
|
|
@@ -2757,7 +2821,7 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
2757
2821
|
}
|
|
2758
2822
|
if (errorLike && caughtErr) {
|
|
2759
2823
|
if (errorLike instanceof Error) {
|
|
2760
|
-
|
|
2824
|
+
let isCompatibleInstance = check_error_exports.compatibleInstance(
|
|
2761
2825
|
caughtErr,
|
|
2762
2826
|
errorLike
|
|
2763
2827
|
);
|
|
@@ -2775,7 +2839,7 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
2775
2839
|
}
|
|
2776
2840
|
}
|
|
2777
2841
|
}
|
|
2778
|
-
|
|
2842
|
+
let isCompatibleConstructor = check_error_exports.compatibleConstructor(
|
|
2779
2843
|
caughtErr,
|
|
2780
2844
|
errorLike
|
|
2781
2845
|
);
|
|
@@ -2794,11 +2858,11 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
2794
2858
|
}
|
|
2795
2859
|
}
|
|
2796
2860
|
if (caughtErr && errMsgMatcher !== void 0 && errMsgMatcher !== null) {
|
|
2797
|
-
|
|
2861
|
+
let placeholder = "including";
|
|
2798
2862
|
if (isRegExp2(errMsgMatcher)) {
|
|
2799
2863
|
placeholder = "matching";
|
|
2800
2864
|
}
|
|
2801
|
-
|
|
2865
|
+
let isCompatibleMessage = check_error_exports.compatibleMessage(
|
|
2802
2866
|
caughtErr,
|
|
2803
2867
|
errMsgMatcher
|
|
2804
2868
|
);
|
|
@@ -2832,9 +2896,8 @@ Assertion.addMethod("throw", assertThrows);
|
|
|
2832
2896
|
Assertion.addMethod("throws", assertThrows);
|
|
2833
2897
|
Assertion.addMethod("Throw", assertThrows);
|
|
2834
2898
|
function respondTo(method, msg) {
|
|
2835
|
-
if (msg)
|
|
2836
|
-
|
|
2837
|
-
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];
|
|
2838
2901
|
this.assert(
|
|
2839
2902
|
"function" === typeof context,
|
|
2840
2903
|
"expected #{this} to respond to " + inspect2(method),
|
|
@@ -2848,10 +2911,9 @@ Assertion.addProperty("itself", function() {
|
|
|
2848
2911
|
flag2(this, "itself", true);
|
|
2849
2912
|
});
|
|
2850
2913
|
function satisfy(matcher, msg) {
|
|
2851
|
-
if (msg)
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
var result = matcher(obj);
|
|
2914
|
+
if (msg) flag2(this, "message", msg);
|
|
2915
|
+
let obj = flag2(this, "object");
|
|
2916
|
+
let result = matcher(obj);
|
|
2855
2917
|
this.assert(
|
|
2856
2918
|
result,
|
|
2857
2919
|
"expected #{this} to satisfy " + objDisplay(matcher),
|
|
@@ -2864,25 +2926,26 @@ __name(satisfy, "satisfy");
|
|
|
2864
2926
|
Assertion.addMethod("satisfy", satisfy);
|
|
2865
2927
|
Assertion.addMethod("satisfies", satisfy);
|
|
2866
2928
|
function closeTo(expected, delta, msg) {
|
|
2867
|
-
if (msg)
|
|
2868
|
-
|
|
2869
|
-
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");
|
|
2870
2931
|
new Assertion(obj, flagMsg, ssfi, true).is.numeric;
|
|
2871
2932
|
let message = "A `delta` value is required for `closeTo`";
|
|
2872
|
-
if (delta == void 0)
|
|
2933
|
+
if (delta == void 0) {
|
|
2873
2934
|
throw new AssertionError(
|
|
2874
2935
|
flagMsg ? `${flagMsg}: ${message}` : message,
|
|
2875
2936
|
void 0,
|
|
2876
2937
|
ssfi
|
|
2877
2938
|
);
|
|
2939
|
+
}
|
|
2878
2940
|
new Assertion(delta, flagMsg, ssfi, true).is.numeric;
|
|
2879
2941
|
message = "A `expected` value is required for `closeTo`";
|
|
2880
|
-
if (expected == void 0)
|
|
2942
|
+
if (expected == void 0) {
|
|
2881
2943
|
throw new AssertionError(
|
|
2882
2944
|
flagMsg ? `${flagMsg}: ${message}` : message,
|
|
2883
2945
|
void 0,
|
|
2884
2946
|
ssfi
|
|
2885
2947
|
);
|
|
2948
|
+
}
|
|
2886
2949
|
new Assertion(expected, flagMsg, ssfi, true).is.numeric;
|
|
2887
2950
|
const abs = /* @__PURE__ */ __name((x) => x < 0n ? -x : x, "abs");
|
|
2888
2951
|
const strip = /* @__PURE__ */ __name((number) => parseFloat(parseFloat(number).toPrecision(12)), "strip");
|
|
@@ -2899,40 +2962,33 @@ function isSubsetOf(_subset, _superset, cmp, contains, ordered) {
|
|
|
2899
2962
|
let superset = Array.from(_superset);
|
|
2900
2963
|
let subset = Array.from(_subset);
|
|
2901
2964
|
if (!contains) {
|
|
2902
|
-
if (subset.length !== superset.length)
|
|
2903
|
-
return false;
|
|
2965
|
+
if (subset.length !== superset.length) return false;
|
|
2904
2966
|
superset = superset.slice();
|
|
2905
2967
|
}
|
|
2906
2968
|
return subset.every(function(elem, idx) {
|
|
2907
|
-
if (ordered)
|
|
2908
|
-
return cmp ? cmp(elem, superset[idx]) : elem === superset[idx];
|
|
2969
|
+
if (ordered) return cmp ? cmp(elem, superset[idx]) : elem === superset[idx];
|
|
2909
2970
|
if (!cmp) {
|
|
2910
|
-
|
|
2911
|
-
if (matchIdx === -1)
|
|
2912
|
-
|
|
2913
|
-
if (!contains)
|
|
2914
|
-
superset.splice(matchIdx, 1);
|
|
2971
|
+
let matchIdx = superset.indexOf(elem);
|
|
2972
|
+
if (matchIdx === -1) return false;
|
|
2973
|
+
if (!contains) superset.splice(matchIdx, 1);
|
|
2915
2974
|
return true;
|
|
2916
2975
|
}
|
|
2917
|
-
return superset.some(function(elem2,
|
|
2918
|
-
if (!cmp(elem, elem2))
|
|
2919
|
-
|
|
2920
|
-
if (!contains)
|
|
2921
|
-
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);
|
|
2922
2979
|
return true;
|
|
2923
2980
|
});
|
|
2924
2981
|
});
|
|
2925
2982
|
}
|
|
2926
2983
|
__name(isSubsetOf, "isSubsetOf");
|
|
2927
2984
|
Assertion.addMethod("members", function(subset, msg) {
|
|
2928
|
-
if (msg)
|
|
2929
|
-
|
|
2930
|
-
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");
|
|
2931
2987
|
new Assertion(obj, flagMsg, ssfi, true).to.be.iterable;
|
|
2932
2988
|
new Assertion(subset, flagMsg, ssfi, true).to.be.iterable;
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2989
|
+
let contains = flag2(this, "contains");
|
|
2990
|
+
let ordered = flag2(this, "ordered");
|
|
2991
|
+
let subject, failMsg, failNegateMsg;
|
|
2936
2992
|
if (contains) {
|
|
2937
2993
|
subject = ordered ? "an ordered superset" : "a superset";
|
|
2938
2994
|
failMsg = "expected #{this} to be " + subject + " of #{exp}";
|
|
@@ -2942,7 +2998,7 @@ Assertion.addMethod("members", function(subset, msg) {
|
|
|
2942
2998
|
failMsg = "expected #{this} to have the same " + subject + " as #{exp}";
|
|
2943
2999
|
failNegateMsg = "expected #{this} to not have the same " + subject + " as #{exp}";
|
|
2944
3000
|
}
|
|
2945
|
-
|
|
3001
|
+
let cmp = flag2(this, "deep") ? flag2(this, "eql") : void 0;
|
|
2946
3002
|
this.assert(
|
|
2947
3003
|
isSubsetOf(subset, obj, cmp, contains, ordered),
|
|
2948
3004
|
failMsg,
|
|
@@ -2953,9 +3009,8 @@ Assertion.addMethod("members", function(subset, msg) {
|
|
|
2953
3009
|
);
|
|
2954
3010
|
});
|
|
2955
3011
|
Assertion.addProperty("iterable", function(msg) {
|
|
2956
|
-
if (msg)
|
|
2957
|
-
|
|
2958
|
-
var obj = flag2(this, "object");
|
|
3012
|
+
if (msg) flag2(this, "message", msg);
|
|
3013
|
+
let obj = flag2(this, "object");
|
|
2959
3014
|
this.assert(
|
|
2960
3015
|
obj != void 0 && obj[Symbol.iterator],
|
|
2961
3016
|
"expected #{this} to be an iterable",
|
|
@@ -2964,9 +3019,8 @@ Assertion.addProperty("iterable", function(msg) {
|
|
|
2964
3019
|
);
|
|
2965
3020
|
});
|
|
2966
3021
|
function oneOf(list, msg) {
|
|
2967
|
-
if (msg)
|
|
2968
|
-
|
|
2969
|
-
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");
|
|
2970
3024
|
new Assertion(list, flagMsg, ssfi, true).to.be.an("array");
|
|
2971
3025
|
if (contains) {
|
|
2972
3026
|
this.assert(
|
|
@@ -3003,11 +3057,10 @@ function oneOf(list, msg) {
|
|
|
3003
3057
|
__name(oneOf, "oneOf");
|
|
3004
3058
|
Assertion.addMethod("oneOf", oneOf);
|
|
3005
3059
|
function assertChanges(subject, prop, msg) {
|
|
3006
|
-
if (msg)
|
|
3007
|
-
|
|
3008
|
-
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");
|
|
3009
3062
|
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
3010
|
-
|
|
3063
|
+
let initial;
|
|
3011
3064
|
if (!prop) {
|
|
3012
3065
|
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
3013
3066
|
initial = subject();
|
|
@@ -3016,8 +3069,8 @@ function assertChanges(subject, prop, msg) {
|
|
|
3016
3069
|
initial = subject[prop];
|
|
3017
3070
|
}
|
|
3018
3071
|
fn();
|
|
3019
|
-
|
|
3020
|
-
|
|
3072
|
+
let final = prop === void 0 || prop === null ? subject() : subject[prop];
|
|
3073
|
+
let msgObj = prop === void 0 || prop === null ? initial : "." + prop;
|
|
3021
3074
|
flag2(this, "deltaMsgObj", msgObj);
|
|
3022
3075
|
flag2(this, "initialDeltaValue", initial);
|
|
3023
3076
|
flag2(this, "finalDeltaValue", final);
|
|
@@ -3033,11 +3086,10 @@ __name(assertChanges, "assertChanges");
|
|
|
3033
3086
|
Assertion.addMethod("change", assertChanges);
|
|
3034
3087
|
Assertion.addMethod("changes", assertChanges);
|
|
3035
3088
|
function assertIncreases(subject, prop, msg) {
|
|
3036
|
-
if (msg)
|
|
3037
|
-
|
|
3038
|
-
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");
|
|
3039
3091
|
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
3040
|
-
|
|
3092
|
+
let initial;
|
|
3041
3093
|
if (!prop) {
|
|
3042
3094
|
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
3043
3095
|
initial = subject();
|
|
@@ -3047,8 +3099,8 @@ function assertIncreases(subject, prop, msg) {
|
|
|
3047
3099
|
}
|
|
3048
3100
|
new Assertion(initial, flagMsg, ssfi, true).is.a("number");
|
|
3049
3101
|
fn();
|
|
3050
|
-
|
|
3051
|
-
|
|
3102
|
+
let final = prop === void 0 || prop === null ? subject() : subject[prop];
|
|
3103
|
+
let msgObj = prop === void 0 || prop === null ? initial : "." + prop;
|
|
3052
3104
|
flag2(this, "deltaMsgObj", msgObj);
|
|
3053
3105
|
flag2(this, "initialDeltaValue", initial);
|
|
3054
3106
|
flag2(this, "finalDeltaValue", final);
|
|
@@ -3064,11 +3116,10 @@ __name(assertIncreases, "assertIncreases");
|
|
|
3064
3116
|
Assertion.addMethod("increase", assertIncreases);
|
|
3065
3117
|
Assertion.addMethod("increases", assertIncreases);
|
|
3066
3118
|
function assertDecreases(subject, prop, msg) {
|
|
3067
|
-
if (msg)
|
|
3068
|
-
|
|
3069
|
-
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");
|
|
3070
3121
|
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
3071
|
-
|
|
3122
|
+
let initial;
|
|
3072
3123
|
if (!prop) {
|
|
3073
3124
|
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
3074
3125
|
initial = subject();
|
|
@@ -3078,8 +3129,8 @@ function assertDecreases(subject, prop, msg) {
|
|
|
3078
3129
|
}
|
|
3079
3130
|
new Assertion(initial, flagMsg, ssfi, true).is.a("number");
|
|
3080
3131
|
fn();
|
|
3081
|
-
|
|
3082
|
-
|
|
3132
|
+
let final = prop === void 0 || prop === null ? subject() : subject[prop];
|
|
3133
|
+
let msgObj = prop === void 0 || prop === null ? initial : "." + prop;
|
|
3083
3134
|
flag2(this, "deltaMsgObj", msgObj);
|
|
3084
3135
|
flag2(this, "initialDeltaValue", initial);
|
|
3085
3136
|
flag2(this, "finalDeltaValue", final);
|
|
@@ -3095,14 +3146,13 @@ __name(assertDecreases, "assertDecreases");
|
|
|
3095
3146
|
Assertion.addMethod("decrease", assertDecreases);
|
|
3096
3147
|
Assertion.addMethod("decreases", assertDecreases);
|
|
3097
3148
|
function assertDelta(delta, msg) {
|
|
3098
|
-
if (msg)
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
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;
|
|
3106
3156
|
if (behavior === "change") {
|
|
3107
3157
|
expression = Math.abs(final - initial) === Math.abs(delta);
|
|
3108
3158
|
} else {
|
|
@@ -3117,8 +3167,8 @@ function assertDelta(delta, msg) {
|
|
|
3117
3167
|
__name(assertDelta, "assertDelta");
|
|
3118
3168
|
Assertion.addMethod("by", assertDelta);
|
|
3119
3169
|
Assertion.addProperty("extensible", function() {
|
|
3120
|
-
|
|
3121
|
-
|
|
3170
|
+
let obj = flag2(this, "object");
|
|
3171
|
+
let isExtensible = obj === Object(obj) && Object.isExtensible(obj);
|
|
3122
3172
|
this.assert(
|
|
3123
3173
|
isExtensible,
|
|
3124
3174
|
"expected #{this} to be extensible",
|
|
@@ -3126,8 +3176,8 @@ Assertion.addProperty("extensible", function() {
|
|
|
3126
3176
|
);
|
|
3127
3177
|
});
|
|
3128
3178
|
Assertion.addProperty("sealed", function() {
|
|
3129
|
-
|
|
3130
|
-
|
|
3179
|
+
let obj = flag2(this, "object");
|
|
3180
|
+
let isSealed = obj === Object(obj) ? Object.isSealed(obj) : true;
|
|
3131
3181
|
this.assert(
|
|
3132
3182
|
isSealed,
|
|
3133
3183
|
"expected #{this} to be sealed",
|
|
@@ -3135,8 +3185,8 @@ Assertion.addProperty("sealed", function() {
|
|
|
3135
3185
|
);
|
|
3136
3186
|
});
|
|
3137
3187
|
Assertion.addProperty("frozen", function() {
|
|
3138
|
-
|
|
3139
|
-
|
|
3188
|
+
let obj = flag2(this, "object");
|
|
3189
|
+
let isFrozen = obj === Object(obj) ? Object.isFrozen(obj) : true;
|
|
3140
3190
|
this.assert(
|
|
3141
3191
|
isFrozen,
|
|
3142
3192
|
"expected #{this} to be frozen",
|
|
@@ -3144,7 +3194,7 @@ Assertion.addProperty("frozen", function() {
|
|
|
3144
3194
|
);
|
|
3145
3195
|
});
|
|
3146
3196
|
Assertion.addProperty("finite", function(_msg) {
|
|
3147
|
-
|
|
3197
|
+
let obj = flag2(this, "object");
|
|
3148
3198
|
this.assert(
|
|
3149
3199
|
typeof obj === "number" && isFinite(obj),
|
|
3150
3200
|
"expected #{this} to be a finite number",
|
|
@@ -3182,8 +3232,8 @@ function compareSubset(expected, actual) {
|
|
|
3182
3232
|
}
|
|
3183
3233
|
}
|
|
3184
3234
|
return Object.keys(expected).every(function(key) {
|
|
3185
|
-
|
|
3186
|
-
|
|
3235
|
+
let expectedValue = expected[key];
|
|
3236
|
+
let actualValue = actual[key];
|
|
3187
3237
|
if (typeof expectedValue === "object" && expectedValue !== null && actualValue !== null) {
|
|
3188
3238
|
return compareSubset(expectedValue, actualValue);
|
|
3189
3239
|
}
|
|
@@ -3257,7 +3307,7 @@ function loadShould() {
|
|
|
3257
3307
|
get: shouldGetter,
|
|
3258
3308
|
configurable: true
|
|
3259
3309
|
});
|
|
3260
|
-
|
|
3310
|
+
let should2 = {};
|
|
3261
3311
|
should2.fail = function(actual, expected, message, operator) {
|
|
3262
3312
|
if (arguments.length < 2) {
|
|
3263
3313
|
message = actual;
|
|
@@ -3303,7 +3353,7 @@ var Should = loadShould;
|
|
|
3303
3353
|
|
|
3304
3354
|
// lib/chai/interface/assert.js
|
|
3305
3355
|
function assert(express, errmsg) {
|
|
3306
|
-
|
|
3356
|
+
let test2 = new Assertion(null, null, assert, true);
|
|
3307
3357
|
test2.assert(express, errmsg, "[ negation message unavailable ]");
|
|
3308
3358
|
}
|
|
3309
3359
|
__name(assert, "assert");
|
|
@@ -3330,7 +3380,7 @@ assert.isNotOk = function(val, msg) {
|
|
|
3330
3380
|
new Assertion(val, msg, assert.isNotOk, true).is.not.ok;
|
|
3331
3381
|
};
|
|
3332
3382
|
assert.equal = function(act, exp, msg) {
|
|
3333
|
-
|
|
3383
|
+
let test2 = new Assertion(act, msg, assert.equal, true);
|
|
3334
3384
|
test2.assert(
|
|
3335
3385
|
exp == flag(test2, "object"),
|
|
3336
3386
|
"expected #{this} to equal #{exp}",
|
|
@@ -3341,7 +3391,7 @@ assert.equal = function(act, exp, msg) {
|
|
|
3341
3391
|
);
|
|
3342
3392
|
};
|
|
3343
3393
|
assert.notEqual = function(act, exp, msg) {
|
|
3344
|
-
|
|
3394
|
+
let test2 = new Assertion(act, msg, assert.notEqual, true);
|
|
3345
3395
|
test2.assert(
|
|
3346
3396
|
exp != flag(test2, "object"),
|
|
3347
3397
|
"expected #{this} to not equal #{exp}",
|
|
@@ -3698,7 +3748,7 @@ assert.throws = function(fn, errorLike, errMsgMatcher, msg) {
|
|
|
3698
3748
|
errMsgMatcher = errorLike;
|
|
3699
3749
|
errorLike = null;
|
|
3700
3750
|
}
|
|
3701
|
-
|
|
3751
|
+
let assertErr = new Assertion(fn, msg, assert.throws, true).to.throw(
|
|
3702
3752
|
errorLike,
|
|
3703
3753
|
errMsgMatcher
|
|
3704
3754
|
);
|
|
@@ -3715,7 +3765,7 @@ assert.doesNotThrow = function(fn, errorLike, errMsgMatcher, message) {
|
|
|
3715
3765
|
);
|
|
3716
3766
|
};
|
|
3717
3767
|
assert.operator = function(val, operator, val2, msg) {
|
|
3718
|
-
|
|
3768
|
+
let ok;
|
|
3719
3769
|
switch (operator) {
|
|
3720
3770
|
case "==":
|
|
3721
3771
|
ok = val == val2;
|
|
@@ -3749,7 +3799,7 @@ assert.operator = function(val, operator, val2, msg) {
|
|
|
3749
3799
|
assert.operator
|
|
3750
3800
|
);
|
|
3751
3801
|
}
|
|
3752
|
-
|
|
3802
|
+
let test2 = new Assertion(ok, msg, assert.operator, true);
|
|
3753
3803
|
test2.assert(
|
|
3754
3804
|
true === flag(test2, "object"),
|
|
3755
3805
|
"expected " + inspect2(val) + " to be " + operator + " " + inspect2(val2),
|
|
@@ -3903,7 +3953,7 @@ assert.changes = function(fn, obj, prop, msg) {
|
|
|
3903
3953
|
};
|
|
3904
3954
|
assert.changesBy = function(fn, obj, prop, delta, msg) {
|
|
3905
3955
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
3906
|
-
|
|
3956
|
+
let tmpMsg = delta;
|
|
3907
3957
|
delta = prop;
|
|
3908
3958
|
msg = tmpMsg;
|
|
3909
3959
|
} else if (arguments.length === 3) {
|
|
@@ -3924,7 +3974,7 @@ assert.doesNotChange = function(fn, obj, prop, msg) {
|
|
|
3924
3974
|
};
|
|
3925
3975
|
assert.changesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
3926
3976
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
3927
|
-
|
|
3977
|
+
let tmpMsg = delta;
|
|
3928
3978
|
delta = prop;
|
|
3929
3979
|
msg = tmpMsg;
|
|
3930
3980
|
} else if (arguments.length === 3) {
|
|
@@ -3942,7 +3992,7 @@ assert.increases = function(fn, obj, prop, msg) {
|
|
|
3942
3992
|
};
|
|
3943
3993
|
assert.increasesBy = function(fn, obj, prop, delta, msg) {
|
|
3944
3994
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
3945
|
-
|
|
3995
|
+
let tmpMsg = delta;
|
|
3946
3996
|
delta = prop;
|
|
3947
3997
|
msg = tmpMsg;
|
|
3948
3998
|
} else if (arguments.length === 3) {
|
|
@@ -3963,7 +4013,7 @@ assert.doesNotIncrease = function(fn, obj, prop, msg) {
|
|
|
3963
4013
|
};
|
|
3964
4014
|
assert.increasesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
3965
4015
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
3966
|
-
|
|
4016
|
+
let tmpMsg = delta;
|
|
3967
4017
|
delta = prop;
|
|
3968
4018
|
msg = tmpMsg;
|
|
3969
4019
|
} else if (arguments.length === 3) {
|
|
@@ -3981,7 +4031,7 @@ assert.decreases = function(fn, obj, prop, msg) {
|
|
|
3981
4031
|
};
|
|
3982
4032
|
assert.decreasesBy = function(fn, obj, prop, delta, msg) {
|
|
3983
4033
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
3984
|
-
|
|
4034
|
+
let tmpMsg = delta;
|
|
3985
4035
|
delta = prop;
|
|
3986
4036
|
msg = tmpMsg;
|
|
3987
4037
|
} else if (arguments.length === 3) {
|
|
@@ -4002,7 +4052,7 @@ assert.doesNotDecrease = function(fn, obj, prop, msg) {
|
|
|
4002
4052
|
};
|
|
4003
4053
|
assert.doesNotDecreaseBy = function(fn, obj, prop, delta, msg) {
|
|
4004
4054
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
4005
|
-
|
|
4055
|
+
let tmpMsg = delta;
|
|
4006
4056
|
delta = prop;
|
|
4007
4057
|
msg = tmpMsg;
|
|
4008
4058
|
} else if (arguments.length === 3) {
|
|
@@ -4013,7 +4063,7 @@ assert.doesNotDecreaseBy = function(fn, obj, prop, delta, msg) {
|
|
|
4013
4063
|
};
|
|
4014
4064
|
assert.decreasesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
4015
4065
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
4016
|
-
|
|
4066
|
+
let tmpMsg = delta;
|
|
4017
4067
|
delta = prop;
|
|
4018
4068
|
msg = tmpMsg;
|
|
4019
4069
|
} else if (arguments.length === 3) {
|