chai 5.1.1 → 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 +575 -242
- 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 +716 -492
- package/lib/chai/interface/assert.js +463 -247
- 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 +13 -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])
|
|
@@ -706,21 +706,60 @@ assert.isNotNumber = function (val, msg) {
|
|
|
706
706
|
new Assertion(val, msg, assert.isNotNumber, true).to.not.be.a('number');
|
|
707
707
|
};
|
|
708
708
|
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
709
|
+
/**
|
|
710
|
+
* ### .isNumeric(value, [message])
|
|
711
|
+
*
|
|
712
|
+
* Asserts that `value` is a number or BigInt.
|
|
713
|
+
*
|
|
714
|
+
* var cups = 2;
|
|
715
|
+
* assert.isNumeric(cups, 'how many cups');
|
|
716
|
+
*
|
|
717
|
+
* var cups = 10n;
|
|
718
|
+
* assert.isNumeric(cups, 'how many cups');
|
|
719
|
+
*
|
|
720
|
+
* @name isNumeric
|
|
721
|
+
* @param {unknown} val
|
|
722
|
+
* @param {string} msg
|
|
723
|
+
* @namespace Assert
|
|
724
|
+
* @public
|
|
725
|
+
*/
|
|
726
|
+
assert.isNumeric = function (val, msg) {
|
|
727
|
+
new Assertion(val, msg, assert.isNumeric, true).is.numeric;
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* ### .isNotNumeric(value, [message])
|
|
732
|
+
*
|
|
733
|
+
* Asserts that `value` is _not_ a number or BigInt.
|
|
734
|
+
*
|
|
735
|
+
* var cups = '2 cups please';
|
|
736
|
+
* assert.isNotNumeric(cups, 'how many cups');
|
|
737
|
+
*
|
|
738
|
+
* @name isNotNumeric
|
|
739
|
+
* @param {unknown} val
|
|
740
|
+
* @param {string} msg
|
|
741
|
+
* @namespace Assert
|
|
742
|
+
* @public
|
|
743
|
+
*/
|
|
744
|
+
assert.isNotNumeric = function (val, msg) {
|
|
745
|
+
new Assertion(val, msg, assert.isNotNumeric, true).is.not.numeric;
|
|
746
|
+
};
|
|
747
|
+
|
|
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
|
+
*/
|
|
724
763
|
assert.isFinite = function (val, msg) {
|
|
725
764
|
new Assertion(val, msg, assert.isFinite, true).to.be.finite;
|
|
726
765
|
};
|
|
@@ -849,8 +888,9 @@ assert.instanceOf = function (val, type, msg) {
|
|
|
849
888
|
* @public
|
|
850
889
|
*/
|
|
851
890
|
assert.notInstanceOf = function (val, type, msg) {
|
|
852
|
-
new Assertion(val, msg, assert.notInstanceOf, true)
|
|
853
|
-
|
|
891
|
+
new Assertion(val, msg, assert.notInstanceOf, true).to.not.be.instanceOf(
|
|
892
|
+
type
|
|
893
|
+
);
|
|
854
894
|
};
|
|
855
895
|
|
|
856
896
|
/**
|
|
@@ -1015,8 +1055,9 @@ assert.nestedInclude = function (exp, inc, msg) {
|
|
|
1015
1055
|
* @public
|
|
1016
1056
|
*/
|
|
1017
1057
|
assert.notNestedInclude = function (exp, inc, msg) {
|
|
1018
|
-
new Assertion(exp, msg, assert.notNestedInclude, true)
|
|
1019
|
-
|
|
1058
|
+
new Assertion(exp, msg, assert.notNestedInclude, true).not.nested.include(
|
|
1059
|
+
inc
|
|
1060
|
+
);
|
|
1020
1061
|
};
|
|
1021
1062
|
|
|
1022
1063
|
/**
|
|
@@ -1039,9 +1080,10 @@ assert.notNestedInclude = function (exp, inc, msg) {
|
|
|
1039
1080
|
* @namespace Assert
|
|
1040
1081
|
* @public
|
|
1041
1082
|
*/
|
|
1042
|
-
assert.deepNestedInclude = function(exp, inc, msg) {
|
|
1043
|
-
new Assertion(exp, msg, assert.deepNestedInclude, true)
|
|
1044
|
-
|
|
1083
|
+
assert.deepNestedInclude = function (exp, inc, msg) {
|
|
1084
|
+
new Assertion(exp, msg, assert.deepNestedInclude, true).deep.nested.include(
|
|
1085
|
+
inc
|
|
1086
|
+
);
|
|
1045
1087
|
};
|
|
1046
1088
|
|
|
1047
1089
|
/**
|
|
@@ -1064,9 +1106,13 @@ assert.deepNestedInclude = function(exp, inc, msg) {
|
|
|
1064
1106
|
* @namespace Assert
|
|
1065
1107
|
* @public
|
|
1066
1108
|
*/
|
|
1067
|
-
assert.notDeepNestedInclude = function(exp, inc, msg) {
|
|
1068
|
-
new Assertion(
|
|
1069
|
-
|
|
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);
|
|
1070
1116
|
};
|
|
1071
1117
|
|
|
1072
1118
|
/**
|
|
@@ -1085,7 +1131,7 @@ assert.notDeepNestedInclude = function(exp, inc, msg) {
|
|
|
1085
1131
|
* @namespace Assert
|
|
1086
1132
|
* @public
|
|
1087
1133
|
*/
|
|
1088
|
-
assert.ownInclude = function(exp, inc, msg) {
|
|
1134
|
+
assert.ownInclude = function (exp, inc, msg) {
|
|
1089
1135
|
new Assertion(exp, msg, assert.ownInclude, true).own.include(inc);
|
|
1090
1136
|
};
|
|
1091
1137
|
|
|
@@ -1106,7 +1152,7 @@ assert.ownInclude = function(exp, inc, msg) {
|
|
|
1106
1152
|
* @namespace Assert
|
|
1107
1153
|
* @public
|
|
1108
1154
|
*/
|
|
1109
|
-
assert.notOwnInclude = function(exp, inc, msg) {
|
|
1155
|
+
assert.notOwnInclude = function (exp, inc, msg) {
|
|
1110
1156
|
new Assertion(exp, msg, assert.notOwnInclude, true).not.own.include(inc);
|
|
1111
1157
|
};
|
|
1112
1158
|
|
|
@@ -1126,9 +1172,8 @@ assert.notOwnInclude = function(exp, inc, msg) {
|
|
|
1126
1172
|
* @namespace Assert
|
|
1127
1173
|
* @public
|
|
1128
1174
|
*/
|
|
1129
|
-
assert.deepOwnInclude = function(exp, inc, msg) {
|
|
1130
|
-
new Assertion(exp, msg, assert.deepOwnInclude, true)
|
|
1131
|
-
.deep.own.include(inc);
|
|
1175
|
+
assert.deepOwnInclude = function (exp, inc, msg) {
|
|
1176
|
+
new Assertion(exp, msg, assert.deepOwnInclude, true).deep.own.include(inc);
|
|
1132
1177
|
};
|
|
1133
1178
|
|
|
1134
1179
|
/**
|
|
@@ -1147,9 +1192,10 @@ assert.deepOwnInclude = function(exp, inc, msg) {
|
|
|
1147
1192
|
* @namespace Assert
|
|
1148
1193
|
* @public
|
|
1149
1194
|
*/
|
|
1150
|
-
assert.notDeepOwnInclude = function(exp, inc, msg) {
|
|
1151
|
-
new Assertion(exp, msg, assert.notDeepOwnInclude, true)
|
|
1152
|
-
|
|
1195
|
+
assert.notDeepOwnInclude = function (exp, inc, msg) {
|
|
1196
|
+
new Assertion(exp, msg, assert.notDeepOwnInclude, true).not.deep.own.include(
|
|
1197
|
+
inc
|
|
1198
|
+
);
|
|
1153
1199
|
};
|
|
1154
1200
|
|
|
1155
1201
|
/**
|
|
@@ -1224,8 +1270,7 @@ assert.property = function (obj, prop, msg) {
|
|
|
1224
1270
|
* @public
|
|
1225
1271
|
*/
|
|
1226
1272
|
assert.notProperty = function (obj, prop, msg) {
|
|
1227
|
-
new Assertion(obj, msg, assert.notProperty, true)
|
|
1228
|
-
.to.not.have.property(prop);
|
|
1273
|
+
new Assertion(obj, msg, assert.notProperty, true).to.not.have.property(prop);
|
|
1229
1274
|
};
|
|
1230
1275
|
|
|
1231
1276
|
/**
|
|
@@ -1246,8 +1291,7 @@ assert.notProperty = function (obj, prop, msg) {
|
|
|
1246
1291
|
* @public
|
|
1247
1292
|
*/
|
|
1248
1293
|
assert.propertyVal = function (obj, prop, val, msg) {
|
|
1249
|
-
new Assertion(obj, msg, assert.propertyVal, true)
|
|
1250
|
-
.to.have.property(prop, val);
|
|
1294
|
+
new Assertion(obj, msg, assert.propertyVal, true).to.have.property(prop, val);
|
|
1251
1295
|
};
|
|
1252
1296
|
|
|
1253
1297
|
/**
|
|
@@ -1269,8 +1313,10 @@ assert.propertyVal = function (obj, prop, val, msg) {
|
|
|
1269
1313
|
* @public
|
|
1270
1314
|
*/
|
|
1271
1315
|
assert.notPropertyVal = function (obj, prop, val, msg) {
|
|
1272
|
-
new Assertion(obj, msg, assert.notPropertyVal, true)
|
|
1273
|
-
|
|
1316
|
+
new Assertion(obj, msg, assert.notPropertyVal, true).to.not.have.property(
|
|
1317
|
+
prop,
|
|
1318
|
+
val
|
|
1319
|
+
);
|
|
1274
1320
|
};
|
|
1275
1321
|
|
|
1276
1322
|
/**
|
|
@@ -1290,8 +1336,10 @@ assert.notPropertyVal = function (obj, prop, val, msg) {
|
|
|
1290
1336
|
* @public
|
|
1291
1337
|
*/
|
|
1292
1338
|
assert.deepPropertyVal = function (obj, prop, val, msg) {
|
|
1293
|
-
new Assertion(obj, msg, assert.deepPropertyVal, true)
|
|
1294
|
-
|
|
1339
|
+
new Assertion(obj, msg, assert.deepPropertyVal, true).to.have.deep.property(
|
|
1340
|
+
prop,
|
|
1341
|
+
val
|
|
1342
|
+
);
|
|
1295
1343
|
};
|
|
1296
1344
|
|
|
1297
1345
|
/**
|
|
@@ -1313,8 +1361,12 @@ assert.deepPropertyVal = function (obj, prop, val, msg) {
|
|
|
1313
1361
|
* @public
|
|
1314
1362
|
*/
|
|
1315
1363
|
assert.notDeepPropertyVal = function (obj, prop, val, msg) {
|
|
1316
|
-
new Assertion(
|
|
1317
|
-
|
|
1364
|
+
new Assertion(
|
|
1365
|
+
obj,
|
|
1366
|
+
msg,
|
|
1367
|
+
assert.notDeepPropertyVal,
|
|
1368
|
+
true
|
|
1369
|
+
).to.not.have.deep.property(prop, val);
|
|
1318
1370
|
};
|
|
1319
1371
|
|
|
1320
1372
|
/**
|
|
@@ -1332,8 +1384,7 @@ assert.notDeepPropertyVal = function (obj, prop, val, msg) {
|
|
|
1332
1384
|
* @public
|
|
1333
1385
|
*/
|
|
1334
1386
|
assert.ownProperty = function (obj, prop, msg) {
|
|
1335
|
-
new Assertion(obj, msg, assert.ownProperty, true)
|
|
1336
|
-
.to.have.own.property(prop);
|
|
1387
|
+
new Assertion(obj, msg, assert.ownProperty, true).to.have.own.property(prop);
|
|
1337
1388
|
};
|
|
1338
1389
|
|
|
1339
1390
|
/**
|
|
@@ -1352,8 +1403,9 @@ assert.ownProperty = function (obj, prop, msg) {
|
|
|
1352
1403
|
* @public
|
|
1353
1404
|
*/
|
|
1354
1405
|
assert.notOwnProperty = function (obj, prop, msg) {
|
|
1355
|
-
new Assertion(obj, msg, assert.notOwnProperty, true)
|
|
1356
|
-
|
|
1406
|
+
new Assertion(obj, msg, assert.notOwnProperty, true).to.not.have.own.property(
|
|
1407
|
+
prop
|
|
1408
|
+
);
|
|
1357
1409
|
};
|
|
1358
1410
|
|
|
1359
1411
|
/**
|
|
@@ -1373,8 +1425,10 @@ assert.notOwnProperty = function (obj, prop, msg) {
|
|
|
1373
1425
|
* @public
|
|
1374
1426
|
*/
|
|
1375
1427
|
assert.ownPropertyVal = function (obj, prop, value, msg) {
|
|
1376
|
-
new Assertion(obj, msg, assert.ownPropertyVal, true)
|
|
1377
|
-
|
|
1428
|
+
new Assertion(obj, msg, assert.ownPropertyVal, true).to.have.own.property(
|
|
1429
|
+
prop,
|
|
1430
|
+
value
|
|
1431
|
+
);
|
|
1378
1432
|
};
|
|
1379
1433
|
|
|
1380
1434
|
/**
|
|
@@ -1395,8 +1449,12 @@ assert.ownPropertyVal = function (obj, prop, value, msg) {
|
|
|
1395
1449
|
* @public
|
|
1396
1450
|
*/
|
|
1397
1451
|
assert.notOwnPropertyVal = function (obj, prop, value, msg) {
|
|
1398
|
-
new Assertion(
|
|
1399
|
-
|
|
1452
|
+
new Assertion(
|
|
1453
|
+
obj,
|
|
1454
|
+
msg,
|
|
1455
|
+
assert.notOwnPropertyVal,
|
|
1456
|
+
true
|
|
1457
|
+
).to.not.have.own.property(prop, value);
|
|
1400
1458
|
};
|
|
1401
1459
|
|
|
1402
1460
|
/**
|
|
@@ -1416,8 +1474,12 @@ assert.notOwnPropertyVal = function (obj, prop, value, msg) {
|
|
|
1416
1474
|
* @public
|
|
1417
1475
|
*/
|
|
1418
1476
|
assert.deepOwnPropertyVal = function (obj, prop, value, msg) {
|
|
1419
|
-
new Assertion(
|
|
1420
|
-
|
|
1477
|
+
new Assertion(
|
|
1478
|
+
obj,
|
|
1479
|
+
msg,
|
|
1480
|
+
assert.deepOwnPropertyVal,
|
|
1481
|
+
true
|
|
1482
|
+
).to.have.deep.own.property(prop, value);
|
|
1421
1483
|
};
|
|
1422
1484
|
|
|
1423
1485
|
/**
|
|
@@ -1440,8 +1502,12 @@ assert.deepOwnPropertyVal = function (obj, prop, value, msg) {
|
|
|
1440
1502
|
* @public
|
|
1441
1503
|
*/
|
|
1442
1504
|
assert.notDeepOwnPropertyVal = function (obj, prop, value, msg) {
|
|
1443
|
-
new Assertion(
|
|
1444
|
-
|
|
1505
|
+
new Assertion(
|
|
1506
|
+
obj,
|
|
1507
|
+
msg,
|
|
1508
|
+
assert.notDeepOwnPropertyVal,
|
|
1509
|
+
true
|
|
1510
|
+
).to.not.have.deep.own.property(prop, value);
|
|
1445
1511
|
};
|
|
1446
1512
|
|
|
1447
1513
|
/**
|
|
@@ -1461,8 +1527,9 @@ assert.notDeepOwnPropertyVal = function (obj, prop, value, msg) {
|
|
|
1461
1527
|
* @public
|
|
1462
1528
|
*/
|
|
1463
1529
|
assert.nestedProperty = function (obj, prop, msg) {
|
|
1464
|
-
new Assertion(obj, msg, assert.nestedProperty, true)
|
|
1465
|
-
|
|
1530
|
+
new Assertion(obj, msg, assert.nestedProperty, true).to.have.nested.property(
|
|
1531
|
+
prop
|
|
1532
|
+
);
|
|
1466
1533
|
};
|
|
1467
1534
|
|
|
1468
1535
|
/**
|
|
@@ -1482,8 +1549,12 @@ assert.nestedProperty = function (obj, prop, msg) {
|
|
|
1482
1549
|
* @public
|
|
1483
1550
|
*/
|
|
1484
1551
|
assert.notNestedProperty = function (obj, prop, msg) {
|
|
1485
|
-
new Assertion(
|
|
1486
|
-
|
|
1552
|
+
new Assertion(
|
|
1553
|
+
obj,
|
|
1554
|
+
msg,
|
|
1555
|
+
assert.notNestedProperty,
|
|
1556
|
+
true
|
|
1557
|
+
).to.not.have.nested.property(prop);
|
|
1487
1558
|
};
|
|
1488
1559
|
|
|
1489
1560
|
/**
|
|
@@ -1504,8 +1575,12 @@ assert.notNestedProperty = function (obj, prop, msg) {
|
|
|
1504
1575
|
* @public
|
|
1505
1576
|
*/
|
|
1506
1577
|
assert.nestedPropertyVal = function (obj, prop, val, msg) {
|
|
1507
|
-
new Assertion(
|
|
1508
|
-
|
|
1578
|
+
new Assertion(
|
|
1579
|
+
obj,
|
|
1580
|
+
msg,
|
|
1581
|
+
assert.nestedPropertyVal,
|
|
1582
|
+
true
|
|
1583
|
+
).to.have.nested.property(prop, val);
|
|
1509
1584
|
};
|
|
1510
1585
|
|
|
1511
1586
|
/**
|
|
@@ -1527,8 +1602,12 @@ assert.nestedPropertyVal = function (obj, prop, val, msg) {
|
|
|
1527
1602
|
* @public
|
|
1528
1603
|
*/
|
|
1529
1604
|
assert.notNestedPropertyVal = function (obj, prop, val, msg) {
|
|
1530
|
-
new Assertion(
|
|
1531
|
-
|
|
1605
|
+
new Assertion(
|
|
1606
|
+
obj,
|
|
1607
|
+
msg,
|
|
1608
|
+
assert.notNestedPropertyVal,
|
|
1609
|
+
true
|
|
1610
|
+
).to.not.have.nested.property(prop, val);
|
|
1532
1611
|
};
|
|
1533
1612
|
|
|
1534
1613
|
/**
|
|
@@ -1549,8 +1628,12 @@ assert.notNestedPropertyVal = function (obj, prop, val, msg) {
|
|
|
1549
1628
|
* @public
|
|
1550
1629
|
*/
|
|
1551
1630
|
assert.deepNestedPropertyVal = function (obj, prop, val, msg) {
|
|
1552
|
-
new Assertion(
|
|
1553
|
-
|
|
1631
|
+
new Assertion(
|
|
1632
|
+
obj,
|
|
1633
|
+
msg,
|
|
1634
|
+
assert.deepNestedPropertyVal,
|
|
1635
|
+
true
|
|
1636
|
+
).to.have.deep.nested.property(prop, val);
|
|
1554
1637
|
};
|
|
1555
1638
|
|
|
1556
1639
|
/**
|
|
@@ -1573,9 +1656,13 @@ assert.deepNestedPropertyVal = function (obj, prop, val, msg) {
|
|
|
1573
1656
|
* @public
|
|
1574
1657
|
*/
|
|
1575
1658
|
assert.notDeepNestedPropertyVal = function (obj, prop, val, msg) {
|
|
1576
|
-
new Assertion(
|
|
1577
|
-
|
|
1578
|
-
|
|
1659
|
+
new Assertion(
|
|
1660
|
+
obj,
|
|
1661
|
+
msg,
|
|
1662
|
+
assert.notDeepNestedPropertyVal,
|
|
1663
|
+
true
|
|
1664
|
+
).to.not.have.deep.nested.property(prop, val);
|
|
1665
|
+
};
|
|
1579
1666
|
|
|
1580
1667
|
/**
|
|
1581
1668
|
* ### .lengthOf(object, length, [message])
|
|
@@ -1619,7 +1706,7 @@ assert.lengthOf = function (exp, len, msg) {
|
|
|
1619
1706
|
*/
|
|
1620
1707
|
assert.hasAnyKeys = function (obj, keys, msg) {
|
|
1621
1708
|
new Assertion(obj, msg, assert.hasAnyKeys, true).to.have.any.keys(keys);
|
|
1622
|
-
}
|
|
1709
|
+
};
|
|
1623
1710
|
|
|
1624
1711
|
/**
|
|
1625
1712
|
* ### .hasAllKeys(object, [keys], [message])
|
|
@@ -1642,7 +1729,7 @@ assert.hasAnyKeys = function (obj, keys, msg) {
|
|
|
1642
1729
|
*/
|
|
1643
1730
|
assert.hasAllKeys = function (obj, keys, msg) {
|
|
1644
1731
|
new Assertion(obj, msg, assert.hasAllKeys, true).to.have.all.keys(keys);
|
|
1645
|
-
}
|
|
1732
|
+
};
|
|
1646
1733
|
|
|
1647
1734
|
/**
|
|
1648
1735
|
* ### .containsAllKeys(object, [keys], [message])
|
|
@@ -1668,9 +1755,10 @@ assert.hasAllKeys = function (obj, keys, msg) {
|
|
|
1668
1755
|
* @public
|
|
1669
1756
|
*/
|
|
1670
1757
|
assert.containsAllKeys = function (obj, keys, msg) {
|
|
1671
|
-
new Assertion(obj, msg, assert.containsAllKeys, true)
|
|
1672
|
-
|
|
1673
|
-
|
|
1758
|
+
new Assertion(obj, msg, assert.containsAllKeys, true).to.contain.all.keys(
|
|
1759
|
+
keys
|
|
1760
|
+
);
|
|
1761
|
+
};
|
|
1674
1762
|
|
|
1675
1763
|
/**
|
|
1676
1764
|
* ### .doesNotHaveAnyKeys(object, [keys], [message])
|
|
@@ -1692,9 +1780,10 @@ assert.containsAllKeys = function (obj, keys, msg) {
|
|
|
1692
1780
|
* @public
|
|
1693
1781
|
*/
|
|
1694
1782
|
assert.doesNotHaveAnyKeys = function (obj, keys, msg) {
|
|
1695
|
-
new Assertion(obj, msg, assert.doesNotHaveAnyKeys, true)
|
|
1696
|
-
|
|
1697
|
-
|
|
1783
|
+
new Assertion(obj, msg, assert.doesNotHaveAnyKeys, true).to.not.have.any.keys(
|
|
1784
|
+
keys
|
|
1785
|
+
);
|
|
1786
|
+
};
|
|
1698
1787
|
|
|
1699
1788
|
/**
|
|
1700
1789
|
* ### .doesNotHaveAllKeys(object, [keys], [message])
|
|
@@ -1716,9 +1805,10 @@ assert.doesNotHaveAnyKeys = function (obj, keys, msg) {
|
|
|
1716
1805
|
* @public
|
|
1717
1806
|
*/
|
|
1718
1807
|
assert.doesNotHaveAllKeys = function (obj, keys, msg) {
|
|
1719
|
-
new Assertion(obj, msg, assert.doesNotHaveAllKeys, true)
|
|
1720
|
-
|
|
1721
|
-
|
|
1808
|
+
new Assertion(obj, msg, assert.doesNotHaveAllKeys, true).to.not.have.all.keys(
|
|
1809
|
+
keys
|
|
1810
|
+
);
|
|
1811
|
+
};
|
|
1722
1812
|
|
|
1723
1813
|
/**
|
|
1724
1814
|
* ### .hasAnyDeepKeys(object, [keys], [message])
|
|
@@ -1744,9 +1834,10 @@ assert.doesNotHaveAllKeys = function (obj, keys, msg) {
|
|
|
1744
1834
|
* @public
|
|
1745
1835
|
*/
|
|
1746
1836
|
assert.hasAnyDeepKeys = function (obj, keys, msg) {
|
|
1747
|
-
new Assertion(obj, msg, assert.hasAnyDeepKeys, true)
|
|
1748
|
-
|
|
1749
|
-
|
|
1837
|
+
new Assertion(obj, msg, assert.hasAnyDeepKeys, true).to.have.any.deep.keys(
|
|
1838
|
+
keys
|
|
1839
|
+
);
|
|
1840
|
+
};
|
|
1750
1841
|
|
|
1751
1842
|
/**
|
|
1752
1843
|
* ### .hasAllDeepKeys(object, [keys], [message])
|
|
@@ -1770,9 +1861,10 @@ assert.hasAnyDeepKeys = function (obj, keys, msg) {
|
|
|
1770
1861
|
* @public
|
|
1771
1862
|
*/
|
|
1772
1863
|
assert.hasAllDeepKeys = function (obj, keys, msg) {
|
|
1773
|
-
new Assertion(obj, msg, assert.hasAllDeepKeys, true)
|
|
1774
|
-
|
|
1775
|
-
|
|
1864
|
+
new Assertion(obj, msg, assert.hasAllDeepKeys, true).to.have.all.deep.keys(
|
|
1865
|
+
keys
|
|
1866
|
+
);
|
|
1867
|
+
};
|
|
1776
1868
|
|
|
1777
1869
|
/**
|
|
1778
1870
|
* ### .containsAllDeepKeys(object, [keys], [message])
|
|
@@ -1796,9 +1888,13 @@ assert.hasAllDeepKeys = function (obj, keys, msg) {
|
|
|
1796
1888
|
* @public
|
|
1797
1889
|
*/
|
|
1798
1890
|
assert.containsAllDeepKeys = function (obj, keys, msg) {
|
|
1799
|
-
new Assertion(
|
|
1800
|
-
|
|
1801
|
-
|
|
1891
|
+
new Assertion(
|
|
1892
|
+
obj,
|
|
1893
|
+
msg,
|
|
1894
|
+
assert.containsAllDeepKeys,
|
|
1895
|
+
true
|
|
1896
|
+
).to.contain.all.deep.keys(keys);
|
|
1897
|
+
};
|
|
1802
1898
|
|
|
1803
1899
|
/**
|
|
1804
1900
|
* ### .doesNotHaveAnyDeepKeys(object, [keys], [message])
|
|
@@ -1822,9 +1918,13 @@ assert.containsAllDeepKeys = function (obj, keys, msg) {
|
|
|
1822
1918
|
* @public
|
|
1823
1919
|
*/
|
|
1824
1920
|
assert.doesNotHaveAnyDeepKeys = function (obj, keys, msg) {
|
|
1825
|
-
new Assertion(
|
|
1826
|
-
|
|
1827
|
-
|
|
1921
|
+
new Assertion(
|
|
1922
|
+
obj,
|
|
1923
|
+
msg,
|
|
1924
|
+
assert.doesNotHaveAnyDeepKeys,
|
|
1925
|
+
true
|
|
1926
|
+
).to.not.have.any.deep.keys(keys);
|
|
1927
|
+
};
|
|
1828
1928
|
|
|
1829
1929
|
/**
|
|
1830
1930
|
* ### .doesNotHaveAllDeepKeys(object, [keys], [message])
|
|
@@ -1848,9 +1948,13 @@ assert.doesNotHaveAnyDeepKeys = function (obj, keys, msg) {
|
|
|
1848
1948
|
* @public
|
|
1849
1949
|
*/
|
|
1850
1950
|
assert.doesNotHaveAllDeepKeys = function (obj, keys, msg) {
|
|
1851
|
-
new Assertion(
|
|
1852
|
-
|
|
1853
|
-
|
|
1951
|
+
new Assertion(
|
|
1952
|
+
obj,
|
|
1953
|
+
msg,
|
|
1954
|
+
assert.doesNotHaveAllDeepKeys,
|
|
1955
|
+
true
|
|
1956
|
+
).to.not.have.all.deep.keys(keys);
|
|
1957
|
+
};
|
|
1854
1958
|
|
|
1855
1959
|
/**
|
|
1856
1960
|
* ### .throws(fn, [errorLike/string/regexp], [string/regexp], [message])
|
|
@@ -1889,8 +1993,10 @@ assert.throws = function (fn, errorLike, errMsgMatcher, msg) {
|
|
|
1889
1993
|
errorLike = null;
|
|
1890
1994
|
}
|
|
1891
1995
|
|
|
1892
|
-
var assertErr = new Assertion(fn, msg, assert.throws, true)
|
|
1893
|
-
|
|
1996
|
+
var assertErr = new Assertion(fn, msg, assert.throws, true).to.throw(
|
|
1997
|
+
errorLike,
|
|
1998
|
+
errMsgMatcher
|
|
1999
|
+
);
|
|
1894
2000
|
return flag(assertErr, 'object');
|
|
1895
2001
|
};
|
|
1896
2002
|
|
|
@@ -1928,8 +2034,10 @@ assert.doesNotThrow = function (fn, errorLike, errMsgMatcher, message) {
|
|
|
1928
2034
|
errorLike = null;
|
|
1929
2035
|
}
|
|
1930
2036
|
|
|
1931
|
-
new Assertion(fn, message, assert.doesNotThrow, true)
|
|
1932
|
-
|
|
2037
|
+
new Assertion(fn, message, assert.doesNotThrow, true).to.not.throw(
|
|
2038
|
+
errorLike,
|
|
2039
|
+
errMsgMatcher
|
|
2040
|
+
);
|
|
1933
2041
|
};
|
|
1934
2042
|
|
|
1935
2043
|
/**
|
|
@@ -1950,7 +2058,7 @@ assert.doesNotThrow = function (fn, errorLike, errMsgMatcher, message) {
|
|
|
1950
2058
|
*/
|
|
1951
2059
|
assert.operator = function (val, operator, val2, msg) {
|
|
1952
2060
|
var ok;
|
|
1953
|
-
switch(operator) {
|
|
2061
|
+
switch (operator) {
|
|
1954
2062
|
case '==':
|
|
1955
2063
|
ok = val == val2;
|
|
1956
2064
|
break;
|
|
@@ -1985,9 +2093,10 @@ assert.operator = function (val, operator, val2, msg) {
|
|
|
1985
2093
|
}
|
|
1986
2094
|
var test = new Assertion(ok, msg, assert.operator, true);
|
|
1987
2095
|
test.assert(
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
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
|
+
);
|
|
1991
2100
|
};
|
|
1992
2101
|
|
|
1993
2102
|
/**
|
|
@@ -2025,8 +2134,10 @@ assert.closeTo = function (act, exp, delta, msg) {
|
|
|
2025
2134
|
* @public
|
|
2026
2135
|
*/
|
|
2027
2136
|
assert.approximately = function (act, exp, delta, msg) {
|
|
2028
|
-
new Assertion(act, msg, assert.approximately, true)
|
|
2029
|
-
|
|
2137
|
+
new Assertion(act, msg, assert.approximately, true).to.be.approximately(
|
|
2138
|
+
exp,
|
|
2139
|
+
delta
|
|
2140
|
+
);
|
|
2030
2141
|
};
|
|
2031
2142
|
|
|
2032
2143
|
/**
|
|
@@ -2045,9 +2156,8 @@ assert.approximately = function (act, exp, delta, msg) {
|
|
|
2045
2156
|
* @public
|
|
2046
2157
|
*/
|
|
2047
2158
|
assert.sameMembers = function (set1, set2, msg) {
|
|
2048
|
-
new Assertion(set1, msg, assert.sameMembers, true)
|
|
2049
|
-
|
|
2050
|
-
}
|
|
2159
|
+
new Assertion(set1, msg, assert.sameMembers, true).to.have.same.members(set2);
|
|
2160
|
+
};
|
|
2051
2161
|
|
|
2052
2162
|
/**
|
|
2053
2163
|
* ### .notSameMembers(set1, set2, [message])
|
|
@@ -2065,9 +2175,13 @@ assert.sameMembers = function (set1, set2, msg) {
|
|
|
2065
2175
|
* @public
|
|
2066
2176
|
*/
|
|
2067
2177
|
assert.notSameMembers = function (set1, set2, msg) {
|
|
2068
|
-
new Assertion(
|
|
2069
|
-
|
|
2070
|
-
|
|
2178
|
+
new Assertion(
|
|
2179
|
+
set1,
|
|
2180
|
+
msg,
|
|
2181
|
+
assert.notSameMembers,
|
|
2182
|
+
true
|
|
2183
|
+
).to.not.have.same.members(set2);
|
|
2184
|
+
};
|
|
2071
2185
|
|
|
2072
2186
|
/**
|
|
2073
2187
|
* ### .sameDeepMembers(set1, set2, [message])
|
|
@@ -2085,9 +2199,13 @@ assert.notSameMembers = function (set1, set2, msg) {
|
|
|
2085
2199
|
* @public
|
|
2086
2200
|
*/
|
|
2087
2201
|
assert.sameDeepMembers = function (set1, set2, msg) {
|
|
2088
|
-
new Assertion(
|
|
2089
|
-
|
|
2090
|
-
|
|
2202
|
+
new Assertion(
|
|
2203
|
+
set1,
|
|
2204
|
+
msg,
|
|
2205
|
+
assert.sameDeepMembers,
|
|
2206
|
+
true
|
|
2207
|
+
).to.have.same.deep.members(set2);
|
|
2208
|
+
};
|
|
2091
2209
|
|
|
2092
2210
|
/**
|
|
2093
2211
|
* ### .notSameDeepMembers(set1, set2, [message])
|
|
@@ -2105,9 +2223,13 @@ assert.sameDeepMembers = function (set1, set2, msg) {
|
|
|
2105
2223
|
* @public
|
|
2106
2224
|
*/
|
|
2107
2225
|
assert.notSameDeepMembers = function (set1, set2, msg) {
|
|
2108
|
-
new Assertion(
|
|
2109
|
-
|
|
2110
|
-
|
|
2226
|
+
new Assertion(
|
|
2227
|
+
set1,
|
|
2228
|
+
msg,
|
|
2229
|
+
assert.notSameDeepMembers,
|
|
2230
|
+
true
|
|
2231
|
+
).to.not.have.same.deep.members(set2);
|
|
2232
|
+
};
|
|
2111
2233
|
|
|
2112
2234
|
/**
|
|
2113
2235
|
* ### .sameOrderedMembers(set1, set2, [message])
|
|
@@ -2125,9 +2247,13 @@ assert.notSameDeepMembers = function (set1, set2, msg) {
|
|
|
2125
2247
|
* @public
|
|
2126
2248
|
*/
|
|
2127
2249
|
assert.sameOrderedMembers = function (set1, set2, msg) {
|
|
2128
|
-
new Assertion(
|
|
2129
|
-
|
|
2130
|
-
|
|
2250
|
+
new Assertion(
|
|
2251
|
+
set1,
|
|
2252
|
+
msg,
|
|
2253
|
+
assert.sameOrderedMembers,
|
|
2254
|
+
true
|
|
2255
|
+
).to.have.same.ordered.members(set2);
|
|
2256
|
+
};
|
|
2131
2257
|
|
|
2132
2258
|
/**
|
|
2133
2259
|
* ### .notSameOrderedMembers(set1, set2, [message])
|
|
@@ -2145,9 +2271,13 @@ assert.sameOrderedMembers = function (set1, set2, msg) {
|
|
|
2145
2271
|
* @public
|
|
2146
2272
|
*/
|
|
2147
2273
|
assert.notSameOrderedMembers = function (set1, set2, msg) {
|
|
2148
|
-
new Assertion(
|
|
2149
|
-
|
|
2150
|
-
|
|
2274
|
+
new Assertion(
|
|
2275
|
+
set1,
|
|
2276
|
+
msg,
|
|
2277
|
+
assert.notSameOrderedMembers,
|
|
2278
|
+
true
|
|
2279
|
+
).to.not.have.same.ordered.members(set2);
|
|
2280
|
+
};
|
|
2151
2281
|
|
|
2152
2282
|
/**
|
|
2153
2283
|
* ### .sameDeepOrderedMembers(set1, set2, [message])
|
|
@@ -2165,9 +2295,13 @@ assert.notSameOrderedMembers = function (set1, set2, msg) {
|
|
|
2165
2295
|
* @public
|
|
2166
2296
|
*/
|
|
2167
2297
|
assert.sameDeepOrderedMembers = function (set1, set2, msg) {
|
|
2168
|
-
new Assertion(
|
|
2169
|
-
|
|
2170
|
-
|
|
2298
|
+
new Assertion(
|
|
2299
|
+
set1,
|
|
2300
|
+
msg,
|
|
2301
|
+
assert.sameDeepOrderedMembers,
|
|
2302
|
+
true
|
|
2303
|
+
).to.have.same.deep.ordered.members(set2);
|
|
2304
|
+
};
|
|
2171
2305
|
|
|
2172
2306
|
/**
|
|
2173
2307
|
* ### .notSameDeepOrderedMembers(set1, set2, [message])
|
|
@@ -2186,9 +2320,13 @@ assert.sameDeepOrderedMembers = function (set1, set2, msg) {
|
|
|
2186
2320
|
* @public
|
|
2187
2321
|
*/
|
|
2188
2322
|
assert.notSameDeepOrderedMembers = function (set1, set2, msg) {
|
|
2189
|
-
new Assertion(
|
|
2190
|
-
|
|
2191
|
-
|
|
2323
|
+
new Assertion(
|
|
2324
|
+
set1,
|
|
2325
|
+
msg,
|
|
2326
|
+
assert.notSameDeepOrderedMembers,
|
|
2327
|
+
true
|
|
2328
|
+
).to.not.have.same.deep.ordered.members(set2);
|
|
2329
|
+
};
|
|
2192
2330
|
|
|
2193
2331
|
/**
|
|
2194
2332
|
* ### .includeMembers(superset, subset, [message])
|
|
@@ -2206,9 +2344,10 @@ assert.notSameDeepOrderedMembers = function (set1, set2, msg) {
|
|
|
2206
2344
|
* @public
|
|
2207
2345
|
*/
|
|
2208
2346
|
assert.includeMembers = function (superset, subset, msg) {
|
|
2209
|
-
new Assertion(superset, msg, assert.includeMembers, true)
|
|
2210
|
-
|
|
2211
|
-
|
|
2347
|
+
new Assertion(superset, msg, assert.includeMembers, true).to.include.members(
|
|
2348
|
+
subset
|
|
2349
|
+
);
|
|
2350
|
+
};
|
|
2212
2351
|
|
|
2213
2352
|
/**
|
|
2214
2353
|
* ### .notIncludeMembers(superset, subset, [message])
|
|
@@ -2226,9 +2365,13 @@ assert.includeMembers = function (superset, subset, msg) {
|
|
|
2226
2365
|
* @public
|
|
2227
2366
|
*/
|
|
2228
2367
|
assert.notIncludeMembers = function (superset, subset, msg) {
|
|
2229
|
-
new Assertion(
|
|
2230
|
-
|
|
2231
|
-
|
|
2368
|
+
new Assertion(
|
|
2369
|
+
superset,
|
|
2370
|
+
msg,
|
|
2371
|
+
assert.notIncludeMembers,
|
|
2372
|
+
true
|
|
2373
|
+
).to.not.include.members(subset);
|
|
2374
|
+
};
|
|
2232
2375
|
|
|
2233
2376
|
/**
|
|
2234
2377
|
* ### .includeDeepMembers(superset, subset, [message])
|
|
@@ -2246,9 +2389,13 @@ assert.notIncludeMembers = function (superset, subset, msg) {
|
|
|
2246
2389
|
* @public
|
|
2247
2390
|
*/
|
|
2248
2391
|
assert.includeDeepMembers = function (superset, subset, msg) {
|
|
2249
|
-
new Assertion(
|
|
2250
|
-
|
|
2251
|
-
|
|
2392
|
+
new Assertion(
|
|
2393
|
+
superset,
|
|
2394
|
+
msg,
|
|
2395
|
+
assert.includeDeepMembers,
|
|
2396
|
+
true
|
|
2397
|
+
).to.include.deep.members(subset);
|
|
2398
|
+
};
|
|
2252
2399
|
|
|
2253
2400
|
/**
|
|
2254
2401
|
* ### .notIncludeDeepMembers(superset, subset, [message])
|
|
@@ -2266,9 +2413,13 @@ assert.includeDeepMembers = function (superset, subset, msg) {
|
|
|
2266
2413
|
* @public
|
|
2267
2414
|
*/
|
|
2268
2415
|
assert.notIncludeDeepMembers = function (superset, subset, msg) {
|
|
2269
|
-
new Assertion(
|
|
2270
|
-
|
|
2271
|
-
|
|
2416
|
+
new Assertion(
|
|
2417
|
+
superset,
|
|
2418
|
+
msg,
|
|
2419
|
+
assert.notIncludeDeepMembers,
|
|
2420
|
+
true
|
|
2421
|
+
).to.not.include.deep.members(subset);
|
|
2422
|
+
};
|
|
2272
2423
|
|
|
2273
2424
|
/**
|
|
2274
2425
|
* ### .includeOrderedMembers(superset, subset, [message])
|
|
@@ -2287,9 +2438,13 @@ assert.notIncludeDeepMembers = function (superset, subset, msg) {
|
|
|
2287
2438
|
* @public
|
|
2288
2439
|
*/
|
|
2289
2440
|
assert.includeOrderedMembers = function (superset, subset, msg) {
|
|
2290
|
-
new Assertion(
|
|
2291
|
-
|
|
2292
|
-
|
|
2441
|
+
new Assertion(
|
|
2442
|
+
superset,
|
|
2443
|
+
msg,
|
|
2444
|
+
assert.includeOrderedMembers,
|
|
2445
|
+
true
|
|
2446
|
+
).to.include.ordered.members(subset);
|
|
2447
|
+
};
|
|
2293
2448
|
|
|
2294
2449
|
/**
|
|
2295
2450
|
* ### .notIncludeOrderedMembers(superset, subset, [message])
|
|
@@ -2309,9 +2464,13 @@ assert.includeOrderedMembers = function (superset, subset, msg) {
|
|
|
2309
2464
|
* @public
|
|
2310
2465
|
*/
|
|
2311
2466
|
assert.notIncludeOrderedMembers = function (superset, subset, msg) {
|
|
2312
|
-
new Assertion(
|
|
2313
|
-
|
|
2314
|
-
|
|
2467
|
+
new Assertion(
|
|
2468
|
+
superset,
|
|
2469
|
+
msg,
|
|
2470
|
+
assert.notIncludeOrderedMembers,
|
|
2471
|
+
true
|
|
2472
|
+
).to.not.include.ordered.members(subset);
|
|
2473
|
+
};
|
|
2315
2474
|
|
|
2316
2475
|
/**
|
|
2317
2476
|
* ### .includeDeepOrderedMembers(superset, subset, [message])
|
|
@@ -2330,9 +2489,13 @@ assert.notIncludeOrderedMembers = function (superset, subset, msg) {
|
|
|
2330
2489
|
* @public
|
|
2331
2490
|
*/
|
|
2332
2491
|
assert.includeDeepOrderedMembers = function (superset, subset, msg) {
|
|
2333
|
-
new Assertion(
|
|
2334
|
-
|
|
2335
|
-
|
|
2492
|
+
new Assertion(
|
|
2493
|
+
superset,
|
|
2494
|
+
msg,
|
|
2495
|
+
assert.includeDeepOrderedMembers,
|
|
2496
|
+
true
|
|
2497
|
+
).to.include.deep.ordered.members(subset);
|
|
2498
|
+
};
|
|
2336
2499
|
|
|
2337
2500
|
/**
|
|
2338
2501
|
* ### .notIncludeDeepOrderedMembers(superset, subset, [message])
|
|
@@ -2353,9 +2516,13 @@ assert.includeDeepOrderedMembers = function (superset, subset, msg) {
|
|
|
2353
2516
|
* @public
|
|
2354
2517
|
*/
|
|
2355
2518
|
assert.notIncludeDeepOrderedMembers = function (superset, subset, msg) {
|
|
2356
|
-
new Assertion(
|
|
2357
|
-
|
|
2358
|
-
|
|
2519
|
+
new Assertion(
|
|
2520
|
+
superset,
|
|
2521
|
+
msg,
|
|
2522
|
+
assert.notIncludeDeepOrderedMembers,
|
|
2523
|
+
true
|
|
2524
|
+
).to.not.include.deep.ordered.members(subset);
|
|
2525
|
+
};
|
|
2359
2526
|
|
|
2360
2527
|
/**
|
|
2361
2528
|
* ### .oneOf(inList, list, [message])
|
|
@@ -2373,7 +2540,7 @@ assert.notIncludeDeepOrderedMembers = function (superset, subset, msg) {
|
|
|
2373
2540
|
*/
|
|
2374
2541
|
assert.oneOf = function (inList, list, msg) {
|
|
2375
2542
|
new Assertion(inList, msg, assert.oneOf, true).to.be.oneOf(list);
|
|
2376
|
-
}
|
|
2543
|
+
};
|
|
2377
2544
|
|
|
2378
2545
|
/**
|
|
2379
2546
|
* ### isIterable(obj, [message])
|
|
@@ -2388,19 +2555,15 @@ assert.oneOf = function (inList, list, msg) {
|
|
|
2388
2555
|
* @namespace Assert
|
|
2389
2556
|
* @public
|
|
2390
2557
|
*/
|
|
2391
|
-
assert.isIterable = function(obj, msg) {
|
|
2558
|
+
assert.isIterable = function (obj, msg) {
|
|
2392
2559
|
if (obj == undefined || !obj[Symbol.iterator]) {
|
|
2393
|
-
msg = msg
|
|
2394
|
-
`${msg} expected ${inspect(obj)} to be an iterable`
|
|
2395
|
-
`expected ${inspect(obj)} to be an iterable`;
|
|
2396
|
-
|
|
2397
|
-
throw new AssertionError(
|
|
2398
|
-
msg,
|
|
2399
|
-
undefined,
|
|
2400
|
-
assert.isIterable
|
|
2401
|
-
);
|
|
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);
|
|
2402
2565
|
}
|
|
2403
|
-
}
|
|
2566
|
+
};
|
|
2404
2567
|
|
|
2405
2568
|
/**
|
|
2406
2569
|
* ### .changes(function, object, property, [message])
|
|
@@ -2426,7 +2589,7 @@ assert.changes = function (fn, obj, prop, msg) {
|
|
|
2426
2589
|
}
|
|
2427
2590
|
|
|
2428
2591
|
new Assertion(fn, msg, assert.changes, true).to.change(obj, prop);
|
|
2429
|
-
}
|
|
2592
|
+
};
|
|
2430
2593
|
|
|
2431
2594
|
/**
|
|
2432
2595
|
* ### .changesBy(function, object, property, delta, [message])
|
|
@@ -2456,9 +2619,8 @@ assert.changesBy = function (fn, obj, prop, delta, msg) {
|
|
|
2456
2619
|
prop = null;
|
|
2457
2620
|
}
|
|
2458
2621
|
|
|
2459
|
-
new Assertion(fn, msg, assert.changesBy, true)
|
|
2460
|
-
|
|
2461
|
-
}
|
|
2622
|
+
new Assertion(fn, msg, assert.changesBy, true).to.change(obj, prop).by(delta);
|
|
2623
|
+
};
|
|
2462
2624
|
|
|
2463
2625
|
/**
|
|
2464
2626
|
* ### .doesNotChange(function, object, property, [message])
|
|
@@ -2484,9 +2646,11 @@ assert.doesNotChange = function (fn, obj, prop, msg) {
|
|
|
2484
2646
|
prop = null;
|
|
2485
2647
|
}
|
|
2486
2648
|
|
|
2487
|
-
return new Assertion(fn, msg, assert.doesNotChange, true)
|
|
2488
|
-
|
|
2489
|
-
|
|
2649
|
+
return new Assertion(fn, msg, assert.doesNotChange, true).to.not.change(
|
|
2650
|
+
obj,
|
|
2651
|
+
prop
|
|
2652
|
+
);
|
|
2653
|
+
};
|
|
2490
2654
|
|
|
2491
2655
|
/**
|
|
2492
2656
|
* ### .changesButNotBy(function, object, property, delta, [message])
|
|
@@ -2516,9 +2680,10 @@ assert.changesButNotBy = function (fn, obj, prop, delta, msg) {
|
|
|
2516
2680
|
prop = null;
|
|
2517
2681
|
}
|
|
2518
2682
|
|
|
2519
|
-
new Assertion(fn, msg, assert.changesButNotBy, true)
|
|
2520
|
-
.
|
|
2521
|
-
|
|
2683
|
+
new Assertion(fn, msg, assert.changesButNotBy, true).to
|
|
2684
|
+
.change(obj, prop)
|
|
2685
|
+
.but.not.by(delta);
|
|
2686
|
+
};
|
|
2522
2687
|
|
|
2523
2688
|
/**
|
|
2524
2689
|
* ### .increases(function, object, property, [message])
|
|
@@ -2544,9 +2709,8 @@ assert.increases = function (fn, obj, prop, msg) {
|
|
|
2544
2709
|
prop = null;
|
|
2545
2710
|
}
|
|
2546
2711
|
|
|
2547
|
-
return new Assertion(fn, msg, assert.increases, true)
|
|
2548
|
-
|
|
2549
|
-
}
|
|
2712
|
+
return new Assertion(fn, msg, assert.increases, true).to.increase(obj, prop);
|
|
2713
|
+
};
|
|
2550
2714
|
|
|
2551
2715
|
/**
|
|
2552
2716
|
* ### .increasesBy(function, object, property, delta, [message])
|
|
@@ -2576,9 +2740,10 @@ assert.increasesBy = function (fn, obj, prop, delta, msg) {
|
|
|
2576
2740
|
prop = null;
|
|
2577
2741
|
}
|
|
2578
2742
|
|
|
2579
|
-
new Assertion(fn, msg, assert.increasesBy, true)
|
|
2580
|
-
.
|
|
2581
|
-
|
|
2743
|
+
new Assertion(fn, msg, assert.increasesBy, true).to
|
|
2744
|
+
.increase(obj, prop)
|
|
2745
|
+
.by(delta);
|
|
2746
|
+
};
|
|
2582
2747
|
|
|
2583
2748
|
/**
|
|
2584
2749
|
* ### .doesNotIncrease(function, object, property, [message])
|
|
@@ -2604,9 +2769,11 @@ assert.doesNotIncrease = function (fn, obj, prop, msg) {
|
|
|
2604
2769
|
prop = null;
|
|
2605
2770
|
}
|
|
2606
2771
|
|
|
2607
|
-
return new Assertion(fn, msg, assert.doesNotIncrease, true)
|
|
2608
|
-
|
|
2609
|
-
|
|
2772
|
+
return new Assertion(fn, msg, assert.doesNotIncrease, true).to.not.increase(
|
|
2773
|
+
obj,
|
|
2774
|
+
prop
|
|
2775
|
+
);
|
|
2776
|
+
};
|
|
2610
2777
|
|
|
2611
2778
|
/**
|
|
2612
2779
|
* ### .increasesButNotBy(function, object, property, delta, [message])
|
|
@@ -2636,9 +2803,10 @@ assert.increasesButNotBy = function (fn, obj, prop, delta, msg) {
|
|
|
2636
2803
|
prop = null;
|
|
2637
2804
|
}
|
|
2638
2805
|
|
|
2639
|
-
new Assertion(fn, msg, assert.increasesButNotBy, true)
|
|
2640
|
-
.
|
|
2641
|
-
|
|
2806
|
+
new Assertion(fn, msg, assert.increasesButNotBy, true).to
|
|
2807
|
+
.increase(obj, prop)
|
|
2808
|
+
.but.not.by(delta);
|
|
2809
|
+
};
|
|
2642
2810
|
|
|
2643
2811
|
/**
|
|
2644
2812
|
* ### .decreases(function, object, property, [message])
|
|
@@ -2664,9 +2832,8 @@ assert.decreases = function (fn, obj, prop, msg) {
|
|
|
2664
2832
|
prop = null;
|
|
2665
2833
|
}
|
|
2666
2834
|
|
|
2667
|
-
return new Assertion(fn, msg, assert.decreases, true)
|
|
2668
|
-
|
|
2669
|
-
}
|
|
2835
|
+
return new Assertion(fn, msg, assert.decreases, true).to.decrease(obj, prop);
|
|
2836
|
+
};
|
|
2670
2837
|
|
|
2671
2838
|
/**
|
|
2672
2839
|
* ### .decreasesBy(function, object, property, delta, [message])
|
|
@@ -2696,9 +2863,10 @@ assert.decreasesBy = function (fn, obj, prop, delta, msg) {
|
|
|
2696
2863
|
prop = null;
|
|
2697
2864
|
}
|
|
2698
2865
|
|
|
2699
|
-
new Assertion(fn, msg, assert.decreasesBy, true)
|
|
2700
|
-
.
|
|
2701
|
-
|
|
2866
|
+
new Assertion(fn, msg, assert.decreasesBy, true).to
|
|
2867
|
+
.decrease(obj, prop)
|
|
2868
|
+
.by(delta);
|
|
2869
|
+
};
|
|
2702
2870
|
|
|
2703
2871
|
/**
|
|
2704
2872
|
* ### .doesNotDecrease(function, object, property, [message])
|
|
@@ -2724,9 +2892,11 @@ assert.doesNotDecrease = function (fn, obj, prop, msg) {
|
|
|
2724
2892
|
prop = null;
|
|
2725
2893
|
}
|
|
2726
2894
|
|
|
2727
|
-
return new Assertion(fn, msg, assert.doesNotDecrease, true)
|
|
2728
|
-
|
|
2729
|
-
|
|
2895
|
+
return new Assertion(fn, msg, assert.doesNotDecrease, true).to.not.decrease(
|
|
2896
|
+
obj,
|
|
2897
|
+
prop
|
|
2898
|
+
);
|
|
2899
|
+
};
|
|
2730
2900
|
|
|
2731
2901
|
/**
|
|
2732
2902
|
* ### .doesNotDecreaseBy(function, object, property, delta, [message])
|
|
@@ -2757,9 +2927,10 @@ assert.doesNotDecreaseBy = function (fn, obj, prop, delta, msg) {
|
|
|
2757
2927
|
prop = null;
|
|
2758
2928
|
}
|
|
2759
2929
|
|
|
2760
|
-
return new Assertion(fn, msg, assert.doesNotDecreaseBy, true)
|
|
2761
|
-
.
|
|
2762
|
-
|
|
2930
|
+
return new Assertion(fn, msg, assert.doesNotDecreaseBy, true).to.not
|
|
2931
|
+
.decrease(obj, prop)
|
|
2932
|
+
.by(delta);
|
|
2933
|
+
};
|
|
2763
2934
|
|
|
2764
2935
|
/**
|
|
2765
2936
|
* ### .decreasesButNotBy(function, object, property, delta, [message])
|
|
@@ -2789,9 +2960,10 @@ assert.decreasesButNotBy = function (fn, obj, prop, delta, msg) {
|
|
|
2789
2960
|
prop = null;
|
|
2790
2961
|
}
|
|
2791
2962
|
|
|
2792
|
-
new Assertion(fn, msg, assert.decreasesButNotBy, true)
|
|
2793
|
-
.
|
|
2794
|
-
|
|
2963
|
+
new Assertion(fn, msg, assert.decreasesButNotBy, true).to
|
|
2964
|
+
.decrease(obj, prop)
|
|
2965
|
+
.but.not.by(delta);
|
|
2966
|
+
};
|
|
2795
2967
|
|
|
2796
2968
|
/**
|
|
2797
2969
|
* ### .ifError(object)
|
|
@@ -2810,7 +2982,7 @@ assert.decreasesButNotBy = function (fn, obj, prop, delta, msg) {
|
|
|
2810
2982
|
*/
|
|
2811
2983
|
assert.ifError = function (val) {
|
|
2812
2984
|
if (val) {
|
|
2813
|
-
throw
|
|
2985
|
+
throw val;
|
|
2814
2986
|
}
|
|
2815
2987
|
};
|
|
2816
2988
|
|
|
@@ -2956,7 +3128,7 @@ assert.isNotFrozen = function (obj, msg) {
|
|
|
2956
3128
|
* @namespace Assert
|
|
2957
3129
|
* @public
|
|
2958
3130
|
*/
|
|
2959
|
-
assert.isEmpty = function(val, msg) {
|
|
3131
|
+
assert.isEmpty = function (val, msg) {
|
|
2960
3132
|
new Assertion(val, msg, assert.isEmpty, true).to.be.empty;
|
|
2961
3133
|
};
|
|
2962
3134
|
|
|
@@ -2981,10 +3153,52 @@ assert.isEmpty = function(val, msg) {
|
|
|
2981
3153
|
* @namespace Assert
|
|
2982
3154
|
* @public
|
|
2983
3155
|
*/
|
|
2984
|
-
assert.isNotEmpty = function(val, msg) {
|
|
3156
|
+
assert.isNotEmpty = function (val, msg) {
|
|
2985
3157
|
new Assertion(val, msg, assert.isNotEmpty, true).to.not.be.empty;
|
|
2986
3158
|
};
|
|
2987
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
|
+
|
|
2988
3202
|
/**
|
|
2989
3203
|
* Aliases.
|
|
2990
3204
|
*
|
|
@@ -2992,21 +3206,23 @@ assert.isNotEmpty = function(val, msg) {
|
|
|
2992
3206
|
* @param {unknown} as
|
|
2993
3207
|
* @returns {unknown}
|
|
2994
3208
|
*/
|
|
2995
|
-
|
|
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) {
|
|
2996
3227
|
assert[as] = assert[name];
|
|
2997
|
-
|
|
2998
|
-
})
|
|
2999
|
-
('isOk', 'ok')
|
|
3000
|
-
('isNotOk', 'notOk')
|
|
3001
|
-
('throws', 'throw')
|
|
3002
|
-
('throws', 'Throw')
|
|
3003
|
-
('isExtensible', 'extensible')
|
|
3004
|
-
('isNotExtensible', 'notExtensible')
|
|
3005
|
-
('isSealed', 'sealed')
|
|
3006
|
-
('isNotSealed', 'notSealed')
|
|
3007
|
-
('isFrozen', 'frozen')
|
|
3008
|
-
('isNotFrozen', 'notFrozen')
|
|
3009
|
-
('isEmpty', 'empty')
|
|
3010
|
-
('isNotEmpty', 'notEmpty')
|
|
3011
|
-
('isCallable', 'isFunction')
|
|
3012
|
-
('isNotCallable', 'isNotFunction')
|
|
3228
|
+
}
|