chai 5.1.2 → 5.2.0
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/chai.js +520 -220
- package/eslint.config.js +14 -0
- package/lib/chai/assertion.js +37 -21
- package/lib/chai/config.js +0 -2
- package/lib/chai/core/assertions.js +698 -475
- package/lib/chai/interface/assert.js +425 -248
- package/lib/chai/interface/expect.js +11 -7
- package/lib/chai/interface/should.js +26 -20
- package/lib/chai/utils/addChainableMethod.js +66 -67
- package/lib/chai/utils/addLengthGuard.js +18 -5
- package/lib/chai/utils/addMethod.js +1 -2
- package/lib/chai/utils/addProperty.js +27 -28
- package/lib/chai/utils/expectTypes.js +15 -7
- package/lib/chai/utils/getMessage.js +16 -10
- package/lib/chai/utils/index.js +8 -2
- package/lib/chai/utils/inspect.js +2 -2
- 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 +10 -9
- package/lib/chai/utils/overwriteMethod.js +4 -5
- package/lib/chai/utils/overwriteProperty.js +38 -39
- package/lib/chai/utils/proxify.js +31 -21
- package/lib/chai/utils/test.js +2 -2
- package/lib/chai/utils/transferFlags.js +7 -2
- package/lib/chai/utils/type-detect.js +1 -1
- package/lib/chai.js +2 -1
- package/package.json +11 -5
- 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
|
@@ -1388,21 +1388,29 @@ function Assertion(obj, msg, ssfi, lockSsfi) {
|
|
|
1388
1388
|
__name(Assertion, "Assertion");
|
|
1389
1389
|
Object.defineProperty(Assertion, "includeStack", {
|
|
1390
1390
|
get: function() {
|
|
1391
|
-
console.warn(
|
|
1391
|
+
console.warn(
|
|
1392
|
+
"Assertion.includeStack is deprecated, use chai.config.includeStack instead."
|
|
1393
|
+
);
|
|
1392
1394
|
return config.includeStack;
|
|
1393
1395
|
},
|
|
1394
1396
|
set: function(value) {
|
|
1395
|
-
console.warn(
|
|
1397
|
+
console.warn(
|
|
1398
|
+
"Assertion.includeStack is deprecated, use chai.config.includeStack instead."
|
|
1399
|
+
);
|
|
1396
1400
|
config.includeStack = value;
|
|
1397
1401
|
}
|
|
1398
1402
|
});
|
|
1399
1403
|
Object.defineProperty(Assertion, "showDiff", {
|
|
1400
1404
|
get: function() {
|
|
1401
|
-
console.warn(
|
|
1405
|
+
console.warn(
|
|
1406
|
+
"Assertion.showDiff is deprecated, use chai.config.showDiff instead."
|
|
1407
|
+
);
|
|
1402
1408
|
return config.showDiff;
|
|
1403
1409
|
},
|
|
1404
1410
|
set: function(value) {
|
|
1405
|
-
console.warn(
|
|
1411
|
+
console.warn(
|
|
1412
|
+
"Assertion.showDiff is deprecated, use chai.config.showDiff instead."
|
|
1413
|
+
);
|
|
1406
1414
|
config.showDiff = value;
|
|
1407
1415
|
}
|
|
1408
1416
|
});
|
|
@@ -1451,18 +1459,14 @@ Assertion.prototype.assert = function(expr, msg, negateMsg, expected, _actual, s
|
|
|
1451
1459
|
);
|
|
1452
1460
|
}
|
|
1453
1461
|
};
|
|
1454
|
-
Object.defineProperty(
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
},
|
|
1461
|
-
set: function(val) {
|
|
1462
|
-
flag(this, "object", val);
|
|
1463
|
-
}
|
|
1462
|
+
Object.defineProperty(Assertion.prototype, "_obj", {
|
|
1463
|
+
get: function() {
|
|
1464
|
+
return flag(this, "object");
|
|
1465
|
+
},
|
|
1466
|
+
set: function(val) {
|
|
1467
|
+
flag(this, "object", val);
|
|
1464
1468
|
}
|
|
1465
|
-
);
|
|
1469
|
+
});
|
|
1466
1470
|
|
|
1467
1471
|
// lib/chai/utils/isProxyEnabled.js
|
|
1468
1472
|
function isProxyEnabled() {
|
|
@@ -1474,24 +1478,20 @@ __name(isProxyEnabled, "isProxyEnabled");
|
|
|
1474
1478
|
function addProperty(ctx, name, getter) {
|
|
1475
1479
|
getter = getter === void 0 ? function() {
|
|
1476
1480
|
} : getter;
|
|
1477
|
-
Object.defineProperty(
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
}, "propertyGetter"),
|
|
1492
|
-
configurable: true
|
|
1493
|
-
}
|
|
1494
|
-
);
|
|
1481
|
+
Object.defineProperty(ctx, name, {
|
|
1482
|
+
get: /* @__PURE__ */ __name(function propertyGetter() {
|
|
1483
|
+
if (!isProxyEnabled() && !flag(this, "lockSsfi")) {
|
|
1484
|
+
flag(this, "ssfi", propertyGetter);
|
|
1485
|
+
}
|
|
1486
|
+
var result = getter.call(this);
|
|
1487
|
+
if (result !== void 0)
|
|
1488
|
+
return result;
|
|
1489
|
+
var newAssertion = new Assertion();
|
|
1490
|
+
transferFlags(this, newAssertion);
|
|
1491
|
+
return newAssertion;
|
|
1492
|
+
}, "propertyGetter"),
|
|
1493
|
+
configurable: true
|
|
1494
|
+
});
|
|
1495
1495
|
}
|
|
1496
1496
|
__name(addProperty, "addProperty");
|
|
1497
1497
|
|
|
@@ -1504,9 +1504,13 @@ function addLengthGuard(fn, assertionName, isChainable) {
|
|
|
1504
1504
|
Object.defineProperty(fn, "length", {
|
|
1505
1505
|
get: function() {
|
|
1506
1506
|
if (isChainable) {
|
|
1507
|
-
throw Error(
|
|
1507
|
+
throw Error(
|
|
1508
|
+
"Invalid Chai property: " + assertionName + '.length. Due to a compatibility issue, "length" cannot directly follow "' + assertionName + '". Use "' + assertionName + '.lengthOf" instead.'
|
|
1509
|
+
);
|
|
1508
1510
|
}
|
|
1509
|
-
throw Error(
|
|
1511
|
+
throw Error(
|
|
1512
|
+
"Invalid Chai property: " + assertionName + '.length. See docs for proper usage of "' + assertionName + '".'
|
|
1513
|
+
);
|
|
1510
1514
|
}
|
|
1511
1515
|
});
|
|
1512
1516
|
return fn;
|
|
@@ -1540,17 +1544,19 @@ function proxify(obj, nonChainableMethodName) {
|
|
|
1540
1544
|
get: /* @__PURE__ */ __name(function proxyGetter(target, property) {
|
|
1541
1545
|
if (typeof property === "string" && config.proxyExcludedKeys.indexOf(property) === -1 && !Reflect.has(target, property)) {
|
|
1542
1546
|
if (nonChainableMethodName) {
|
|
1543
|
-
throw Error(
|
|
1547
|
+
throw Error(
|
|
1548
|
+
"Invalid Chai property: " + nonChainableMethodName + "." + property + '. See docs for proper usage of "' + nonChainableMethodName + '".'
|
|
1549
|
+
);
|
|
1544
1550
|
}
|
|
1545
1551
|
var suggestion = null;
|
|
1546
1552
|
var suggestionDistance = 4;
|
|
1547
1553
|
getProperties(target).forEach(function(prop) {
|
|
1548
|
-
if (
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
);
|
|
1554
|
+
if (
|
|
1555
|
+
// we actually mean to check `Object.prototype` here
|
|
1556
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
1557
|
+
!Object.prototype.hasOwnProperty(prop) && builtins.indexOf(prop) === -1
|
|
1558
|
+
) {
|
|
1559
|
+
var dist = stringDistanceCapped(property, prop, suggestionDistance);
|
|
1554
1560
|
if (dist < suggestionDistance) {
|
|
1555
1561
|
suggestion = prop;
|
|
1556
1562
|
suggestionDistance = dist;
|
|
@@ -1558,7 +1564,9 @@ function proxify(obj, nonChainableMethodName) {
|
|
|
1558
1564
|
}
|
|
1559
1565
|
});
|
|
1560
1566
|
if (suggestion !== null) {
|
|
1561
|
-
throw Error(
|
|
1567
|
+
throw Error(
|
|
1568
|
+
"Invalid Chai property: " + property + '. Did you mean "' + suggestion + '"?'
|
|
1569
|
+
);
|
|
1562
1570
|
} else {
|
|
1563
1571
|
throw Error("Invalid Chai property: " + property);
|
|
1564
1572
|
}
|
|
@@ -1576,16 +1584,16 @@ function stringDistanceCapped(strA, strB, cap) {
|
|
|
1576
1584
|
return cap;
|
|
1577
1585
|
}
|
|
1578
1586
|
var memo = [];
|
|
1579
|
-
for (
|
|
1587
|
+
for (let i = 0; i <= strA.length; i++) {
|
|
1580
1588
|
memo[i] = Array(strB.length + 1).fill(0);
|
|
1581
1589
|
memo[i][0] = i;
|
|
1582
1590
|
}
|
|
1583
|
-
for (
|
|
1591
|
+
for (let j = 0; j < strB.length; j++) {
|
|
1584
1592
|
memo[0][j] = j;
|
|
1585
1593
|
}
|
|
1586
|
-
for (
|
|
1594
|
+
for (let i = 1; i <= strA.length; i++) {
|
|
1587
1595
|
var ch = strA.charCodeAt(i - 1);
|
|
1588
|
-
for (
|
|
1596
|
+
for (let j = 1; j <= strB.length; j++) {
|
|
1589
1597
|
if (Math.abs(i - j) >= cap) {
|
|
1590
1598
|
memo[i][j] = cap;
|
|
1591
1599
|
continue;
|
|
@@ -1625,28 +1633,24 @@ function overwriteProperty(ctx, name, getter) {
|
|
|
1625
1633
|
}, "_super");
|
|
1626
1634
|
if (_get && "function" === typeof _get.get)
|
|
1627
1635
|
_super = _get.get;
|
|
1628
|
-
Object.defineProperty(
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
}, "overwritingPropertyGetter"),
|
|
1647
|
-
configurable: true
|
|
1648
|
-
}
|
|
1649
|
-
);
|
|
1636
|
+
Object.defineProperty(ctx, name, {
|
|
1637
|
+
get: /* @__PURE__ */ __name(function overwritingPropertyGetter() {
|
|
1638
|
+
if (!isProxyEnabled() && !flag(this, "lockSsfi")) {
|
|
1639
|
+
flag(this, "ssfi", overwritingPropertyGetter);
|
|
1640
|
+
}
|
|
1641
|
+
var origLockSsfi = flag(this, "lockSsfi");
|
|
1642
|
+
flag(this, "lockSsfi", true);
|
|
1643
|
+
var result = getter(_super).call(this);
|
|
1644
|
+
flag(this, "lockSsfi", origLockSsfi);
|
|
1645
|
+
if (result !== void 0) {
|
|
1646
|
+
return result;
|
|
1647
|
+
}
|
|
1648
|
+
var newAssertion = new Assertion();
|
|
1649
|
+
transferFlags(this, newAssertion);
|
|
1650
|
+
return newAssertion;
|
|
1651
|
+
}, "overwritingPropertyGetter"),
|
|
1652
|
+
configurable: true
|
|
1653
|
+
});
|
|
1650
1654
|
}
|
|
1651
1655
|
__name(overwriteProperty, "overwriteProperty");
|
|
1652
1656
|
|
|
@@ -1702,46 +1706,42 @@ function addChainableMethod(ctx, name, method, chainingBehavior) {
|
|
|
1702
1706
|
ctx.__methods = {};
|
|
1703
1707
|
}
|
|
1704
1708
|
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
|
-
});
|
|
1709
|
+
Object.defineProperty(ctx, name, {
|
|
1710
|
+
get: /* @__PURE__ */ __name(function chainableMethodGetter() {
|
|
1711
|
+
chainableBehavior.chainingBehavior.call(this);
|
|
1712
|
+
var chainableMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
1713
|
+
if (!flag(this, "lockSsfi")) {
|
|
1714
|
+
flag(this, "ssfi", chainableMethodWrapper);
|
|
1738
1715
|
}
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1716
|
+
var result = chainableBehavior.method.apply(this, arguments);
|
|
1717
|
+
if (result !== void 0) {
|
|
1718
|
+
return result;
|
|
1719
|
+
}
|
|
1720
|
+
var newAssertion = new Assertion();
|
|
1721
|
+
transferFlags(this, newAssertion);
|
|
1722
|
+
return newAssertion;
|
|
1723
|
+
}, "chainableMethodWrapper");
|
|
1724
|
+
addLengthGuard(chainableMethodWrapper, name, true);
|
|
1725
|
+
if (canSetPrototype) {
|
|
1726
|
+
var prototype = Object.create(this);
|
|
1727
|
+
prototype.call = call;
|
|
1728
|
+
prototype.apply = apply;
|
|
1729
|
+
Object.setPrototypeOf(chainableMethodWrapper, prototype);
|
|
1730
|
+
} else {
|
|
1731
|
+
var asserterNames = Object.getOwnPropertyNames(ctx);
|
|
1732
|
+
asserterNames.forEach(function(asserterName) {
|
|
1733
|
+
if (excludeNames.indexOf(asserterName) !== -1) {
|
|
1734
|
+
return;
|
|
1735
|
+
}
|
|
1736
|
+
var pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
|
|
1737
|
+
Object.defineProperty(chainableMethodWrapper, asserterName, pd);
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1740
|
+
transferFlags(this, chainableMethodWrapper);
|
|
1741
|
+
return proxify(chainableMethodWrapper);
|
|
1742
|
+
}, "chainableMethodGetter"),
|
|
1743
|
+
configurable: true
|
|
1744
|
+
});
|
|
1745
1745
|
}
|
|
1746
1746
|
__name(addChainableMethod, "addChainableMethod");
|
|
1747
1747
|
|
|
@@ -1794,11 +1794,7 @@ function getOwnEnumerableProperties(obj) {
|
|
|
1794
1794
|
__name(getOwnEnumerableProperties, "getOwnEnumerableProperties");
|
|
1795
1795
|
|
|
1796
1796
|
// lib/chai/utils/isNaN.js
|
|
1797
|
-
|
|
1798
|
-
return value !== value;
|
|
1799
|
-
}
|
|
1800
|
-
__name(_isNaN, "_isNaN");
|
|
1801
|
-
var isNaN2 = Number.isNaN || _isNaN;
|
|
1797
|
+
var isNaN2 = Number.isNaN;
|
|
1802
1798
|
|
|
1803
1799
|
// lib/chai/utils/getOperator.js
|
|
1804
1800
|
function isObjectType(obj) {
|
|
@@ -1893,10 +1889,15 @@ Assertion.addProperty("all", function() {
|
|
|
1893
1889
|
flag2(this, "any", false);
|
|
1894
1890
|
});
|
|
1895
1891
|
var functionTypes = {
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1892
|
+
function: [
|
|
1893
|
+
"function",
|
|
1894
|
+
"asyncfunction",
|
|
1895
|
+
"generatorfunction",
|
|
1896
|
+
"asyncgeneratorfunction"
|
|
1897
|
+
],
|
|
1898
|
+
asyncfunction: ["asyncfunction", "asyncgeneratorfunction"],
|
|
1899
|
+
generatorfunction: ["generatorfunction", "asyncgeneratorfunction"],
|
|
1900
|
+
asyncgeneratorfunction: ["asyncgeneratorfunction"]
|
|
1900
1901
|
};
|
|
1901
1902
|
function an(type3, msg) {
|
|
1902
1903
|
if (msg)
|
|
@@ -2047,13 +2048,14 @@ Assertion.addProperty("callable", function() {
|
|
|
2047
2048
|
const msg = message ? `${message}: ` : "";
|
|
2048
2049
|
const negate = flag2(this, "negate");
|
|
2049
2050
|
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 = [
|
|
2051
|
+
const isCallable = [
|
|
2052
|
+
"Function",
|
|
2053
|
+
"AsyncFunction",
|
|
2054
|
+
"GeneratorFunction",
|
|
2055
|
+
"AsyncGeneratorFunction"
|
|
2056
|
+
].includes(type(val));
|
|
2051
2057
|
if (isCallable && negate || !isCallable && !negate) {
|
|
2052
|
-
throw new AssertionError(
|
|
2053
|
-
assertionMessage,
|
|
2054
|
-
void 0,
|
|
2055
|
-
ssfi
|
|
2056
|
-
);
|
|
2058
|
+
throw new AssertionError(assertionMessage, void 0, ssfi);
|
|
2057
2059
|
}
|
|
2058
2060
|
});
|
|
2059
2061
|
Assertion.addProperty("false", function() {
|
|
@@ -2192,13 +2194,25 @@ function assertAbove(n, msg) {
|
|
|
2192
2194
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2193
2195
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2194
2196
|
}
|
|
2195
|
-
if (!doLength &&
|
|
2196
|
-
throw new AssertionError(
|
|
2197
|
+
if (!doLength && objType === "date" && nType !== "date") {
|
|
2198
|
+
throw new AssertionError(
|
|
2199
|
+
msgPrefix + "the argument to above must be a date",
|
|
2200
|
+
void 0,
|
|
2201
|
+
ssfi
|
|
2202
|
+
);
|
|
2197
2203
|
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2198
|
-
throw new AssertionError(
|
|
2199
|
-
|
|
2204
|
+
throw new AssertionError(
|
|
2205
|
+
msgPrefix + "the argument to above must be a number",
|
|
2206
|
+
void 0,
|
|
2207
|
+
ssfi
|
|
2208
|
+
);
|
|
2209
|
+
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2200
2210
|
var printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2201
|
-
throw new AssertionError(
|
|
2211
|
+
throw new AssertionError(
|
|
2212
|
+
msgPrefix + "expected " + printObj + " to be a number or a date",
|
|
2213
|
+
void 0,
|
|
2214
|
+
ssfi
|
|
2215
|
+
);
|
|
2202
2216
|
}
|
|
2203
2217
|
if (doLength) {
|
|
2204
2218
|
var descriptor = "length", itemsCount;
|
|
@@ -2235,11 +2249,11 @@ function assertLeast(n, msg) {
|
|
|
2235
2249
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2236
2250
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2237
2251
|
}
|
|
2238
|
-
if (!doLength &&
|
|
2252
|
+
if (!doLength && objType === "date" && nType !== "date") {
|
|
2239
2253
|
errorMessage = msgPrefix + "the argument to least must be a date";
|
|
2240
2254
|
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2241
2255
|
errorMessage = msgPrefix + "the argument to least must be a number";
|
|
2242
|
-
} else if (!doLength &&
|
|
2256
|
+
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2243
2257
|
var printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2244
2258
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2245
2259
|
} else {
|
|
@@ -2283,11 +2297,11 @@ function assertBelow(n, msg) {
|
|
|
2283
2297
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2284
2298
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2285
2299
|
}
|
|
2286
|
-
if (!doLength &&
|
|
2300
|
+
if (!doLength && objType === "date" && nType !== "date") {
|
|
2287
2301
|
errorMessage = msgPrefix + "the argument to below must be a date";
|
|
2288
2302
|
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2289
2303
|
errorMessage = msgPrefix + "the argument to below must be a number";
|
|
2290
|
-
} else if (!doLength &&
|
|
2304
|
+
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2291
2305
|
var printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2292
2306
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2293
2307
|
} else {
|
|
@@ -2331,11 +2345,11 @@ function assertMost(n, msg) {
|
|
|
2331
2345
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2332
2346
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2333
2347
|
}
|
|
2334
|
-
if (!doLength &&
|
|
2348
|
+
if (!doLength && objType === "date" && nType !== "date") {
|
|
2335
2349
|
errorMessage = msgPrefix + "the argument to most must be a date";
|
|
2336
2350
|
} else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
|
|
2337
2351
|
errorMessage = msgPrefix + "the argument to most must be a number";
|
|
2338
|
-
} else if (!doLength &&
|
|
2352
|
+
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2339
2353
|
var printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2340
2354
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2341
2355
|
} else {
|
|
@@ -2379,11 +2393,11 @@ Assertion.addMethod("within", function(start, finish, msg) {
|
|
|
2379
2393
|
if (doLength && objType !== "map" && objType !== "set") {
|
|
2380
2394
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2381
2395
|
}
|
|
2382
|
-
if (!doLength &&
|
|
2396
|
+
if (!doLength && objType === "date" && (startType !== "date" || finishType !== "date")) {
|
|
2383
2397
|
errorMessage = msgPrefix + "the arguments to within must be dates";
|
|
2384
2398
|
} else if ((!isNumeric(start) || !isNumeric(finish)) && (doLength || isNumeric(obj))) {
|
|
2385
2399
|
errorMessage = msgPrefix + "the arguments to within must be numbers";
|
|
2386
|
-
} else if (!doLength &&
|
|
2400
|
+
} else if (!doLength && objType !== "date" && !isNumeric(obj)) {
|
|
2387
2401
|
var printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2388
2402
|
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2389
2403
|
} else {
|
|
@@ -2517,7 +2531,7 @@ function assertProperty(name, val, msg) {
|
|
|
2517
2531
|
}
|
|
2518
2532
|
__name(assertProperty, "assertProperty");
|
|
2519
2533
|
Assertion.addMethod("property", assertProperty);
|
|
2520
|
-
function assertOwnProperty(
|
|
2534
|
+
function assertOwnProperty(_name, _value, _msg) {
|
|
2521
2535
|
flag2(this, "own", true);
|
|
2522
2536
|
assertProperty.apply(this, arguments);
|
|
2523
2537
|
}
|
|
@@ -2743,7 +2757,10 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
2743
2757
|
}
|
|
2744
2758
|
if (errorLike && caughtErr) {
|
|
2745
2759
|
if (errorLike instanceof Error) {
|
|
2746
|
-
var isCompatibleInstance = check_error_exports.compatibleInstance(
|
|
2760
|
+
var isCompatibleInstance = check_error_exports.compatibleInstance(
|
|
2761
|
+
caughtErr,
|
|
2762
|
+
errorLike
|
|
2763
|
+
);
|
|
2747
2764
|
if (isCompatibleInstance === negate) {
|
|
2748
2765
|
if (everyArgIsDefined && negate) {
|
|
2749
2766
|
errorLikeFail = true;
|
|
@@ -2758,7 +2775,10 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
2758
2775
|
}
|
|
2759
2776
|
}
|
|
2760
2777
|
}
|
|
2761
|
-
var isCompatibleConstructor = check_error_exports.compatibleConstructor(
|
|
2778
|
+
var isCompatibleConstructor = check_error_exports.compatibleConstructor(
|
|
2779
|
+
caughtErr,
|
|
2780
|
+
errorLike
|
|
2781
|
+
);
|
|
2762
2782
|
if (isCompatibleConstructor === negate) {
|
|
2763
2783
|
if (everyArgIsDefined && negate) {
|
|
2764
2784
|
errorLikeFail = true;
|
|
@@ -2778,7 +2798,10 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
2778
2798
|
if (isRegExp2(errMsgMatcher)) {
|
|
2779
2799
|
placeholder = "matching";
|
|
2780
2800
|
}
|
|
2781
|
-
var isCompatibleMessage = check_error_exports.compatibleMessage(
|
|
2801
|
+
var isCompatibleMessage = check_error_exports.compatibleMessage(
|
|
2802
|
+
caughtErr,
|
|
2803
|
+
errMsgMatcher
|
|
2804
|
+
);
|
|
2782
2805
|
if (isCompatibleMessage === negate) {
|
|
2783
2806
|
if (everyArgIsDefined && negate) {
|
|
2784
2807
|
errMsgMatcherFail = true;
|
|
@@ -2847,15 +2870,24 @@ function closeTo(expected, delta, msg) {
|
|
|
2847
2870
|
new Assertion(obj, flagMsg, ssfi, true).is.numeric;
|
|
2848
2871
|
let message = "A `delta` value is required for `closeTo`";
|
|
2849
2872
|
if (delta == void 0)
|
|
2850
|
-
throw new AssertionError(
|
|
2873
|
+
throw new AssertionError(
|
|
2874
|
+
flagMsg ? `${flagMsg}: ${message}` : message,
|
|
2875
|
+
void 0,
|
|
2876
|
+
ssfi
|
|
2877
|
+
);
|
|
2851
2878
|
new Assertion(delta, flagMsg, ssfi, true).is.numeric;
|
|
2852
2879
|
message = "A `expected` value is required for `closeTo`";
|
|
2853
2880
|
if (expected == void 0)
|
|
2854
|
-
throw new AssertionError(
|
|
2881
|
+
throw new AssertionError(
|
|
2882
|
+
flagMsg ? `${flagMsg}: ${message}` : message,
|
|
2883
|
+
void 0,
|
|
2884
|
+
ssfi
|
|
2885
|
+
);
|
|
2855
2886
|
new Assertion(expected, flagMsg, ssfi, true).is.numeric;
|
|
2856
2887
|
const abs = /* @__PURE__ */ __name((x) => x < 0n ? -x : x, "abs");
|
|
2888
|
+
const strip = /* @__PURE__ */ __name((number) => parseFloat(parseFloat(number).toPrecision(12)), "strip");
|
|
2857
2889
|
this.assert(
|
|
2858
|
-
abs(obj - expected) <= delta,
|
|
2890
|
+
strip(abs(obj - expected)) <= delta,
|
|
2859
2891
|
"expected #{this} to be close to " + expected + " +/- " + delta,
|
|
2860
2892
|
"expected #{this} not to be close to " + expected + " +/- " + delta
|
|
2861
2893
|
);
|
|
@@ -3111,7 +3143,7 @@ Assertion.addProperty("frozen", function() {
|
|
|
3111
3143
|
"expected #{this} to not be frozen"
|
|
3112
3144
|
);
|
|
3113
3145
|
});
|
|
3114
|
-
Assertion.addProperty("finite", function(
|
|
3146
|
+
Assertion.addProperty("finite", function(_msg) {
|
|
3115
3147
|
var obj = flag2(this, "object");
|
|
3116
3148
|
this.assert(
|
|
3117
3149
|
typeof obj === "number" && isFinite(obj),
|
|
@@ -3119,6 +3151,61 @@ Assertion.addProperty("finite", function(msg) {
|
|
|
3119
3151
|
"expected #{this} to not be a finite number"
|
|
3120
3152
|
);
|
|
3121
3153
|
});
|
|
3154
|
+
function compareSubset(expected, actual) {
|
|
3155
|
+
if (expected === actual) {
|
|
3156
|
+
return true;
|
|
3157
|
+
}
|
|
3158
|
+
if (typeof actual !== typeof expected) {
|
|
3159
|
+
return false;
|
|
3160
|
+
}
|
|
3161
|
+
if (typeof expected !== "object" || expected === null) {
|
|
3162
|
+
return expected === actual;
|
|
3163
|
+
}
|
|
3164
|
+
if (!actual) {
|
|
3165
|
+
return false;
|
|
3166
|
+
}
|
|
3167
|
+
if (Array.isArray(expected)) {
|
|
3168
|
+
if (!Array.isArray(actual)) {
|
|
3169
|
+
return false;
|
|
3170
|
+
}
|
|
3171
|
+
return expected.every(function(exp) {
|
|
3172
|
+
return actual.some(function(act) {
|
|
3173
|
+
return compareSubset(exp, act);
|
|
3174
|
+
});
|
|
3175
|
+
});
|
|
3176
|
+
}
|
|
3177
|
+
if (expected instanceof Date) {
|
|
3178
|
+
if (actual instanceof Date) {
|
|
3179
|
+
return expected.getTime() === actual.getTime();
|
|
3180
|
+
} else {
|
|
3181
|
+
return false;
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
3184
|
+
return Object.keys(expected).every(function(key) {
|
|
3185
|
+
var expectedValue = expected[key];
|
|
3186
|
+
var actualValue = actual[key];
|
|
3187
|
+
if (typeof expectedValue === "object" && expectedValue !== null && actualValue !== null) {
|
|
3188
|
+
return compareSubset(expectedValue, actualValue);
|
|
3189
|
+
}
|
|
3190
|
+
if (typeof expectedValue === "function") {
|
|
3191
|
+
return expectedValue(actualValue);
|
|
3192
|
+
}
|
|
3193
|
+
return actualValue === expectedValue;
|
|
3194
|
+
});
|
|
3195
|
+
}
|
|
3196
|
+
__name(compareSubset, "compareSubset");
|
|
3197
|
+
Assertion.addMethod("containSubset", function(expected) {
|
|
3198
|
+
const actual = flag(this, "object");
|
|
3199
|
+
const showDiff = config.showDiff;
|
|
3200
|
+
this.assert(
|
|
3201
|
+
compareSubset(expected, actual),
|
|
3202
|
+
"expected #{act} to contain subset #{exp}",
|
|
3203
|
+
"expected #{act} to not contain subset #{exp}",
|
|
3204
|
+
expected,
|
|
3205
|
+
actual,
|
|
3206
|
+
showDiff
|
|
3207
|
+
);
|
|
3208
|
+
});
|
|
3122
3209
|
|
|
3123
3210
|
// lib/chai/interface/expect.js
|
|
3124
3211
|
function expect(val, message) {
|
|
@@ -3131,11 +3218,15 @@ expect.fail = function(actual, expected, message, operator) {
|
|
|
3131
3218
|
actual = void 0;
|
|
3132
3219
|
}
|
|
3133
3220
|
message = message || "expect.fail()";
|
|
3134
|
-
throw new AssertionError(
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3221
|
+
throw new AssertionError(
|
|
3222
|
+
message,
|
|
3223
|
+
{
|
|
3224
|
+
actual,
|
|
3225
|
+
expected,
|
|
3226
|
+
operator
|
|
3227
|
+
},
|
|
3228
|
+
expect.fail
|
|
3229
|
+
);
|
|
3139
3230
|
};
|
|
3140
3231
|
|
|
3141
3232
|
// lib/chai/interface/should.js
|
|
@@ -3173,11 +3264,15 @@ function loadShould() {
|
|
|
3173
3264
|
actual = void 0;
|
|
3174
3265
|
}
|
|
3175
3266
|
message = message || "should.fail()";
|
|
3176
|
-
throw new AssertionError(
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3267
|
+
throw new AssertionError(
|
|
3268
|
+
message,
|
|
3269
|
+
{
|
|
3270
|
+
actual,
|
|
3271
|
+
expected,
|
|
3272
|
+
operator
|
|
3273
|
+
},
|
|
3274
|
+
should2.fail
|
|
3275
|
+
);
|
|
3181
3276
|
};
|
|
3182
3277
|
should2.equal = function(actual, expected, message) {
|
|
3183
3278
|
new Assertion(actual, message).to.equal(expected);
|
|
@@ -3209,11 +3304,7 @@ var Should = loadShould;
|
|
|
3209
3304
|
// lib/chai/interface/assert.js
|
|
3210
3305
|
function assert(express, errmsg) {
|
|
3211
3306
|
var test2 = new Assertion(null, null, assert, true);
|
|
3212
|
-
test2.assert(
|
|
3213
|
-
express,
|
|
3214
|
-
errmsg,
|
|
3215
|
-
"[ negation message unavailable ]"
|
|
3216
|
-
);
|
|
3307
|
+
test2.assert(express, errmsg, "[ negation message unavailable ]");
|
|
3217
3308
|
}
|
|
3218
3309
|
__name(assert, "assert");
|
|
3219
3310
|
assert.fail = function(actual, expected, message, operator) {
|
|
@@ -3222,11 +3313,15 @@ assert.fail = function(actual, expected, message, operator) {
|
|
|
3222
3313
|
actual = void 0;
|
|
3223
3314
|
}
|
|
3224
3315
|
message = message || "assert.fail()";
|
|
3225
|
-
throw new AssertionError(
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3316
|
+
throw new AssertionError(
|
|
3317
|
+
message,
|
|
3318
|
+
{
|
|
3319
|
+
actual,
|
|
3320
|
+
expected,
|
|
3321
|
+
operator
|
|
3322
|
+
},
|
|
3323
|
+
assert.fail
|
|
3324
|
+
);
|
|
3230
3325
|
};
|
|
3231
3326
|
assert.isOk = function(val, msg) {
|
|
3232
3327
|
new Assertion(val, msg, assert.isOk, true).is.ok;
|
|
@@ -3371,7 +3466,9 @@ assert.instanceOf = function(val, type3, msg) {
|
|
|
3371
3466
|
new Assertion(val, msg, assert.instanceOf, true).to.be.instanceOf(type3);
|
|
3372
3467
|
};
|
|
3373
3468
|
assert.notInstanceOf = function(val, type3, msg) {
|
|
3374
|
-
new Assertion(val, msg, assert.notInstanceOf, true).to.not.be.instanceOf(
|
|
3469
|
+
new Assertion(val, msg, assert.notInstanceOf, true).to.not.be.instanceOf(
|
|
3470
|
+
type3
|
|
3471
|
+
);
|
|
3375
3472
|
};
|
|
3376
3473
|
assert.include = function(exp, inc, msg) {
|
|
3377
3474
|
new Assertion(exp, msg, assert.include, true).include(inc);
|
|
@@ -3389,13 +3486,22 @@ assert.nestedInclude = function(exp, inc, msg) {
|
|
|
3389
3486
|
new Assertion(exp, msg, assert.nestedInclude, true).nested.include(inc);
|
|
3390
3487
|
};
|
|
3391
3488
|
assert.notNestedInclude = function(exp, inc, msg) {
|
|
3392
|
-
new Assertion(exp, msg, assert.notNestedInclude, true).not.nested.include(
|
|
3489
|
+
new Assertion(exp, msg, assert.notNestedInclude, true).not.nested.include(
|
|
3490
|
+
inc
|
|
3491
|
+
);
|
|
3393
3492
|
};
|
|
3394
3493
|
assert.deepNestedInclude = function(exp, inc, msg) {
|
|
3395
|
-
new Assertion(exp, msg, assert.deepNestedInclude, true).deep.nested.include(
|
|
3494
|
+
new Assertion(exp, msg, assert.deepNestedInclude, true).deep.nested.include(
|
|
3495
|
+
inc
|
|
3496
|
+
);
|
|
3396
3497
|
};
|
|
3397
3498
|
assert.notDeepNestedInclude = function(exp, inc, msg) {
|
|
3398
|
-
new Assertion(
|
|
3499
|
+
new Assertion(
|
|
3500
|
+
exp,
|
|
3501
|
+
msg,
|
|
3502
|
+
assert.notDeepNestedInclude,
|
|
3503
|
+
true
|
|
3504
|
+
).not.deep.nested.include(inc);
|
|
3399
3505
|
};
|
|
3400
3506
|
assert.ownInclude = function(exp, inc, msg) {
|
|
3401
3507
|
new Assertion(exp, msg, assert.ownInclude, true).own.include(inc);
|
|
@@ -3407,7 +3513,9 @@ assert.deepOwnInclude = function(exp, inc, msg) {
|
|
|
3407
3513
|
new Assertion(exp, msg, assert.deepOwnInclude, true).deep.own.include(inc);
|
|
3408
3514
|
};
|
|
3409
3515
|
assert.notDeepOwnInclude = function(exp, inc, msg) {
|
|
3410
|
-
new Assertion(exp, msg, assert.notDeepOwnInclude, true).not.deep.own.include(
|
|
3516
|
+
new Assertion(exp, msg, assert.notDeepOwnInclude, true).not.deep.own.include(
|
|
3517
|
+
inc
|
|
3518
|
+
);
|
|
3411
3519
|
};
|
|
3412
3520
|
assert.match = function(exp, re, msg) {
|
|
3413
3521
|
new Assertion(exp, msg, assert.match, true).to.match(re);
|
|
@@ -3425,49 +3533,107 @@ assert.propertyVal = function(obj, prop, val, msg) {
|
|
|
3425
3533
|
new Assertion(obj, msg, assert.propertyVal, true).to.have.property(prop, val);
|
|
3426
3534
|
};
|
|
3427
3535
|
assert.notPropertyVal = function(obj, prop, val, msg) {
|
|
3428
|
-
new Assertion(obj, msg, assert.notPropertyVal, true).to.not.have.property(
|
|
3536
|
+
new Assertion(obj, msg, assert.notPropertyVal, true).to.not.have.property(
|
|
3537
|
+
prop,
|
|
3538
|
+
val
|
|
3539
|
+
);
|
|
3429
3540
|
};
|
|
3430
3541
|
assert.deepPropertyVal = function(obj, prop, val, msg) {
|
|
3431
|
-
new Assertion(obj, msg, assert.deepPropertyVal, true).to.have.deep.property(
|
|
3542
|
+
new Assertion(obj, msg, assert.deepPropertyVal, true).to.have.deep.property(
|
|
3543
|
+
prop,
|
|
3544
|
+
val
|
|
3545
|
+
);
|
|
3432
3546
|
};
|
|
3433
3547
|
assert.notDeepPropertyVal = function(obj, prop, val, msg) {
|
|
3434
|
-
new Assertion(
|
|
3548
|
+
new Assertion(
|
|
3549
|
+
obj,
|
|
3550
|
+
msg,
|
|
3551
|
+
assert.notDeepPropertyVal,
|
|
3552
|
+
true
|
|
3553
|
+
).to.not.have.deep.property(prop, val);
|
|
3435
3554
|
};
|
|
3436
3555
|
assert.ownProperty = function(obj, prop, msg) {
|
|
3437
3556
|
new Assertion(obj, msg, assert.ownProperty, true).to.have.own.property(prop);
|
|
3438
3557
|
};
|
|
3439
3558
|
assert.notOwnProperty = function(obj, prop, msg) {
|
|
3440
|
-
new Assertion(obj, msg, assert.notOwnProperty, true).to.not.have.own.property(
|
|
3559
|
+
new Assertion(obj, msg, assert.notOwnProperty, true).to.not.have.own.property(
|
|
3560
|
+
prop
|
|
3561
|
+
);
|
|
3441
3562
|
};
|
|
3442
3563
|
assert.ownPropertyVal = function(obj, prop, value, msg) {
|
|
3443
|
-
new Assertion(obj, msg, assert.ownPropertyVal, true).to.have.own.property(
|
|
3564
|
+
new Assertion(obj, msg, assert.ownPropertyVal, true).to.have.own.property(
|
|
3565
|
+
prop,
|
|
3566
|
+
value
|
|
3567
|
+
);
|
|
3444
3568
|
};
|
|
3445
3569
|
assert.notOwnPropertyVal = function(obj, prop, value, msg) {
|
|
3446
|
-
new Assertion(
|
|
3570
|
+
new Assertion(
|
|
3571
|
+
obj,
|
|
3572
|
+
msg,
|
|
3573
|
+
assert.notOwnPropertyVal,
|
|
3574
|
+
true
|
|
3575
|
+
).to.not.have.own.property(prop, value);
|
|
3447
3576
|
};
|
|
3448
3577
|
assert.deepOwnPropertyVal = function(obj, prop, value, msg) {
|
|
3449
|
-
new Assertion(
|
|
3578
|
+
new Assertion(
|
|
3579
|
+
obj,
|
|
3580
|
+
msg,
|
|
3581
|
+
assert.deepOwnPropertyVal,
|
|
3582
|
+
true
|
|
3583
|
+
).to.have.deep.own.property(prop, value);
|
|
3450
3584
|
};
|
|
3451
3585
|
assert.notDeepOwnPropertyVal = function(obj, prop, value, msg) {
|
|
3452
|
-
new Assertion(
|
|
3586
|
+
new Assertion(
|
|
3587
|
+
obj,
|
|
3588
|
+
msg,
|
|
3589
|
+
assert.notDeepOwnPropertyVal,
|
|
3590
|
+
true
|
|
3591
|
+
).to.not.have.deep.own.property(prop, value);
|
|
3453
3592
|
};
|
|
3454
3593
|
assert.nestedProperty = function(obj, prop, msg) {
|
|
3455
|
-
new Assertion(obj, msg, assert.nestedProperty, true).to.have.nested.property(
|
|
3594
|
+
new Assertion(obj, msg, assert.nestedProperty, true).to.have.nested.property(
|
|
3595
|
+
prop
|
|
3596
|
+
);
|
|
3456
3597
|
};
|
|
3457
3598
|
assert.notNestedProperty = function(obj, prop, msg) {
|
|
3458
|
-
new Assertion(
|
|
3599
|
+
new Assertion(
|
|
3600
|
+
obj,
|
|
3601
|
+
msg,
|
|
3602
|
+
assert.notNestedProperty,
|
|
3603
|
+
true
|
|
3604
|
+
).to.not.have.nested.property(prop);
|
|
3459
3605
|
};
|
|
3460
3606
|
assert.nestedPropertyVal = function(obj, prop, val, msg) {
|
|
3461
|
-
new Assertion(
|
|
3607
|
+
new Assertion(
|
|
3608
|
+
obj,
|
|
3609
|
+
msg,
|
|
3610
|
+
assert.nestedPropertyVal,
|
|
3611
|
+
true
|
|
3612
|
+
).to.have.nested.property(prop, val);
|
|
3462
3613
|
};
|
|
3463
3614
|
assert.notNestedPropertyVal = function(obj, prop, val, msg) {
|
|
3464
|
-
new Assertion(
|
|
3615
|
+
new Assertion(
|
|
3616
|
+
obj,
|
|
3617
|
+
msg,
|
|
3618
|
+
assert.notNestedPropertyVal,
|
|
3619
|
+
true
|
|
3620
|
+
).to.not.have.nested.property(prop, val);
|
|
3465
3621
|
};
|
|
3466
3622
|
assert.deepNestedPropertyVal = function(obj, prop, val, msg) {
|
|
3467
|
-
new Assertion(
|
|
3623
|
+
new Assertion(
|
|
3624
|
+
obj,
|
|
3625
|
+
msg,
|
|
3626
|
+
assert.deepNestedPropertyVal,
|
|
3627
|
+
true
|
|
3628
|
+
).to.have.deep.nested.property(prop, val);
|
|
3468
3629
|
};
|
|
3469
3630
|
assert.notDeepNestedPropertyVal = function(obj, prop, val, msg) {
|
|
3470
|
-
new Assertion(
|
|
3631
|
+
new Assertion(
|
|
3632
|
+
obj,
|
|
3633
|
+
msg,
|
|
3634
|
+
assert.notDeepNestedPropertyVal,
|
|
3635
|
+
true
|
|
3636
|
+
).to.not.have.deep.nested.property(prop, val);
|
|
3471
3637
|
};
|
|
3472
3638
|
assert.lengthOf = function(exp, len, msg) {
|
|
3473
3639
|
new Assertion(exp, msg, assert.lengthOf, true).to.have.lengthOf(len);
|
|
@@ -3479,35 +3645,63 @@ assert.hasAllKeys = function(obj, keys, msg) {
|
|
|
3479
3645
|
new Assertion(obj, msg, assert.hasAllKeys, true).to.have.all.keys(keys);
|
|
3480
3646
|
};
|
|
3481
3647
|
assert.containsAllKeys = function(obj, keys, msg) {
|
|
3482
|
-
new Assertion(obj, msg, assert.containsAllKeys, true).to.contain.all.keys(
|
|
3648
|
+
new Assertion(obj, msg, assert.containsAllKeys, true).to.contain.all.keys(
|
|
3649
|
+
keys
|
|
3650
|
+
);
|
|
3483
3651
|
};
|
|
3484
3652
|
assert.doesNotHaveAnyKeys = function(obj, keys, msg) {
|
|
3485
|
-
new Assertion(obj, msg, assert.doesNotHaveAnyKeys, true).to.not.have.any.keys(
|
|
3653
|
+
new Assertion(obj, msg, assert.doesNotHaveAnyKeys, true).to.not.have.any.keys(
|
|
3654
|
+
keys
|
|
3655
|
+
);
|
|
3486
3656
|
};
|
|
3487
3657
|
assert.doesNotHaveAllKeys = function(obj, keys, msg) {
|
|
3488
|
-
new Assertion(obj, msg, assert.doesNotHaveAllKeys, true).to.not.have.all.keys(
|
|
3658
|
+
new Assertion(obj, msg, assert.doesNotHaveAllKeys, true).to.not.have.all.keys(
|
|
3659
|
+
keys
|
|
3660
|
+
);
|
|
3489
3661
|
};
|
|
3490
3662
|
assert.hasAnyDeepKeys = function(obj, keys, msg) {
|
|
3491
|
-
new Assertion(obj, msg, assert.hasAnyDeepKeys, true).to.have.any.deep.keys(
|
|
3663
|
+
new Assertion(obj, msg, assert.hasAnyDeepKeys, true).to.have.any.deep.keys(
|
|
3664
|
+
keys
|
|
3665
|
+
);
|
|
3492
3666
|
};
|
|
3493
3667
|
assert.hasAllDeepKeys = function(obj, keys, msg) {
|
|
3494
|
-
new Assertion(obj, msg, assert.hasAllDeepKeys, true).to.have.all.deep.keys(
|
|
3668
|
+
new Assertion(obj, msg, assert.hasAllDeepKeys, true).to.have.all.deep.keys(
|
|
3669
|
+
keys
|
|
3670
|
+
);
|
|
3495
3671
|
};
|
|
3496
3672
|
assert.containsAllDeepKeys = function(obj, keys, msg) {
|
|
3497
|
-
new Assertion(
|
|
3673
|
+
new Assertion(
|
|
3674
|
+
obj,
|
|
3675
|
+
msg,
|
|
3676
|
+
assert.containsAllDeepKeys,
|
|
3677
|
+
true
|
|
3678
|
+
).to.contain.all.deep.keys(keys);
|
|
3498
3679
|
};
|
|
3499
3680
|
assert.doesNotHaveAnyDeepKeys = function(obj, keys, msg) {
|
|
3500
|
-
new Assertion(
|
|
3681
|
+
new Assertion(
|
|
3682
|
+
obj,
|
|
3683
|
+
msg,
|
|
3684
|
+
assert.doesNotHaveAnyDeepKeys,
|
|
3685
|
+
true
|
|
3686
|
+
).to.not.have.any.deep.keys(keys);
|
|
3501
3687
|
};
|
|
3502
3688
|
assert.doesNotHaveAllDeepKeys = function(obj, keys, msg) {
|
|
3503
|
-
new Assertion(
|
|
3689
|
+
new Assertion(
|
|
3690
|
+
obj,
|
|
3691
|
+
msg,
|
|
3692
|
+
assert.doesNotHaveAllDeepKeys,
|
|
3693
|
+
true
|
|
3694
|
+
).to.not.have.all.deep.keys(keys);
|
|
3504
3695
|
};
|
|
3505
3696
|
assert.throws = function(fn, errorLike, errMsgMatcher, msg) {
|
|
3506
3697
|
if ("string" === typeof errorLike || errorLike instanceof RegExp) {
|
|
3507
3698
|
errMsgMatcher = errorLike;
|
|
3508
3699
|
errorLike = null;
|
|
3509
3700
|
}
|
|
3510
|
-
var assertErr = new Assertion(fn, msg, assert.throws, true).to.throw(
|
|
3701
|
+
var assertErr = new Assertion(fn, msg, assert.throws, true).to.throw(
|
|
3702
|
+
errorLike,
|
|
3703
|
+
errMsgMatcher
|
|
3704
|
+
);
|
|
3511
3705
|
return flag(assertErr, "object");
|
|
3512
3706
|
};
|
|
3513
3707
|
assert.doesNotThrow = function(fn, errorLike, errMsgMatcher, message) {
|
|
@@ -3515,7 +3709,10 @@ assert.doesNotThrow = function(fn, errorLike, errMsgMatcher, message) {
|
|
|
3515
3709
|
errMsgMatcher = errorLike;
|
|
3516
3710
|
errorLike = null;
|
|
3517
3711
|
}
|
|
3518
|
-
new Assertion(fn, message, assert.doesNotThrow, true).to.not.throw(
|
|
3712
|
+
new Assertion(fn, message, assert.doesNotThrow, true).to.not.throw(
|
|
3713
|
+
errorLike,
|
|
3714
|
+
errMsgMatcher
|
|
3715
|
+
);
|
|
3519
3716
|
};
|
|
3520
3717
|
assert.operator = function(val, operator, val2, msg) {
|
|
3521
3718
|
var ok;
|
|
@@ -3563,55 +3760,130 @@ assert.closeTo = function(act, exp, delta, msg) {
|
|
|
3563
3760
|
new Assertion(act, msg, assert.closeTo, true).to.be.closeTo(exp, delta);
|
|
3564
3761
|
};
|
|
3565
3762
|
assert.approximately = function(act, exp, delta, msg) {
|
|
3566
|
-
new Assertion(act, msg, assert.approximately, true).to.be.approximately(
|
|
3763
|
+
new Assertion(act, msg, assert.approximately, true).to.be.approximately(
|
|
3764
|
+
exp,
|
|
3765
|
+
delta
|
|
3766
|
+
);
|
|
3567
3767
|
};
|
|
3568
3768
|
assert.sameMembers = function(set1, set2, msg) {
|
|
3569
3769
|
new Assertion(set1, msg, assert.sameMembers, true).to.have.same.members(set2);
|
|
3570
3770
|
};
|
|
3571
3771
|
assert.notSameMembers = function(set1, set2, msg) {
|
|
3572
|
-
new Assertion(
|
|
3772
|
+
new Assertion(
|
|
3773
|
+
set1,
|
|
3774
|
+
msg,
|
|
3775
|
+
assert.notSameMembers,
|
|
3776
|
+
true
|
|
3777
|
+
).to.not.have.same.members(set2);
|
|
3573
3778
|
};
|
|
3574
3779
|
assert.sameDeepMembers = function(set1, set2, msg) {
|
|
3575
|
-
new Assertion(
|
|
3780
|
+
new Assertion(
|
|
3781
|
+
set1,
|
|
3782
|
+
msg,
|
|
3783
|
+
assert.sameDeepMembers,
|
|
3784
|
+
true
|
|
3785
|
+
).to.have.same.deep.members(set2);
|
|
3576
3786
|
};
|
|
3577
3787
|
assert.notSameDeepMembers = function(set1, set2, msg) {
|
|
3578
|
-
new Assertion(
|
|
3788
|
+
new Assertion(
|
|
3789
|
+
set1,
|
|
3790
|
+
msg,
|
|
3791
|
+
assert.notSameDeepMembers,
|
|
3792
|
+
true
|
|
3793
|
+
).to.not.have.same.deep.members(set2);
|
|
3579
3794
|
};
|
|
3580
3795
|
assert.sameOrderedMembers = function(set1, set2, msg) {
|
|
3581
|
-
new Assertion(
|
|
3796
|
+
new Assertion(
|
|
3797
|
+
set1,
|
|
3798
|
+
msg,
|
|
3799
|
+
assert.sameOrderedMembers,
|
|
3800
|
+
true
|
|
3801
|
+
).to.have.same.ordered.members(set2);
|
|
3582
3802
|
};
|
|
3583
3803
|
assert.notSameOrderedMembers = function(set1, set2, msg) {
|
|
3584
|
-
new Assertion(
|
|
3804
|
+
new Assertion(
|
|
3805
|
+
set1,
|
|
3806
|
+
msg,
|
|
3807
|
+
assert.notSameOrderedMembers,
|
|
3808
|
+
true
|
|
3809
|
+
).to.not.have.same.ordered.members(set2);
|
|
3585
3810
|
};
|
|
3586
3811
|
assert.sameDeepOrderedMembers = function(set1, set2, msg) {
|
|
3587
|
-
new Assertion(
|
|
3812
|
+
new Assertion(
|
|
3813
|
+
set1,
|
|
3814
|
+
msg,
|
|
3815
|
+
assert.sameDeepOrderedMembers,
|
|
3816
|
+
true
|
|
3817
|
+
).to.have.same.deep.ordered.members(set2);
|
|
3588
3818
|
};
|
|
3589
3819
|
assert.notSameDeepOrderedMembers = function(set1, set2, msg) {
|
|
3590
|
-
new Assertion(
|
|
3820
|
+
new Assertion(
|
|
3821
|
+
set1,
|
|
3822
|
+
msg,
|
|
3823
|
+
assert.notSameDeepOrderedMembers,
|
|
3824
|
+
true
|
|
3825
|
+
).to.not.have.same.deep.ordered.members(set2);
|
|
3591
3826
|
};
|
|
3592
3827
|
assert.includeMembers = function(superset, subset, msg) {
|
|
3593
|
-
new Assertion(superset, msg, assert.includeMembers, true).to.include.members(
|
|
3828
|
+
new Assertion(superset, msg, assert.includeMembers, true).to.include.members(
|
|
3829
|
+
subset
|
|
3830
|
+
);
|
|
3594
3831
|
};
|
|
3595
3832
|
assert.notIncludeMembers = function(superset, subset, msg) {
|
|
3596
|
-
new Assertion(
|
|
3833
|
+
new Assertion(
|
|
3834
|
+
superset,
|
|
3835
|
+
msg,
|
|
3836
|
+
assert.notIncludeMembers,
|
|
3837
|
+
true
|
|
3838
|
+
).to.not.include.members(subset);
|
|
3597
3839
|
};
|
|
3598
3840
|
assert.includeDeepMembers = function(superset, subset, msg) {
|
|
3599
|
-
new Assertion(
|
|
3841
|
+
new Assertion(
|
|
3842
|
+
superset,
|
|
3843
|
+
msg,
|
|
3844
|
+
assert.includeDeepMembers,
|
|
3845
|
+
true
|
|
3846
|
+
).to.include.deep.members(subset);
|
|
3600
3847
|
};
|
|
3601
3848
|
assert.notIncludeDeepMembers = function(superset, subset, msg) {
|
|
3602
|
-
new Assertion(
|
|
3849
|
+
new Assertion(
|
|
3850
|
+
superset,
|
|
3851
|
+
msg,
|
|
3852
|
+
assert.notIncludeDeepMembers,
|
|
3853
|
+
true
|
|
3854
|
+
).to.not.include.deep.members(subset);
|
|
3603
3855
|
};
|
|
3604
3856
|
assert.includeOrderedMembers = function(superset, subset, msg) {
|
|
3605
|
-
new Assertion(
|
|
3857
|
+
new Assertion(
|
|
3858
|
+
superset,
|
|
3859
|
+
msg,
|
|
3860
|
+
assert.includeOrderedMembers,
|
|
3861
|
+
true
|
|
3862
|
+
).to.include.ordered.members(subset);
|
|
3606
3863
|
};
|
|
3607
3864
|
assert.notIncludeOrderedMembers = function(superset, subset, msg) {
|
|
3608
|
-
new Assertion(
|
|
3865
|
+
new Assertion(
|
|
3866
|
+
superset,
|
|
3867
|
+
msg,
|
|
3868
|
+
assert.notIncludeOrderedMembers,
|
|
3869
|
+
true
|
|
3870
|
+
).to.not.include.ordered.members(subset);
|
|
3609
3871
|
};
|
|
3610
3872
|
assert.includeDeepOrderedMembers = function(superset, subset, msg) {
|
|
3611
|
-
new Assertion(
|
|
3873
|
+
new Assertion(
|
|
3874
|
+
superset,
|
|
3875
|
+
msg,
|
|
3876
|
+
assert.includeDeepOrderedMembers,
|
|
3877
|
+
true
|
|
3878
|
+
).to.include.deep.ordered.members(subset);
|
|
3612
3879
|
};
|
|
3613
3880
|
assert.notIncludeDeepOrderedMembers = function(superset, subset, msg) {
|
|
3614
|
-
new Assertion(
|
|
3881
|
+
new Assertion(
|
|
3882
|
+
superset,
|
|
3883
|
+
msg,
|
|
3884
|
+
assert.notIncludeDeepOrderedMembers,
|
|
3885
|
+
true
|
|
3886
|
+
).to.not.include.deep.ordered.members(subset);
|
|
3615
3887
|
};
|
|
3616
3888
|
assert.oneOf = function(inList, list, msg) {
|
|
3617
3889
|
new Assertion(inList, msg, assert.oneOf, true).to.be.oneOf(list);
|
|
@@ -3619,11 +3891,7 @@ assert.oneOf = function(inList, list, msg) {
|
|
|
3619
3891
|
assert.isIterable = function(obj, msg) {
|
|
3620
3892
|
if (obj == void 0 || !obj[Symbol.iterator]) {
|
|
3621
3893
|
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
|
-
);
|
|
3894
|
+
throw new AssertionError(msg, void 0, assert.isIterable);
|
|
3627
3895
|
}
|
|
3628
3896
|
};
|
|
3629
3897
|
assert.changes = function(fn, obj, prop, msg) {
|
|
@@ -3649,7 +3917,10 @@ assert.doesNotChange = function(fn, obj, prop, msg) {
|
|
|
3649
3917
|
msg = prop;
|
|
3650
3918
|
prop = null;
|
|
3651
3919
|
}
|
|
3652
|
-
return new Assertion(fn, msg, assert.doesNotChange, true).to.not.change(
|
|
3920
|
+
return new Assertion(fn, msg, assert.doesNotChange, true).to.not.change(
|
|
3921
|
+
obj,
|
|
3922
|
+
prop
|
|
3923
|
+
);
|
|
3653
3924
|
};
|
|
3654
3925
|
assert.changesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
3655
3926
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
@@ -3685,7 +3956,10 @@ assert.doesNotIncrease = function(fn, obj, prop, msg) {
|
|
|
3685
3956
|
msg = prop;
|
|
3686
3957
|
prop = null;
|
|
3687
3958
|
}
|
|
3688
|
-
return new Assertion(fn, msg, assert.doesNotIncrease, true).to.not.increase(
|
|
3959
|
+
return new Assertion(fn, msg, assert.doesNotIncrease, true).to.not.increase(
|
|
3960
|
+
obj,
|
|
3961
|
+
prop
|
|
3962
|
+
);
|
|
3689
3963
|
};
|
|
3690
3964
|
assert.increasesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
3691
3965
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
@@ -3721,7 +3995,10 @@ assert.doesNotDecrease = function(fn, obj, prop, msg) {
|
|
|
3721
3995
|
msg = prop;
|
|
3722
3996
|
prop = null;
|
|
3723
3997
|
}
|
|
3724
|
-
return new Assertion(fn, msg, assert.doesNotDecrease, true).to.not.decrease(
|
|
3998
|
+
return new Assertion(fn, msg, assert.doesNotDecrease, true).to.not.decrease(
|
|
3999
|
+
obj,
|
|
4000
|
+
prop
|
|
4001
|
+
);
|
|
3725
4002
|
};
|
|
3726
4003
|
assert.doesNotDecreaseBy = function(fn, obj, prop, delta, msg) {
|
|
3727
4004
|
if (arguments.length === 4 && typeof obj === "function") {
|
|
@@ -3774,15 +4051,38 @@ assert.isEmpty = function(val, msg) {
|
|
|
3774
4051
|
assert.isNotEmpty = function(val, msg) {
|
|
3775
4052
|
new Assertion(val, msg, assert.isNotEmpty, true).to.not.be.empty;
|
|
3776
4053
|
};
|
|
3777
|
-
|
|
4054
|
+
assert.containsSubset = function(val, exp, msg) {
|
|
4055
|
+
new Assertion(val, msg).to.containSubset(exp);
|
|
4056
|
+
};
|
|
4057
|
+
assert.doesNotContainSubset = function(val, exp, msg) {
|
|
4058
|
+
new Assertion(val, msg).to.not.containSubset(exp);
|
|
4059
|
+
};
|
|
4060
|
+
var aliases = [
|
|
4061
|
+
["isOk", "ok"],
|
|
4062
|
+
["isNotOk", "notOk"],
|
|
4063
|
+
["throws", "throw"],
|
|
4064
|
+
["throws", "Throw"],
|
|
4065
|
+
["isExtensible", "extensible"],
|
|
4066
|
+
["isNotExtensible", "notExtensible"],
|
|
4067
|
+
["isSealed", "sealed"],
|
|
4068
|
+
["isNotSealed", "notSealed"],
|
|
4069
|
+
["isFrozen", "frozen"],
|
|
4070
|
+
["isNotFrozen", "notFrozen"],
|
|
4071
|
+
["isEmpty", "empty"],
|
|
4072
|
+
["isNotEmpty", "notEmpty"],
|
|
4073
|
+
["isCallable", "isFunction"],
|
|
4074
|
+
["isNotCallable", "isNotFunction"],
|
|
4075
|
+
["containsSubset", "containSubset"]
|
|
4076
|
+
];
|
|
4077
|
+
for (const [name, as] of aliases) {
|
|
3778
4078
|
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");
|
|
4079
|
+
}
|
|
3781
4080
|
|
|
3782
4081
|
// lib/chai.js
|
|
3783
4082
|
var used = [];
|
|
3784
4083
|
function use(fn) {
|
|
3785
4084
|
const exports = {
|
|
4085
|
+
use,
|
|
3786
4086
|
AssertionError,
|
|
3787
4087
|
util: utils_exports,
|
|
3788
4088
|
config,
|