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
|
@@ -25,11 +25,7 @@ import {AssertionError} from 'assertion-error';
|
|
|
25
25
|
*/
|
|
26
26
|
export function assert(express, errmsg) {
|
|
27
27
|
var test = new Assertion(null, null, chai.assert, true);
|
|
28
|
-
test.assert(
|
|
29
|
-
express
|
|
30
|
-
, errmsg
|
|
31
|
-
, '[ negation message unavailable ]'
|
|
32
|
-
);
|
|
28
|
+
test.assert(express, errmsg, '[ negation message unavailable ]');
|
|
33
29
|
}
|
|
34
30
|
|
|
35
31
|
/**
|
|
@@ -55,18 +51,22 @@ export function assert(express, errmsg) {
|
|
|
55
51
|
*/
|
|
56
52
|
assert.fail = function (actual, expected, message, operator) {
|
|
57
53
|
if (arguments.length < 2) {
|
|
58
|
-
|
|
54
|
+
// Comply with Node's fail([message]) interface
|
|
59
55
|
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
message = actual;
|
|
57
|
+
actual = undefined;
|
|
62
58
|
}
|
|
63
59
|
|
|
64
60
|
message = message || 'assert.fail()';
|
|
65
|
-
throw new AssertionError(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
throw new AssertionError(
|
|
62
|
+
message,
|
|
63
|
+
{
|
|
64
|
+
actual: actual,
|
|
65
|
+
expected: expected,
|
|
66
|
+
operator: operator
|
|
67
|
+
},
|
|
68
|
+
assert.fail
|
|
69
|
+
);
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
/**
|
|
@@ -125,12 +125,12 @@ assert.equal = function (act, exp, msg) {
|
|
|
125
125
|
var test = new Assertion(act, msg, assert.equal, true);
|
|
126
126
|
|
|
127
127
|
test.assert(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
,
|
|
132
|
-
,
|
|
133
|
-
|
|
128
|
+
exp == flag(test, 'object'),
|
|
129
|
+
'expected #{this} to equal #{exp}',
|
|
130
|
+
'expected #{this} to not equal #{act}',
|
|
131
|
+
exp,
|
|
132
|
+
act,
|
|
133
|
+
true
|
|
134
134
|
);
|
|
135
135
|
};
|
|
136
136
|
|
|
@@ -152,12 +152,12 @@ assert.notEqual = function (act, exp, msg) {
|
|
|
152
152
|
var test = new Assertion(act, msg, assert.notEqual, true);
|
|
153
153
|
|
|
154
154
|
test.assert(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
,
|
|
159
|
-
,
|
|
160
|
-
|
|
155
|
+
exp != flag(test, 'object'),
|
|
156
|
+
'expected #{this} to not equal #{exp}',
|
|
157
|
+
'expected #{this} to equal #{act}',
|
|
158
|
+
exp,
|
|
159
|
+
act,
|
|
160
|
+
true
|
|
161
161
|
);
|
|
162
162
|
};
|
|
163
163
|
|
|
@@ -540,7 +540,7 @@ assert.isDefined = function (val, msg) {
|
|
|
540
540
|
*/
|
|
541
541
|
assert.isCallable = function (value, message) {
|
|
542
542
|
new Assertion(value, message, assert.isCallable, true).is.callable;
|
|
543
|
-
}
|
|
543
|
+
};
|
|
544
544
|
|
|
545
545
|
/**
|
|
546
546
|
* ### .isNotCallable(value, [message])
|
|
@@ -713,7 +713,7 @@ assert.isNotNumber = function (val, msg) {
|
|
|
713
713
|
*
|
|
714
714
|
* var cups = 2;
|
|
715
715
|
* assert.isNumeric(cups, 'how many cups');
|
|
716
|
-
*
|
|
716
|
+
*
|
|
717
717
|
* var cups = 10n;
|
|
718
718
|
* assert.isNumeric(cups, 'how many cups');
|
|
719
719
|
*
|
|
@@ -745,21 +745,21 @@ assert.isNotNumeric = function (val, msg) {
|
|
|
745
745
|
new Assertion(val, msg, assert.isNotNumeric, true).is.not.numeric;
|
|
746
746
|
};
|
|
747
747
|
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
748
|
+
/**
|
|
749
|
+
* ### .isFinite(value, [message])
|
|
750
|
+
*
|
|
751
|
+
* Asserts that `value` is a finite number. Unlike `.isNumber`, this will fail for `NaN` and `Infinity`.
|
|
752
|
+
*
|
|
753
|
+
* var cups = 2;
|
|
754
|
+
* assert.isFinite(cups, 'how many cups');
|
|
755
|
+
* assert.isFinite(NaN); // throws
|
|
756
|
+
*
|
|
757
|
+
* @name isFinite
|
|
758
|
+
* @param {number} val
|
|
759
|
+
* @param {string} msg
|
|
760
|
+
* @namespace Assert
|
|
761
|
+
* @public
|
|
762
|
+
*/
|
|
763
763
|
assert.isFinite = function (val, msg) {
|
|
764
764
|
new Assertion(val, msg, assert.isFinite, true).to.be.finite;
|
|
765
765
|
};
|
|
@@ -888,8 +888,9 @@ assert.instanceOf = function (val, type, msg) {
|
|
|
888
888
|
* @public
|
|
889
889
|
*/
|
|
890
890
|
assert.notInstanceOf = function (val, type, msg) {
|
|
891
|
-
new Assertion(val, msg, assert.notInstanceOf, true)
|
|
892
|
-
|
|
891
|
+
new Assertion(val, msg, assert.notInstanceOf, true).to.not.be.instanceOf(
|
|
892
|
+
type
|
|
893
|
+
);
|
|
893
894
|
};
|
|
894
895
|
|
|
895
896
|
/**
|
|
@@ -1054,8 +1055,9 @@ assert.nestedInclude = function (exp, inc, msg) {
|
|
|
1054
1055
|
* @public
|
|
1055
1056
|
*/
|
|
1056
1057
|
assert.notNestedInclude = function (exp, inc, msg) {
|
|
1057
|
-
new Assertion(exp, msg, assert.notNestedInclude, true)
|
|
1058
|
-
|
|
1058
|
+
new Assertion(exp, msg, assert.notNestedInclude, true).not.nested.include(
|
|
1059
|
+
inc
|
|
1060
|
+
);
|
|
1059
1061
|
};
|
|
1060
1062
|
|
|
1061
1063
|
/**
|
|
@@ -1078,9 +1080,10 @@ assert.notNestedInclude = function (exp, inc, msg) {
|
|
|
1078
1080
|
* @namespace Assert
|
|
1079
1081
|
* @public
|
|
1080
1082
|
*/
|
|
1081
|
-
assert.deepNestedInclude = function(exp, inc, msg) {
|
|
1082
|
-
new Assertion(exp, msg, assert.deepNestedInclude, true)
|
|
1083
|
-
|
|
1083
|
+
assert.deepNestedInclude = function (exp, inc, msg) {
|
|
1084
|
+
new Assertion(exp, msg, assert.deepNestedInclude, true).deep.nested.include(
|
|
1085
|
+
inc
|
|
1086
|
+
);
|
|
1084
1087
|
};
|
|
1085
1088
|
|
|
1086
1089
|
/**
|
|
@@ -1103,9 +1106,13 @@ assert.deepNestedInclude = function(exp, inc, msg) {
|
|
|
1103
1106
|
* @namespace Assert
|
|
1104
1107
|
* @public
|
|
1105
1108
|
*/
|
|
1106
|
-
assert.notDeepNestedInclude = function(exp, inc, msg) {
|
|
1107
|
-
new Assertion(
|
|
1108
|
-
|
|
1109
|
+
assert.notDeepNestedInclude = function (exp, inc, msg) {
|
|
1110
|
+
new Assertion(
|
|
1111
|
+
exp,
|
|
1112
|
+
msg,
|
|
1113
|
+
assert.notDeepNestedInclude,
|
|
1114
|
+
true
|
|
1115
|
+
).not.deep.nested.include(inc);
|
|
1109
1116
|
};
|
|
1110
1117
|
|
|
1111
1118
|
/**
|
|
@@ -1124,7 +1131,7 @@ assert.notDeepNestedInclude = function(exp, inc, msg) {
|
|
|
1124
1131
|
* @namespace Assert
|
|
1125
1132
|
* @public
|
|
1126
1133
|
*/
|
|
1127
|
-
assert.ownInclude = function(exp, inc, msg) {
|
|
1134
|
+
assert.ownInclude = function (exp, inc, msg) {
|
|
1128
1135
|
new Assertion(exp, msg, assert.ownInclude, true).own.include(inc);
|
|
1129
1136
|
};
|
|
1130
1137
|
|
|
@@ -1145,7 +1152,7 @@ assert.ownInclude = function(exp, inc, msg) {
|
|
|
1145
1152
|
* @namespace Assert
|
|
1146
1153
|
* @public
|
|
1147
1154
|
*/
|
|
1148
|
-
assert.notOwnInclude = function(exp, inc, msg) {
|
|
1155
|
+
assert.notOwnInclude = function (exp, inc, msg) {
|
|
1149
1156
|
new Assertion(exp, msg, assert.notOwnInclude, true).not.own.include(inc);
|
|
1150
1157
|
};
|
|
1151
1158
|
|
|
@@ -1165,9 +1172,8 @@ assert.notOwnInclude = function(exp, inc, msg) {
|
|
|
1165
1172
|
* @namespace Assert
|
|
1166
1173
|
* @public
|
|
1167
1174
|
*/
|
|
1168
|
-
assert.deepOwnInclude = function(exp, inc, msg) {
|
|
1169
|
-
new Assertion(exp, msg, assert.deepOwnInclude, true)
|
|
1170
|
-
.deep.own.include(inc);
|
|
1175
|
+
assert.deepOwnInclude = function (exp, inc, msg) {
|
|
1176
|
+
new Assertion(exp, msg, assert.deepOwnInclude, true).deep.own.include(inc);
|
|
1171
1177
|
};
|
|
1172
1178
|
|
|
1173
1179
|
/**
|
|
@@ -1186,9 +1192,10 @@ assert.deepOwnInclude = function(exp, inc, msg) {
|
|
|
1186
1192
|
* @namespace Assert
|
|
1187
1193
|
* @public
|
|
1188
1194
|
*/
|
|
1189
|
-
assert.notDeepOwnInclude = function(exp, inc, msg) {
|
|
1190
|
-
new Assertion(exp, msg, assert.notDeepOwnInclude, true)
|
|
1191
|
-
|
|
1195
|
+
assert.notDeepOwnInclude = function (exp, inc, msg) {
|
|
1196
|
+
new Assertion(exp, msg, assert.notDeepOwnInclude, true).not.deep.own.include(
|
|
1197
|
+
inc
|
|
1198
|
+
);
|
|
1192
1199
|
};
|
|
1193
1200
|
|
|
1194
1201
|
/**
|
|
@@ -1263,8 +1270,7 @@ assert.property = function (obj, prop, msg) {
|
|
|
1263
1270
|
* @public
|
|
1264
1271
|
*/
|
|
1265
1272
|
assert.notProperty = function (obj, prop, msg) {
|
|
1266
|
-
new Assertion(obj, msg, assert.notProperty, true)
|
|
1267
|
-
.to.not.have.property(prop);
|
|
1273
|
+
new Assertion(obj, msg, assert.notProperty, true).to.not.have.property(prop);
|
|
1268
1274
|
};
|
|
1269
1275
|
|
|
1270
1276
|
/**
|
|
@@ -1285,8 +1291,7 @@ assert.notProperty = function (obj, prop, msg) {
|
|
|
1285
1291
|
* @public
|
|
1286
1292
|
*/
|
|
1287
1293
|
assert.propertyVal = function (obj, prop, val, msg) {
|
|
1288
|
-
new Assertion(obj, msg, assert.propertyVal, true)
|
|
1289
|
-
.to.have.property(prop, val);
|
|
1294
|
+
new Assertion(obj, msg, assert.propertyVal, true).to.have.property(prop, val);
|
|
1290
1295
|
};
|
|
1291
1296
|
|
|
1292
1297
|
/**
|
|
@@ -1308,8 +1313,10 @@ assert.propertyVal = function (obj, prop, val, msg) {
|
|
|
1308
1313
|
* @public
|
|
1309
1314
|
*/
|
|
1310
1315
|
assert.notPropertyVal = function (obj, prop, val, msg) {
|
|
1311
|
-
new Assertion(obj, msg, assert.notPropertyVal, true)
|
|
1312
|
-
|
|
1316
|
+
new Assertion(obj, msg, assert.notPropertyVal, true).to.not.have.property(
|
|
1317
|
+
prop,
|
|
1318
|
+
val
|
|
1319
|
+
);
|
|
1313
1320
|
};
|
|
1314
1321
|
|
|
1315
1322
|
/**
|
|
@@ -1329,8 +1336,10 @@ assert.notPropertyVal = function (obj, prop, val, msg) {
|
|
|
1329
1336
|
* @public
|
|
1330
1337
|
*/
|
|
1331
1338
|
assert.deepPropertyVal = function (obj, prop, val, msg) {
|
|
1332
|
-
new Assertion(obj, msg, assert.deepPropertyVal, true)
|
|
1333
|
-
|
|
1339
|
+
new Assertion(obj, msg, assert.deepPropertyVal, true).to.have.deep.property(
|
|
1340
|
+
prop,
|
|
1341
|
+
val
|
|
1342
|
+
);
|
|
1334
1343
|
};
|
|
1335
1344
|
|
|
1336
1345
|
/**
|
|
@@ -1352,8 +1361,12 @@ assert.deepPropertyVal = function (obj, prop, val, msg) {
|
|
|
1352
1361
|
* @public
|
|
1353
1362
|
*/
|
|
1354
1363
|
assert.notDeepPropertyVal = function (obj, prop, val, msg) {
|
|
1355
|
-
new Assertion(
|
|
1356
|
-
|
|
1364
|
+
new Assertion(
|
|
1365
|
+
obj,
|
|
1366
|
+
msg,
|
|
1367
|
+
assert.notDeepPropertyVal,
|
|
1368
|
+
true
|
|
1369
|
+
).to.not.have.deep.property(prop, val);
|
|
1357
1370
|
};
|
|
1358
1371
|
|
|
1359
1372
|
/**
|
|
@@ -1371,8 +1384,7 @@ assert.notDeepPropertyVal = function (obj, prop, val, msg) {
|
|
|
1371
1384
|
* @public
|
|
1372
1385
|
*/
|
|
1373
1386
|
assert.ownProperty = function (obj, prop, msg) {
|
|
1374
|
-
new Assertion(obj, msg, assert.ownProperty, true)
|
|
1375
|
-
.to.have.own.property(prop);
|
|
1387
|
+
new Assertion(obj, msg, assert.ownProperty, true).to.have.own.property(prop);
|
|
1376
1388
|
};
|
|
1377
1389
|
|
|
1378
1390
|
/**
|
|
@@ -1391,8 +1403,9 @@ assert.ownProperty = function (obj, prop, msg) {
|
|
|
1391
1403
|
* @public
|
|
1392
1404
|
*/
|
|
1393
1405
|
assert.notOwnProperty = function (obj, prop, msg) {
|
|
1394
|
-
new Assertion(obj, msg, assert.notOwnProperty, true)
|
|
1395
|
-
|
|
1406
|
+
new Assertion(obj, msg, assert.notOwnProperty, true).to.not.have.own.property(
|
|
1407
|
+
prop
|
|
1408
|
+
);
|
|
1396
1409
|
};
|
|
1397
1410
|
|
|
1398
1411
|
/**
|
|
@@ -1412,8 +1425,10 @@ assert.notOwnProperty = function (obj, prop, msg) {
|
|
|
1412
1425
|
* @public
|
|
1413
1426
|
*/
|
|
1414
1427
|
assert.ownPropertyVal = function (obj, prop, value, msg) {
|
|
1415
|
-
new Assertion(obj, msg, assert.ownPropertyVal, true)
|
|
1416
|
-
|
|
1428
|
+
new Assertion(obj, msg, assert.ownPropertyVal, true).to.have.own.property(
|
|
1429
|
+
prop,
|
|
1430
|
+
value
|
|
1431
|
+
);
|
|
1417
1432
|
};
|
|
1418
1433
|
|
|
1419
1434
|
/**
|
|
@@ -1434,8 +1449,12 @@ assert.ownPropertyVal = function (obj, prop, value, msg) {
|
|
|
1434
1449
|
* @public
|
|
1435
1450
|
*/
|
|
1436
1451
|
assert.notOwnPropertyVal = function (obj, prop, value, msg) {
|
|
1437
|
-
new Assertion(
|
|
1438
|
-
|
|
1452
|
+
new Assertion(
|
|
1453
|
+
obj,
|
|
1454
|
+
msg,
|
|
1455
|
+
assert.notOwnPropertyVal,
|
|
1456
|
+
true
|
|
1457
|
+
).to.not.have.own.property(prop, value);
|
|
1439
1458
|
};
|
|
1440
1459
|
|
|
1441
1460
|
/**
|
|
@@ -1455,8 +1474,12 @@ assert.notOwnPropertyVal = function (obj, prop, value, msg) {
|
|
|
1455
1474
|
* @public
|
|
1456
1475
|
*/
|
|
1457
1476
|
assert.deepOwnPropertyVal = function (obj, prop, value, msg) {
|
|
1458
|
-
new Assertion(
|
|
1459
|
-
|
|
1477
|
+
new Assertion(
|
|
1478
|
+
obj,
|
|
1479
|
+
msg,
|
|
1480
|
+
assert.deepOwnPropertyVal,
|
|
1481
|
+
true
|
|
1482
|
+
).to.have.deep.own.property(prop, value);
|
|
1460
1483
|
};
|
|
1461
1484
|
|
|
1462
1485
|
/**
|
|
@@ -1479,8 +1502,12 @@ assert.deepOwnPropertyVal = function (obj, prop, value, msg) {
|
|
|
1479
1502
|
* @public
|
|
1480
1503
|
*/
|
|
1481
1504
|
assert.notDeepOwnPropertyVal = function (obj, prop, value, msg) {
|
|
1482
|
-
new Assertion(
|
|
1483
|
-
|
|
1505
|
+
new Assertion(
|
|
1506
|
+
obj,
|
|
1507
|
+
msg,
|
|
1508
|
+
assert.notDeepOwnPropertyVal,
|
|
1509
|
+
true
|
|
1510
|
+
).to.not.have.deep.own.property(prop, value);
|
|
1484
1511
|
};
|
|
1485
1512
|
|
|
1486
1513
|
/**
|
|
@@ -1500,8 +1527,9 @@ assert.notDeepOwnPropertyVal = function (obj, prop, value, msg) {
|
|
|
1500
1527
|
* @public
|
|
1501
1528
|
*/
|
|
1502
1529
|
assert.nestedProperty = function (obj, prop, msg) {
|
|
1503
|
-
new Assertion(obj, msg, assert.nestedProperty, true)
|
|
1504
|
-
|
|
1530
|
+
new Assertion(obj, msg, assert.nestedProperty, true).to.have.nested.property(
|
|
1531
|
+
prop
|
|
1532
|
+
);
|
|
1505
1533
|
};
|
|
1506
1534
|
|
|
1507
1535
|
/**
|
|
@@ -1521,8 +1549,12 @@ assert.nestedProperty = function (obj, prop, msg) {
|
|
|
1521
1549
|
* @public
|
|
1522
1550
|
*/
|
|
1523
1551
|
assert.notNestedProperty = function (obj, prop, msg) {
|
|
1524
|
-
new Assertion(
|
|
1525
|
-
|
|
1552
|
+
new Assertion(
|
|
1553
|
+
obj,
|
|
1554
|
+
msg,
|
|
1555
|
+
assert.notNestedProperty,
|
|
1556
|
+
true
|
|
1557
|
+
).to.not.have.nested.property(prop);
|
|
1526
1558
|
};
|
|
1527
1559
|
|
|
1528
1560
|
/**
|
|
@@ -1543,8 +1575,12 @@ assert.notNestedProperty = function (obj, prop, msg) {
|
|
|
1543
1575
|
* @public
|
|
1544
1576
|
*/
|
|
1545
1577
|
assert.nestedPropertyVal = function (obj, prop, val, msg) {
|
|
1546
|
-
new Assertion(
|
|
1547
|
-
|
|
1578
|
+
new Assertion(
|
|
1579
|
+
obj,
|
|
1580
|
+
msg,
|
|
1581
|
+
assert.nestedPropertyVal,
|
|
1582
|
+
true
|
|
1583
|
+
).to.have.nested.property(prop, val);
|
|
1548
1584
|
};
|
|
1549
1585
|
|
|
1550
1586
|
/**
|
|
@@ -1566,8 +1602,12 @@ assert.nestedPropertyVal = function (obj, prop, val, msg) {
|
|
|
1566
1602
|
* @public
|
|
1567
1603
|
*/
|
|
1568
1604
|
assert.notNestedPropertyVal = function (obj, prop, val, msg) {
|
|
1569
|
-
new Assertion(
|
|
1570
|
-
|
|
1605
|
+
new Assertion(
|
|
1606
|
+
obj,
|
|
1607
|
+
msg,
|
|
1608
|
+
assert.notNestedPropertyVal,
|
|
1609
|
+
true
|
|
1610
|
+
).to.not.have.nested.property(prop, val);
|
|
1571
1611
|
};
|
|
1572
1612
|
|
|
1573
1613
|
/**
|
|
@@ -1588,8 +1628,12 @@ assert.notNestedPropertyVal = function (obj, prop, val, msg) {
|
|
|
1588
1628
|
* @public
|
|
1589
1629
|
*/
|
|
1590
1630
|
assert.deepNestedPropertyVal = function (obj, prop, val, msg) {
|
|
1591
|
-
new Assertion(
|
|
1592
|
-
|
|
1631
|
+
new Assertion(
|
|
1632
|
+
obj,
|
|
1633
|
+
msg,
|
|
1634
|
+
assert.deepNestedPropertyVal,
|
|
1635
|
+
true
|
|
1636
|
+
).to.have.deep.nested.property(prop, val);
|
|
1593
1637
|
};
|
|
1594
1638
|
|
|
1595
1639
|
/**
|
|
@@ -1612,9 +1656,13 @@ assert.deepNestedPropertyVal = function (obj, prop, val, msg) {
|
|
|
1612
1656
|
* @public
|
|
1613
1657
|
*/
|
|
1614
1658
|
assert.notDeepNestedPropertyVal = function (obj, prop, val, msg) {
|
|
1615
|
-
new Assertion(
|
|
1616
|
-
|
|
1617
|
-
|
|
1659
|
+
new Assertion(
|
|
1660
|
+
obj,
|
|
1661
|
+
msg,
|
|
1662
|
+
assert.notDeepNestedPropertyVal,
|
|
1663
|
+
true
|
|
1664
|
+
).to.not.have.deep.nested.property(prop, val);
|
|
1665
|
+
};
|
|
1618
1666
|
|
|
1619
1667
|
/**
|
|
1620
1668
|
* ### .lengthOf(object, length, [message])
|
|
@@ -1658,7 +1706,7 @@ assert.lengthOf = function (exp, len, msg) {
|
|
|
1658
1706
|
*/
|
|
1659
1707
|
assert.hasAnyKeys = function (obj, keys, msg) {
|
|
1660
1708
|
new Assertion(obj, msg, assert.hasAnyKeys, true).to.have.any.keys(keys);
|
|
1661
|
-
}
|
|
1709
|
+
};
|
|
1662
1710
|
|
|
1663
1711
|
/**
|
|
1664
1712
|
* ### .hasAllKeys(object, [keys], [message])
|
|
@@ -1681,7 +1729,7 @@ assert.hasAnyKeys = function (obj, keys, msg) {
|
|
|
1681
1729
|
*/
|
|
1682
1730
|
assert.hasAllKeys = function (obj, keys, msg) {
|
|
1683
1731
|
new Assertion(obj, msg, assert.hasAllKeys, true).to.have.all.keys(keys);
|
|
1684
|
-
}
|
|
1732
|
+
};
|
|
1685
1733
|
|
|
1686
1734
|
/**
|
|
1687
1735
|
* ### .containsAllKeys(object, [keys], [message])
|
|
@@ -1707,9 +1755,10 @@ assert.hasAllKeys = function (obj, keys, msg) {
|
|
|
1707
1755
|
* @public
|
|
1708
1756
|
*/
|
|
1709
1757
|
assert.containsAllKeys = function (obj, keys, msg) {
|
|
1710
|
-
new Assertion(obj, msg, assert.containsAllKeys, true)
|
|
1711
|
-
|
|
1712
|
-
|
|
1758
|
+
new Assertion(obj, msg, assert.containsAllKeys, true).to.contain.all.keys(
|
|
1759
|
+
keys
|
|
1760
|
+
);
|
|
1761
|
+
};
|
|
1713
1762
|
|
|
1714
1763
|
/**
|
|
1715
1764
|
* ### .doesNotHaveAnyKeys(object, [keys], [message])
|
|
@@ -1731,9 +1780,10 @@ assert.containsAllKeys = function (obj, keys, msg) {
|
|
|
1731
1780
|
* @public
|
|
1732
1781
|
*/
|
|
1733
1782
|
assert.doesNotHaveAnyKeys = function (obj, keys, msg) {
|
|
1734
|
-
new Assertion(obj, msg, assert.doesNotHaveAnyKeys, true)
|
|
1735
|
-
|
|
1736
|
-
|
|
1783
|
+
new Assertion(obj, msg, assert.doesNotHaveAnyKeys, true).to.not.have.any.keys(
|
|
1784
|
+
keys
|
|
1785
|
+
);
|
|
1786
|
+
};
|
|
1737
1787
|
|
|
1738
1788
|
/**
|
|
1739
1789
|
* ### .doesNotHaveAllKeys(object, [keys], [message])
|
|
@@ -1755,9 +1805,10 @@ assert.doesNotHaveAnyKeys = function (obj, keys, msg) {
|
|
|
1755
1805
|
* @public
|
|
1756
1806
|
*/
|
|
1757
1807
|
assert.doesNotHaveAllKeys = function (obj, keys, msg) {
|
|
1758
|
-
new Assertion(obj, msg, assert.doesNotHaveAllKeys, true)
|
|
1759
|
-
|
|
1760
|
-
|
|
1808
|
+
new Assertion(obj, msg, assert.doesNotHaveAllKeys, true).to.not.have.all.keys(
|
|
1809
|
+
keys
|
|
1810
|
+
);
|
|
1811
|
+
};
|
|
1761
1812
|
|
|
1762
1813
|
/**
|
|
1763
1814
|
* ### .hasAnyDeepKeys(object, [keys], [message])
|
|
@@ -1783,9 +1834,10 @@ assert.doesNotHaveAllKeys = function (obj, keys, msg) {
|
|
|
1783
1834
|
* @public
|
|
1784
1835
|
*/
|
|
1785
1836
|
assert.hasAnyDeepKeys = function (obj, keys, msg) {
|
|
1786
|
-
new Assertion(obj, msg, assert.hasAnyDeepKeys, true)
|
|
1787
|
-
|
|
1788
|
-
|
|
1837
|
+
new Assertion(obj, msg, assert.hasAnyDeepKeys, true).to.have.any.deep.keys(
|
|
1838
|
+
keys
|
|
1839
|
+
);
|
|
1840
|
+
};
|
|
1789
1841
|
|
|
1790
1842
|
/**
|
|
1791
1843
|
* ### .hasAllDeepKeys(object, [keys], [message])
|
|
@@ -1809,9 +1861,10 @@ assert.hasAnyDeepKeys = function (obj, keys, msg) {
|
|
|
1809
1861
|
* @public
|
|
1810
1862
|
*/
|
|
1811
1863
|
assert.hasAllDeepKeys = function (obj, keys, msg) {
|
|
1812
|
-
new Assertion(obj, msg, assert.hasAllDeepKeys, true)
|
|
1813
|
-
|
|
1814
|
-
|
|
1864
|
+
new Assertion(obj, msg, assert.hasAllDeepKeys, true).to.have.all.deep.keys(
|
|
1865
|
+
keys
|
|
1866
|
+
);
|
|
1867
|
+
};
|
|
1815
1868
|
|
|
1816
1869
|
/**
|
|
1817
1870
|
* ### .containsAllDeepKeys(object, [keys], [message])
|
|
@@ -1835,9 +1888,13 @@ assert.hasAllDeepKeys = function (obj, keys, msg) {
|
|
|
1835
1888
|
* @public
|
|
1836
1889
|
*/
|
|
1837
1890
|
assert.containsAllDeepKeys = function (obj, keys, msg) {
|
|
1838
|
-
new Assertion(
|
|
1839
|
-
|
|
1840
|
-
|
|
1891
|
+
new Assertion(
|
|
1892
|
+
obj,
|
|
1893
|
+
msg,
|
|
1894
|
+
assert.containsAllDeepKeys,
|
|
1895
|
+
true
|
|
1896
|
+
).to.contain.all.deep.keys(keys);
|
|
1897
|
+
};
|
|
1841
1898
|
|
|
1842
1899
|
/**
|
|
1843
1900
|
* ### .doesNotHaveAnyDeepKeys(object, [keys], [message])
|
|
@@ -1861,9 +1918,13 @@ assert.containsAllDeepKeys = function (obj, keys, msg) {
|
|
|
1861
1918
|
* @public
|
|
1862
1919
|
*/
|
|
1863
1920
|
assert.doesNotHaveAnyDeepKeys = function (obj, keys, msg) {
|
|
1864
|
-
new Assertion(
|
|
1865
|
-
|
|
1866
|
-
|
|
1921
|
+
new Assertion(
|
|
1922
|
+
obj,
|
|
1923
|
+
msg,
|
|
1924
|
+
assert.doesNotHaveAnyDeepKeys,
|
|
1925
|
+
true
|
|
1926
|
+
).to.not.have.any.deep.keys(keys);
|
|
1927
|
+
};
|
|
1867
1928
|
|
|
1868
1929
|
/**
|
|
1869
1930
|
* ### .doesNotHaveAllDeepKeys(object, [keys], [message])
|
|
@@ -1887,9 +1948,13 @@ assert.doesNotHaveAnyDeepKeys = function (obj, keys, msg) {
|
|
|
1887
1948
|
* @public
|
|
1888
1949
|
*/
|
|
1889
1950
|
assert.doesNotHaveAllDeepKeys = function (obj, keys, msg) {
|
|
1890
|
-
new Assertion(
|
|
1891
|
-
|
|
1892
|
-
|
|
1951
|
+
new Assertion(
|
|
1952
|
+
obj,
|
|
1953
|
+
msg,
|
|
1954
|
+
assert.doesNotHaveAllDeepKeys,
|
|
1955
|
+
true
|
|
1956
|
+
).to.not.have.all.deep.keys(keys);
|
|
1957
|
+
};
|
|
1893
1958
|
|
|
1894
1959
|
/**
|
|
1895
1960
|
* ### .throws(fn, [errorLike/string/regexp], [string/regexp], [message])
|
|
@@ -1928,8 +1993,10 @@ assert.throws = function (fn, errorLike, errMsgMatcher, msg) {
|
|
|
1928
1993
|
errorLike = null;
|
|
1929
1994
|
}
|
|
1930
1995
|
|
|
1931
|
-
var assertErr = new Assertion(fn, msg, assert.throws, true)
|
|
1932
|
-
|
|
1996
|
+
var assertErr = new Assertion(fn, msg, assert.throws, true).to.throw(
|
|
1997
|
+
errorLike,
|
|
1998
|
+
errMsgMatcher
|
|
1999
|
+
);
|
|
1933
2000
|
return flag(assertErr, 'object');
|
|
1934
2001
|
};
|
|
1935
2002
|
|
|
@@ -1967,8 +2034,10 @@ assert.doesNotThrow = function (fn, errorLike, errMsgMatcher, message) {
|
|
|
1967
2034
|
errorLike = null;
|
|
1968
2035
|
}
|
|
1969
2036
|
|
|
1970
|
-
new Assertion(fn, message, assert.doesNotThrow, true)
|
|
1971
|
-
|
|
2037
|
+
new Assertion(fn, message, assert.doesNotThrow, true).to.not.throw(
|
|
2038
|
+
errorLike,
|
|
2039
|
+
errMsgMatcher
|
|
2040
|
+
);
|
|
1972
2041
|
};
|
|
1973
2042
|
|
|
1974
2043
|
/**
|
|
@@ -1989,7 +2058,7 @@ assert.doesNotThrow = function (fn, errorLike, errMsgMatcher, message) {
|
|
|
1989
2058
|
*/
|
|
1990
2059
|
assert.operator = function (val, operator, val2, msg) {
|
|
1991
2060
|
var ok;
|
|
1992
|
-
switch(operator) {
|
|
2061
|
+
switch (operator) {
|
|
1993
2062
|
case '==':
|
|
1994
2063
|
ok = val == val2;
|
|
1995
2064
|
break;
|
|
@@ -2024,9 +2093,10 @@ assert.operator = function (val, operator, val2, msg) {
|
|
|
2024
2093
|
}
|
|
2025
2094
|
var test = new Assertion(ok, msg, assert.operator, true);
|
|
2026
2095
|
test.assert(
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2096
|
+
true === flag(test, 'object'),
|
|
2097
|
+
'expected ' + inspect(val) + ' to be ' + operator + ' ' + inspect(val2),
|
|
2098
|
+
'expected ' + inspect(val) + ' to not be ' + operator + ' ' + inspect(val2)
|
|
2099
|
+
);
|
|
2030
2100
|
};
|
|
2031
2101
|
|
|
2032
2102
|
/**
|
|
@@ -2064,8 +2134,10 @@ assert.closeTo = function (act, exp, delta, msg) {
|
|
|
2064
2134
|
* @public
|
|
2065
2135
|
*/
|
|
2066
2136
|
assert.approximately = function (act, exp, delta, msg) {
|
|
2067
|
-
new Assertion(act, msg, assert.approximately, true)
|
|
2068
|
-
|
|
2137
|
+
new Assertion(act, msg, assert.approximately, true).to.be.approximately(
|
|
2138
|
+
exp,
|
|
2139
|
+
delta
|
|
2140
|
+
);
|
|
2069
2141
|
};
|
|
2070
2142
|
|
|
2071
2143
|
/**
|
|
@@ -2084,9 +2156,8 @@ assert.approximately = function (act, exp, delta, msg) {
|
|
|
2084
2156
|
* @public
|
|
2085
2157
|
*/
|
|
2086
2158
|
assert.sameMembers = function (set1, set2, msg) {
|
|
2087
|
-
new Assertion(set1, msg, assert.sameMembers, true)
|
|
2088
|
-
|
|
2089
|
-
}
|
|
2159
|
+
new Assertion(set1, msg, assert.sameMembers, true).to.have.same.members(set2);
|
|
2160
|
+
};
|
|
2090
2161
|
|
|
2091
2162
|
/**
|
|
2092
2163
|
* ### .notSameMembers(set1, set2, [message])
|
|
@@ -2104,9 +2175,13 @@ assert.sameMembers = function (set1, set2, msg) {
|
|
|
2104
2175
|
* @public
|
|
2105
2176
|
*/
|
|
2106
2177
|
assert.notSameMembers = function (set1, set2, msg) {
|
|
2107
|
-
new Assertion(
|
|
2108
|
-
|
|
2109
|
-
|
|
2178
|
+
new Assertion(
|
|
2179
|
+
set1,
|
|
2180
|
+
msg,
|
|
2181
|
+
assert.notSameMembers,
|
|
2182
|
+
true
|
|
2183
|
+
).to.not.have.same.members(set2);
|
|
2184
|
+
};
|
|
2110
2185
|
|
|
2111
2186
|
/**
|
|
2112
2187
|
* ### .sameDeepMembers(set1, set2, [message])
|
|
@@ -2124,9 +2199,13 @@ assert.notSameMembers = function (set1, set2, msg) {
|
|
|
2124
2199
|
* @public
|
|
2125
2200
|
*/
|
|
2126
2201
|
assert.sameDeepMembers = function (set1, set2, msg) {
|
|
2127
|
-
new Assertion(
|
|
2128
|
-
|
|
2129
|
-
|
|
2202
|
+
new Assertion(
|
|
2203
|
+
set1,
|
|
2204
|
+
msg,
|
|
2205
|
+
assert.sameDeepMembers,
|
|
2206
|
+
true
|
|
2207
|
+
).to.have.same.deep.members(set2);
|
|
2208
|
+
};
|
|
2130
2209
|
|
|
2131
2210
|
/**
|
|
2132
2211
|
* ### .notSameDeepMembers(set1, set2, [message])
|
|
@@ -2144,9 +2223,13 @@ assert.sameDeepMembers = function (set1, set2, msg) {
|
|
|
2144
2223
|
* @public
|
|
2145
2224
|
*/
|
|
2146
2225
|
assert.notSameDeepMembers = function (set1, set2, msg) {
|
|
2147
|
-
new Assertion(
|
|
2148
|
-
|
|
2149
|
-
|
|
2226
|
+
new Assertion(
|
|
2227
|
+
set1,
|
|
2228
|
+
msg,
|
|
2229
|
+
assert.notSameDeepMembers,
|
|
2230
|
+
true
|
|
2231
|
+
).to.not.have.same.deep.members(set2);
|
|
2232
|
+
};
|
|
2150
2233
|
|
|
2151
2234
|
/**
|
|
2152
2235
|
* ### .sameOrderedMembers(set1, set2, [message])
|
|
@@ -2164,9 +2247,13 @@ assert.notSameDeepMembers = function (set1, set2, msg) {
|
|
|
2164
2247
|
* @public
|
|
2165
2248
|
*/
|
|
2166
2249
|
assert.sameOrderedMembers = function (set1, set2, msg) {
|
|
2167
|
-
new Assertion(
|
|
2168
|
-
|
|
2169
|
-
|
|
2250
|
+
new Assertion(
|
|
2251
|
+
set1,
|
|
2252
|
+
msg,
|
|
2253
|
+
assert.sameOrderedMembers,
|
|
2254
|
+
true
|
|
2255
|
+
).to.have.same.ordered.members(set2);
|
|
2256
|
+
};
|
|
2170
2257
|
|
|
2171
2258
|
/**
|
|
2172
2259
|
* ### .notSameOrderedMembers(set1, set2, [message])
|
|
@@ -2184,9 +2271,13 @@ assert.sameOrderedMembers = function (set1, set2, msg) {
|
|
|
2184
2271
|
* @public
|
|
2185
2272
|
*/
|
|
2186
2273
|
assert.notSameOrderedMembers = function (set1, set2, msg) {
|
|
2187
|
-
new Assertion(
|
|
2188
|
-
|
|
2189
|
-
|
|
2274
|
+
new Assertion(
|
|
2275
|
+
set1,
|
|
2276
|
+
msg,
|
|
2277
|
+
assert.notSameOrderedMembers,
|
|
2278
|
+
true
|
|
2279
|
+
).to.not.have.same.ordered.members(set2);
|
|
2280
|
+
};
|
|
2190
2281
|
|
|
2191
2282
|
/**
|
|
2192
2283
|
* ### .sameDeepOrderedMembers(set1, set2, [message])
|
|
@@ -2204,9 +2295,13 @@ assert.notSameOrderedMembers = function (set1, set2, msg) {
|
|
|
2204
2295
|
* @public
|
|
2205
2296
|
*/
|
|
2206
2297
|
assert.sameDeepOrderedMembers = function (set1, set2, msg) {
|
|
2207
|
-
new Assertion(
|
|
2208
|
-
|
|
2209
|
-
|
|
2298
|
+
new Assertion(
|
|
2299
|
+
set1,
|
|
2300
|
+
msg,
|
|
2301
|
+
assert.sameDeepOrderedMembers,
|
|
2302
|
+
true
|
|
2303
|
+
).to.have.same.deep.ordered.members(set2);
|
|
2304
|
+
};
|
|
2210
2305
|
|
|
2211
2306
|
/**
|
|
2212
2307
|
* ### .notSameDeepOrderedMembers(set1, set2, [message])
|
|
@@ -2225,9 +2320,13 @@ assert.sameDeepOrderedMembers = function (set1, set2, msg) {
|
|
|
2225
2320
|
* @public
|
|
2226
2321
|
*/
|
|
2227
2322
|
assert.notSameDeepOrderedMembers = function (set1, set2, msg) {
|
|
2228
|
-
new Assertion(
|
|
2229
|
-
|
|
2230
|
-
|
|
2323
|
+
new Assertion(
|
|
2324
|
+
set1,
|
|
2325
|
+
msg,
|
|
2326
|
+
assert.notSameDeepOrderedMembers,
|
|
2327
|
+
true
|
|
2328
|
+
).to.not.have.same.deep.ordered.members(set2);
|
|
2329
|
+
};
|
|
2231
2330
|
|
|
2232
2331
|
/**
|
|
2233
2332
|
* ### .includeMembers(superset, subset, [message])
|
|
@@ -2245,9 +2344,10 @@ assert.notSameDeepOrderedMembers = function (set1, set2, msg) {
|
|
|
2245
2344
|
* @public
|
|
2246
2345
|
*/
|
|
2247
2346
|
assert.includeMembers = function (superset, subset, msg) {
|
|
2248
|
-
new Assertion(superset, msg, assert.includeMembers, true)
|
|
2249
|
-
|
|
2250
|
-
|
|
2347
|
+
new Assertion(superset, msg, assert.includeMembers, true).to.include.members(
|
|
2348
|
+
subset
|
|
2349
|
+
);
|
|
2350
|
+
};
|
|
2251
2351
|
|
|
2252
2352
|
/**
|
|
2253
2353
|
* ### .notIncludeMembers(superset, subset, [message])
|
|
@@ -2265,9 +2365,13 @@ assert.includeMembers = function (superset, subset, msg) {
|
|
|
2265
2365
|
* @public
|
|
2266
2366
|
*/
|
|
2267
2367
|
assert.notIncludeMembers = function (superset, subset, msg) {
|
|
2268
|
-
new Assertion(
|
|
2269
|
-
|
|
2270
|
-
|
|
2368
|
+
new Assertion(
|
|
2369
|
+
superset,
|
|
2370
|
+
msg,
|
|
2371
|
+
assert.notIncludeMembers,
|
|
2372
|
+
true
|
|
2373
|
+
).to.not.include.members(subset);
|
|
2374
|
+
};
|
|
2271
2375
|
|
|
2272
2376
|
/**
|
|
2273
2377
|
* ### .includeDeepMembers(superset, subset, [message])
|
|
@@ -2285,9 +2389,13 @@ assert.notIncludeMembers = function (superset, subset, msg) {
|
|
|
2285
2389
|
* @public
|
|
2286
2390
|
*/
|
|
2287
2391
|
assert.includeDeepMembers = function (superset, subset, msg) {
|
|
2288
|
-
new Assertion(
|
|
2289
|
-
|
|
2290
|
-
|
|
2392
|
+
new Assertion(
|
|
2393
|
+
superset,
|
|
2394
|
+
msg,
|
|
2395
|
+
assert.includeDeepMembers,
|
|
2396
|
+
true
|
|
2397
|
+
).to.include.deep.members(subset);
|
|
2398
|
+
};
|
|
2291
2399
|
|
|
2292
2400
|
/**
|
|
2293
2401
|
* ### .notIncludeDeepMembers(superset, subset, [message])
|
|
@@ -2305,9 +2413,13 @@ assert.includeDeepMembers = function (superset, subset, msg) {
|
|
|
2305
2413
|
* @public
|
|
2306
2414
|
*/
|
|
2307
2415
|
assert.notIncludeDeepMembers = function (superset, subset, msg) {
|
|
2308
|
-
new Assertion(
|
|
2309
|
-
|
|
2310
|
-
|
|
2416
|
+
new Assertion(
|
|
2417
|
+
superset,
|
|
2418
|
+
msg,
|
|
2419
|
+
assert.notIncludeDeepMembers,
|
|
2420
|
+
true
|
|
2421
|
+
).to.not.include.deep.members(subset);
|
|
2422
|
+
};
|
|
2311
2423
|
|
|
2312
2424
|
/**
|
|
2313
2425
|
* ### .includeOrderedMembers(superset, subset, [message])
|
|
@@ -2326,9 +2438,13 @@ assert.notIncludeDeepMembers = function (superset, subset, msg) {
|
|
|
2326
2438
|
* @public
|
|
2327
2439
|
*/
|
|
2328
2440
|
assert.includeOrderedMembers = function (superset, subset, msg) {
|
|
2329
|
-
new Assertion(
|
|
2330
|
-
|
|
2331
|
-
|
|
2441
|
+
new Assertion(
|
|
2442
|
+
superset,
|
|
2443
|
+
msg,
|
|
2444
|
+
assert.includeOrderedMembers,
|
|
2445
|
+
true
|
|
2446
|
+
).to.include.ordered.members(subset);
|
|
2447
|
+
};
|
|
2332
2448
|
|
|
2333
2449
|
/**
|
|
2334
2450
|
* ### .notIncludeOrderedMembers(superset, subset, [message])
|
|
@@ -2348,9 +2464,13 @@ assert.includeOrderedMembers = function (superset, subset, msg) {
|
|
|
2348
2464
|
* @public
|
|
2349
2465
|
*/
|
|
2350
2466
|
assert.notIncludeOrderedMembers = function (superset, subset, msg) {
|
|
2351
|
-
new Assertion(
|
|
2352
|
-
|
|
2353
|
-
|
|
2467
|
+
new Assertion(
|
|
2468
|
+
superset,
|
|
2469
|
+
msg,
|
|
2470
|
+
assert.notIncludeOrderedMembers,
|
|
2471
|
+
true
|
|
2472
|
+
).to.not.include.ordered.members(subset);
|
|
2473
|
+
};
|
|
2354
2474
|
|
|
2355
2475
|
/**
|
|
2356
2476
|
* ### .includeDeepOrderedMembers(superset, subset, [message])
|
|
@@ -2369,9 +2489,13 @@ assert.notIncludeOrderedMembers = function (superset, subset, msg) {
|
|
|
2369
2489
|
* @public
|
|
2370
2490
|
*/
|
|
2371
2491
|
assert.includeDeepOrderedMembers = function (superset, subset, msg) {
|
|
2372
|
-
new Assertion(
|
|
2373
|
-
|
|
2374
|
-
|
|
2492
|
+
new Assertion(
|
|
2493
|
+
superset,
|
|
2494
|
+
msg,
|
|
2495
|
+
assert.includeDeepOrderedMembers,
|
|
2496
|
+
true
|
|
2497
|
+
).to.include.deep.ordered.members(subset);
|
|
2498
|
+
};
|
|
2375
2499
|
|
|
2376
2500
|
/**
|
|
2377
2501
|
* ### .notIncludeDeepOrderedMembers(superset, subset, [message])
|
|
@@ -2392,9 +2516,13 @@ assert.includeDeepOrderedMembers = function (superset, subset, msg) {
|
|
|
2392
2516
|
* @public
|
|
2393
2517
|
*/
|
|
2394
2518
|
assert.notIncludeDeepOrderedMembers = function (superset, subset, msg) {
|
|
2395
|
-
new Assertion(
|
|
2396
|
-
|
|
2397
|
-
|
|
2519
|
+
new Assertion(
|
|
2520
|
+
superset,
|
|
2521
|
+
msg,
|
|
2522
|
+
assert.notIncludeDeepOrderedMembers,
|
|
2523
|
+
true
|
|
2524
|
+
).to.not.include.deep.ordered.members(subset);
|
|
2525
|
+
};
|
|
2398
2526
|
|
|
2399
2527
|
/**
|
|
2400
2528
|
* ### .oneOf(inList, list, [message])
|
|
@@ -2412,7 +2540,7 @@ assert.notIncludeDeepOrderedMembers = function (superset, subset, msg) {
|
|
|
2412
2540
|
*/
|
|
2413
2541
|
assert.oneOf = function (inList, list, msg) {
|
|
2414
2542
|
new Assertion(inList, msg, assert.oneOf, true).to.be.oneOf(list);
|
|
2415
|
-
}
|
|
2543
|
+
};
|
|
2416
2544
|
|
|
2417
2545
|
/**
|
|
2418
2546
|
* ### isIterable(obj, [message])
|
|
@@ -2427,19 +2555,15 @@ assert.oneOf = function (inList, list, msg) {
|
|
|
2427
2555
|
* @namespace Assert
|
|
2428
2556
|
* @public
|
|
2429
2557
|
*/
|
|
2430
|
-
assert.isIterable = function(obj, msg) {
|
|
2558
|
+
assert.isIterable = function (obj, msg) {
|
|
2431
2559
|
if (obj == undefined || !obj[Symbol.iterator]) {
|
|
2432
|
-
msg = msg
|
|
2433
|
-
`${msg} expected ${inspect(obj)} to be an iterable`
|
|
2434
|
-
`expected ${inspect(obj)} to be an iterable`;
|
|
2435
|
-
|
|
2436
|
-
throw new AssertionError(
|
|
2437
|
-
msg,
|
|
2438
|
-
undefined,
|
|
2439
|
-
assert.isIterable
|
|
2440
|
-
);
|
|
2560
|
+
msg = msg
|
|
2561
|
+
? `${msg} expected ${inspect(obj)} to be an iterable`
|
|
2562
|
+
: `expected ${inspect(obj)} to be an iterable`;
|
|
2563
|
+
|
|
2564
|
+
throw new AssertionError(msg, undefined, assert.isIterable);
|
|
2441
2565
|
}
|
|
2442
|
-
}
|
|
2566
|
+
};
|
|
2443
2567
|
|
|
2444
2568
|
/**
|
|
2445
2569
|
* ### .changes(function, object, property, [message])
|
|
@@ -2465,7 +2589,7 @@ assert.changes = function (fn, obj, prop, msg) {
|
|
|
2465
2589
|
}
|
|
2466
2590
|
|
|
2467
2591
|
new Assertion(fn, msg, assert.changes, true).to.change(obj, prop);
|
|
2468
|
-
}
|
|
2592
|
+
};
|
|
2469
2593
|
|
|
2470
2594
|
/**
|
|
2471
2595
|
* ### .changesBy(function, object, property, delta, [message])
|
|
@@ -2495,9 +2619,8 @@ assert.changesBy = function (fn, obj, prop, delta, msg) {
|
|
|
2495
2619
|
prop = null;
|
|
2496
2620
|
}
|
|
2497
2621
|
|
|
2498
|
-
new Assertion(fn, msg, assert.changesBy, true)
|
|
2499
|
-
|
|
2500
|
-
}
|
|
2622
|
+
new Assertion(fn, msg, assert.changesBy, true).to.change(obj, prop).by(delta);
|
|
2623
|
+
};
|
|
2501
2624
|
|
|
2502
2625
|
/**
|
|
2503
2626
|
* ### .doesNotChange(function, object, property, [message])
|
|
@@ -2523,9 +2646,11 @@ assert.doesNotChange = function (fn, obj, prop, msg) {
|
|
|
2523
2646
|
prop = null;
|
|
2524
2647
|
}
|
|
2525
2648
|
|
|
2526
|
-
return new Assertion(fn, msg, assert.doesNotChange, true)
|
|
2527
|
-
|
|
2528
|
-
|
|
2649
|
+
return new Assertion(fn, msg, assert.doesNotChange, true).to.not.change(
|
|
2650
|
+
obj,
|
|
2651
|
+
prop
|
|
2652
|
+
);
|
|
2653
|
+
};
|
|
2529
2654
|
|
|
2530
2655
|
/**
|
|
2531
2656
|
* ### .changesButNotBy(function, object, property, delta, [message])
|
|
@@ -2555,9 +2680,10 @@ assert.changesButNotBy = function (fn, obj, prop, delta, msg) {
|
|
|
2555
2680
|
prop = null;
|
|
2556
2681
|
}
|
|
2557
2682
|
|
|
2558
|
-
new Assertion(fn, msg, assert.changesButNotBy, true)
|
|
2559
|
-
.
|
|
2560
|
-
|
|
2683
|
+
new Assertion(fn, msg, assert.changesButNotBy, true).to
|
|
2684
|
+
.change(obj, prop)
|
|
2685
|
+
.but.not.by(delta);
|
|
2686
|
+
};
|
|
2561
2687
|
|
|
2562
2688
|
/**
|
|
2563
2689
|
* ### .increases(function, object, property, [message])
|
|
@@ -2583,9 +2709,8 @@ assert.increases = function (fn, obj, prop, msg) {
|
|
|
2583
2709
|
prop = null;
|
|
2584
2710
|
}
|
|
2585
2711
|
|
|
2586
|
-
return new Assertion(fn, msg, assert.increases, true)
|
|
2587
|
-
|
|
2588
|
-
}
|
|
2712
|
+
return new Assertion(fn, msg, assert.increases, true).to.increase(obj, prop);
|
|
2713
|
+
};
|
|
2589
2714
|
|
|
2590
2715
|
/**
|
|
2591
2716
|
* ### .increasesBy(function, object, property, delta, [message])
|
|
@@ -2615,9 +2740,10 @@ assert.increasesBy = function (fn, obj, prop, delta, msg) {
|
|
|
2615
2740
|
prop = null;
|
|
2616
2741
|
}
|
|
2617
2742
|
|
|
2618
|
-
new Assertion(fn, msg, assert.increasesBy, true)
|
|
2619
|
-
.
|
|
2620
|
-
|
|
2743
|
+
new Assertion(fn, msg, assert.increasesBy, true).to
|
|
2744
|
+
.increase(obj, prop)
|
|
2745
|
+
.by(delta);
|
|
2746
|
+
};
|
|
2621
2747
|
|
|
2622
2748
|
/**
|
|
2623
2749
|
* ### .doesNotIncrease(function, object, property, [message])
|
|
@@ -2643,9 +2769,11 @@ assert.doesNotIncrease = function (fn, obj, prop, msg) {
|
|
|
2643
2769
|
prop = null;
|
|
2644
2770
|
}
|
|
2645
2771
|
|
|
2646
|
-
return new Assertion(fn, msg, assert.doesNotIncrease, true)
|
|
2647
|
-
|
|
2648
|
-
|
|
2772
|
+
return new Assertion(fn, msg, assert.doesNotIncrease, true).to.not.increase(
|
|
2773
|
+
obj,
|
|
2774
|
+
prop
|
|
2775
|
+
);
|
|
2776
|
+
};
|
|
2649
2777
|
|
|
2650
2778
|
/**
|
|
2651
2779
|
* ### .increasesButNotBy(function, object, property, delta, [message])
|
|
@@ -2675,9 +2803,10 @@ assert.increasesButNotBy = function (fn, obj, prop, delta, msg) {
|
|
|
2675
2803
|
prop = null;
|
|
2676
2804
|
}
|
|
2677
2805
|
|
|
2678
|
-
new Assertion(fn, msg, assert.increasesButNotBy, true)
|
|
2679
|
-
.
|
|
2680
|
-
|
|
2806
|
+
new Assertion(fn, msg, assert.increasesButNotBy, true).to
|
|
2807
|
+
.increase(obj, prop)
|
|
2808
|
+
.but.not.by(delta);
|
|
2809
|
+
};
|
|
2681
2810
|
|
|
2682
2811
|
/**
|
|
2683
2812
|
* ### .decreases(function, object, property, [message])
|
|
@@ -2703,9 +2832,8 @@ assert.decreases = function (fn, obj, prop, msg) {
|
|
|
2703
2832
|
prop = null;
|
|
2704
2833
|
}
|
|
2705
2834
|
|
|
2706
|
-
return new Assertion(fn, msg, assert.decreases, true)
|
|
2707
|
-
|
|
2708
|
-
}
|
|
2835
|
+
return new Assertion(fn, msg, assert.decreases, true).to.decrease(obj, prop);
|
|
2836
|
+
};
|
|
2709
2837
|
|
|
2710
2838
|
/**
|
|
2711
2839
|
* ### .decreasesBy(function, object, property, delta, [message])
|
|
@@ -2735,9 +2863,10 @@ assert.decreasesBy = function (fn, obj, prop, delta, msg) {
|
|
|
2735
2863
|
prop = null;
|
|
2736
2864
|
}
|
|
2737
2865
|
|
|
2738
|
-
new Assertion(fn, msg, assert.decreasesBy, true)
|
|
2739
|
-
.
|
|
2740
|
-
|
|
2866
|
+
new Assertion(fn, msg, assert.decreasesBy, true).to
|
|
2867
|
+
.decrease(obj, prop)
|
|
2868
|
+
.by(delta);
|
|
2869
|
+
};
|
|
2741
2870
|
|
|
2742
2871
|
/**
|
|
2743
2872
|
* ### .doesNotDecrease(function, object, property, [message])
|
|
@@ -2763,9 +2892,11 @@ assert.doesNotDecrease = function (fn, obj, prop, msg) {
|
|
|
2763
2892
|
prop = null;
|
|
2764
2893
|
}
|
|
2765
2894
|
|
|
2766
|
-
return new Assertion(fn, msg, assert.doesNotDecrease, true)
|
|
2767
|
-
|
|
2768
|
-
|
|
2895
|
+
return new Assertion(fn, msg, assert.doesNotDecrease, true).to.not.decrease(
|
|
2896
|
+
obj,
|
|
2897
|
+
prop
|
|
2898
|
+
);
|
|
2899
|
+
};
|
|
2769
2900
|
|
|
2770
2901
|
/**
|
|
2771
2902
|
* ### .doesNotDecreaseBy(function, object, property, delta, [message])
|
|
@@ -2796,9 +2927,10 @@ assert.doesNotDecreaseBy = function (fn, obj, prop, delta, msg) {
|
|
|
2796
2927
|
prop = null;
|
|
2797
2928
|
}
|
|
2798
2929
|
|
|
2799
|
-
return new Assertion(fn, msg, assert.doesNotDecreaseBy, true)
|
|
2800
|
-
.
|
|
2801
|
-
|
|
2930
|
+
return new Assertion(fn, msg, assert.doesNotDecreaseBy, true).to.not
|
|
2931
|
+
.decrease(obj, prop)
|
|
2932
|
+
.by(delta);
|
|
2933
|
+
};
|
|
2802
2934
|
|
|
2803
2935
|
/**
|
|
2804
2936
|
* ### .decreasesButNotBy(function, object, property, delta, [message])
|
|
@@ -2828,9 +2960,10 @@ assert.decreasesButNotBy = function (fn, obj, prop, delta, msg) {
|
|
|
2828
2960
|
prop = null;
|
|
2829
2961
|
}
|
|
2830
2962
|
|
|
2831
|
-
new Assertion(fn, msg, assert.decreasesButNotBy, true)
|
|
2832
|
-
.
|
|
2833
|
-
|
|
2963
|
+
new Assertion(fn, msg, assert.decreasesButNotBy, true).to
|
|
2964
|
+
.decrease(obj, prop)
|
|
2965
|
+
.but.not.by(delta);
|
|
2966
|
+
};
|
|
2834
2967
|
|
|
2835
2968
|
/**
|
|
2836
2969
|
* ### .ifError(object)
|
|
@@ -2849,7 +2982,7 @@ assert.decreasesButNotBy = function (fn, obj, prop, delta, msg) {
|
|
|
2849
2982
|
*/
|
|
2850
2983
|
assert.ifError = function (val) {
|
|
2851
2984
|
if (val) {
|
|
2852
|
-
throw
|
|
2985
|
+
throw val;
|
|
2853
2986
|
}
|
|
2854
2987
|
};
|
|
2855
2988
|
|
|
@@ -2995,7 +3128,7 @@ assert.isNotFrozen = function (obj, msg) {
|
|
|
2995
3128
|
* @namespace Assert
|
|
2996
3129
|
* @public
|
|
2997
3130
|
*/
|
|
2998
|
-
assert.isEmpty = function(val, msg) {
|
|
3131
|
+
assert.isEmpty = function (val, msg) {
|
|
2999
3132
|
new Assertion(val, msg, assert.isEmpty, true).to.be.empty;
|
|
3000
3133
|
};
|
|
3001
3134
|
|
|
@@ -3020,10 +3153,52 @@ assert.isEmpty = function(val, msg) {
|
|
|
3020
3153
|
* @namespace Assert
|
|
3021
3154
|
* @public
|
|
3022
3155
|
*/
|
|
3023
|
-
assert.isNotEmpty = function(val, msg) {
|
|
3156
|
+
assert.isNotEmpty = function (val, msg) {
|
|
3024
3157
|
new Assertion(val, msg, assert.isNotEmpty, true).to.not.be.empty;
|
|
3025
3158
|
};
|
|
3026
3159
|
|
|
3160
|
+
/**
|
|
3161
|
+
* ### .containsSubset(target, subset)
|
|
3162
|
+
*
|
|
3163
|
+
* Asserts that the target primitive/object/array structure deeply contains all provided fields
|
|
3164
|
+
* at the same key/depth as the provided structure.
|
|
3165
|
+
*
|
|
3166
|
+
* When comparing arrays, the target must contain the subset of at least one of each object/value in the subset array.
|
|
3167
|
+
* Order does not matter.
|
|
3168
|
+
*
|
|
3169
|
+
* assert.containsSubset(
|
|
3170
|
+
* [{name: {first: "John", last: "Smith"}}, {name: {first: "Jane", last: "Doe"}}],
|
|
3171
|
+
* [{name: {first: "Jane"}}]
|
|
3172
|
+
* );
|
|
3173
|
+
*
|
|
3174
|
+
* @name containsSubset
|
|
3175
|
+
* @alias containSubset
|
|
3176
|
+
* @param {unknown} val
|
|
3177
|
+
* @param {unknown} exp
|
|
3178
|
+
* @param {string} msg _optional_
|
|
3179
|
+
* @namespace Assert
|
|
3180
|
+
* @public
|
|
3181
|
+
*/
|
|
3182
|
+
assert.containsSubset = function (val, exp, msg) {
|
|
3183
|
+
new Assertion(val, msg).to.containSubset(exp);
|
|
3184
|
+
};
|
|
3185
|
+
|
|
3186
|
+
/**
|
|
3187
|
+
* ### .doesNotContainSubset(target, subset)
|
|
3188
|
+
*
|
|
3189
|
+
* The negation of assert.containsSubset.
|
|
3190
|
+
*
|
|
3191
|
+
* @name doesNotContainSubset
|
|
3192
|
+
* @param {unknown} val
|
|
3193
|
+
* @param {unknown} exp
|
|
3194
|
+
* @param {string} msg _optional_
|
|
3195
|
+
* @namespace Assert
|
|
3196
|
+
* @public
|
|
3197
|
+
*/
|
|
3198
|
+
assert.doesNotContainSubset = function (val, exp, msg) {
|
|
3199
|
+
new Assertion(val, msg).to.not.containSubset(exp);
|
|
3200
|
+
};
|
|
3201
|
+
|
|
3027
3202
|
/**
|
|
3028
3203
|
* Aliases.
|
|
3029
3204
|
*
|
|
@@ -3031,21 +3206,23 @@ assert.isNotEmpty = function(val, msg) {
|
|
|
3031
3206
|
* @param {unknown} as
|
|
3032
3207
|
* @returns {unknown}
|
|
3033
3208
|
*/
|
|
3034
|
-
|
|
3209
|
+
const aliases = [
|
|
3210
|
+
['isOk', 'ok'],
|
|
3211
|
+
['isNotOk', 'notOk'],
|
|
3212
|
+
['throws', 'throw'],
|
|
3213
|
+
['throws', 'Throw'],
|
|
3214
|
+
['isExtensible', 'extensible'],
|
|
3215
|
+
['isNotExtensible', 'notExtensible'],
|
|
3216
|
+
['isSealed', 'sealed'],
|
|
3217
|
+
['isNotSealed', 'notSealed'],
|
|
3218
|
+
['isFrozen', 'frozen'],
|
|
3219
|
+
['isNotFrozen', 'notFrozen'],
|
|
3220
|
+
['isEmpty', 'empty'],
|
|
3221
|
+
['isNotEmpty', 'notEmpty'],
|
|
3222
|
+
['isCallable', 'isFunction'],
|
|
3223
|
+
['isNotCallable', 'isNotFunction'],
|
|
3224
|
+
['containsSubset', 'containSubset']
|
|
3225
|
+
];
|
|
3226
|
+
for (const [name, as] of aliases) {
|
|
3035
3227
|
assert[as] = assert[name];
|
|
3036
|
-
|
|
3037
|
-
})
|
|
3038
|
-
('isOk', 'ok')
|
|
3039
|
-
('isNotOk', 'notOk')
|
|
3040
|
-
('throws', 'throw')
|
|
3041
|
-
('throws', 'Throw')
|
|
3042
|
-
('isExtensible', 'extensible')
|
|
3043
|
-
('isNotExtensible', 'notExtensible')
|
|
3044
|
-
('isSealed', 'sealed')
|
|
3045
|
-
('isNotSealed', 'notSealed')
|
|
3046
|
-
('isFrozen', 'frozen')
|
|
3047
|
-
('isNotFrozen', 'notFrozen')
|
|
3048
|
-
('isEmpty', 'empty')
|
|
3049
|
-
('isNotEmpty', 'notEmpty')
|
|
3050
|
-
('isCallable', 'isFunction')
|
|
3051
|
-
('isNotCallable', 'isNotFunction')
|
|
3228
|
+
}
|