chai 4.2.0 → 4.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/chai.js +191 -59
- package/index.mjs +14 -0
- package/karma.conf.js +7 -1
- package/karma.sauce.js +1 -1
- package/lib/chai/assertion.js +12 -2
- package/lib/chai/core/assertions.js +67 -18
- package/lib/chai/interface/assert.js +6 -6
- package/lib/chai/interface/should.js +2 -1
- package/lib/chai/utils/getOperator.js +55 -0
- package/lib/chai/utils/index.js +6 -0
- package/lib/chai.js +1 -1
- package/package.json +14 -7
- package/sauce.browsers.js +4 -0
package/README.md
CHANGED
package/chai.js
CHANGED
|
@@ -14,7 +14,7 @@ var used = [];
|
|
|
14
14
|
* Chai version
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
exports.version = '4.
|
|
17
|
+
exports.version = '4.3.3';
|
|
18
18
|
|
|
19
19
|
/*!
|
|
20
20
|
* Assertion Error
|
|
@@ -95,7 +95,7 @@ exports.use(should);
|
|
|
95
95
|
var assert = require('./chai/interface/assert');
|
|
96
96
|
exports.use(assert);
|
|
97
97
|
|
|
98
|
-
},{"./chai/assertion":3,"./chai/config":4,"./chai/core/assertions":5,"./chai/interface/assert":6,"./chai/interface/expect":7,"./chai/interface/should":8,"./chai/utils":
|
|
98
|
+
},{"./chai/assertion":3,"./chai/config":4,"./chai/core/assertions":5,"./chai/interface/assert":6,"./chai/interface/expect":7,"./chai/interface/should":8,"./chai/utils":23,"assertion-error":34}],3:[function(require,module,exports){
|
|
99
99
|
/*!
|
|
100
100
|
* chai
|
|
101
101
|
* http://chaijs.com
|
|
@@ -236,11 +236,21 @@ module.exports = function (_chai, util) {
|
|
|
236
236
|
if (!ok) {
|
|
237
237
|
msg = util.getMessage(this, arguments);
|
|
238
238
|
var actual = util.getActual(this, arguments);
|
|
239
|
-
|
|
239
|
+
var assertionErrorObjectProperties = {
|
|
240
240
|
actual: actual
|
|
241
241
|
, expected: expected
|
|
242
242
|
, showDiff: showDiff
|
|
243
|
-
}
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
var operator = util.getOperator(this, arguments);
|
|
246
|
+
if (operator) {
|
|
247
|
+
assertionErrorObjectProperties.operator = operator;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
throw new AssertionError(
|
|
251
|
+
msg,
|
|
252
|
+
assertionErrorObjectProperties,
|
|
253
|
+
(config.includeStack) ? this.assert : flag(this, 'ssfi'));
|
|
244
254
|
}
|
|
245
255
|
};
|
|
246
256
|
|
|
@@ -395,6 +405,7 @@ module.exports = function (chai, _) {
|
|
|
395
405
|
* - but
|
|
396
406
|
* - does
|
|
397
407
|
* - still
|
|
408
|
+
* - also
|
|
398
409
|
*
|
|
399
410
|
* @name language chains
|
|
400
411
|
* @namespace BDD
|
|
@@ -404,7 +415,7 @@ module.exports = function (chai, _) {
|
|
|
404
415
|
[ 'to', 'be', 'been', 'is'
|
|
405
416
|
, 'and', 'has', 'have', 'with'
|
|
406
417
|
, 'that', 'which', 'at', 'of'
|
|
407
|
-
, 'same', 'but', 'does', 'still' ].forEach(function (chain) {
|
|
418
|
+
, 'same', 'but', 'does', 'still', "also" ].forEach(function (chain) {
|
|
408
419
|
Assertion.addProperty(chain);
|
|
409
420
|
});
|
|
410
421
|
|
|
@@ -894,8 +905,13 @@ module.exports = function (chai, _) {
|
|
|
894
905
|
// objects with a custom `@@toStringTag`.
|
|
895
906
|
if (val !== Object(val)) {
|
|
896
907
|
throw new AssertionError(
|
|
897
|
-
flagMsg + '
|
|
898
|
-
|
|
908
|
+
flagMsg + 'the given combination of arguments ('
|
|
909
|
+
+ objType + ' and '
|
|
910
|
+
+ _.type(val).toLowerCase() + ')'
|
|
911
|
+
+ ' is invalid for this assertion. '
|
|
912
|
+
+ 'You can use an array, a map, an object, a set, a string, '
|
|
913
|
+
+ 'or a weakset instead of a '
|
|
914
|
+
+ _.type(val).toLowerCase(),
|
|
899
915
|
undefined,
|
|
900
916
|
ssfi
|
|
901
917
|
);
|
|
@@ -1179,19 +1195,25 @@ module.exports = function (chai, _) {
|
|
|
1179
1195
|
*
|
|
1180
1196
|
* expect(null, 'nooo why fail??').to.exist;
|
|
1181
1197
|
*
|
|
1198
|
+
* The alias `.exists` can be used interchangeably with `.exist`.
|
|
1199
|
+
*
|
|
1182
1200
|
* @name exist
|
|
1201
|
+
* @alias exists
|
|
1183
1202
|
* @namespace BDD
|
|
1184
1203
|
* @api public
|
|
1185
1204
|
*/
|
|
1186
1205
|
|
|
1187
|
-
|
|
1206
|
+
function assertExist () {
|
|
1188
1207
|
var val = flag(this, 'object');
|
|
1189
1208
|
this.assert(
|
|
1190
1209
|
val !== null && val !== undefined
|
|
1191
1210
|
, 'expected #{this} to exist'
|
|
1192
1211
|
, 'expected #{this} to not exist'
|
|
1193
1212
|
);
|
|
1194
|
-
}
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
Assertion.addProperty('exist', assertExist);
|
|
1216
|
+
Assertion.addProperty('exists', assertExist);
|
|
1195
1217
|
|
|
1196
1218
|
/**
|
|
1197
1219
|
* ### .empty
|
|
@@ -1300,7 +1322,7 @@ module.exports = function (chai, _) {
|
|
|
1300
1322
|
*
|
|
1301
1323
|
* Add `.not` earlier in the chain to negate `.arguments`. However, it's often
|
|
1302
1324
|
* best to assert which type the target is expected to be, rather than
|
|
1303
|
-
* asserting that
|
|
1325
|
+
* asserting that it’s not an `arguments` object.
|
|
1304
1326
|
*
|
|
1305
1327
|
* expect('foo').to.be.a('string'); // Recommended
|
|
1306
1328
|
* expect('foo').to.not.be.arguments; // Not recommended
|
|
@@ -1591,10 +1613,12 @@ module.exports = function (chai, _) {
|
|
|
1591
1613
|
* expect(1).to.be.at.least(2, 'nooo why fail??');
|
|
1592
1614
|
* expect(1, 'nooo why fail??').to.be.at.least(2);
|
|
1593
1615
|
*
|
|
1594
|
-
* The
|
|
1616
|
+
* The aliases `.gte` and `.greaterThanOrEqual` can be used interchangeably with
|
|
1617
|
+
* `.least`.
|
|
1595
1618
|
*
|
|
1596
1619
|
* @name least
|
|
1597
1620
|
* @alias gte
|
|
1621
|
+
* @alias greaterThanOrEqual
|
|
1598
1622
|
* @param {Number} n
|
|
1599
1623
|
* @param {String} msg _optional_
|
|
1600
1624
|
* @namespace BDD
|
|
@@ -1660,6 +1684,7 @@ module.exports = function (chai, _) {
|
|
|
1660
1684
|
|
|
1661
1685
|
Assertion.addMethod('least', assertLeast);
|
|
1662
1686
|
Assertion.addMethod('gte', assertLeast);
|
|
1687
|
+
Assertion.addMethod('greaterThanOrEqual', assertLeast);
|
|
1663
1688
|
|
|
1664
1689
|
/**
|
|
1665
1690
|
* ### .below(n[, msg])
|
|
@@ -1797,10 +1822,12 @@ module.exports = function (chai, _) {
|
|
|
1797
1822
|
* expect(2).to.be.at.most(1, 'nooo why fail??');
|
|
1798
1823
|
* expect(2, 'nooo why fail??').to.be.at.most(1);
|
|
1799
1824
|
*
|
|
1800
|
-
* The
|
|
1825
|
+
* The aliases `.lte` and `.lessThanOrEqual` can be used interchangeably with
|
|
1826
|
+
* `.most`.
|
|
1801
1827
|
*
|
|
1802
1828
|
* @name most
|
|
1803
1829
|
* @alias lte
|
|
1830
|
+
* @alias lessThanOrEqual
|
|
1804
1831
|
* @param {Number} n
|
|
1805
1832
|
* @param {String} msg _optional_
|
|
1806
1833
|
* @namespace BDD
|
|
@@ -1866,6 +1893,7 @@ module.exports = function (chai, _) {
|
|
|
1866
1893
|
|
|
1867
1894
|
Assertion.addMethod('most', assertMost);
|
|
1868
1895
|
Assertion.addMethod('lte', assertMost);
|
|
1896
|
+
Assertion.addMethod('lessThanOrEqual', assertMost);
|
|
1869
1897
|
|
|
1870
1898
|
/**
|
|
1871
1899
|
* ### .within(start, finish[, msg])
|
|
@@ -2282,7 +2310,7 @@ module.exports = function (chai, _) {
|
|
|
2282
2310
|
* a `descriptor`. The problem is that it creates uncertain expectations by
|
|
2283
2311
|
* asserting that the target either doesn't have a property descriptor with
|
|
2284
2312
|
* the given key `name`, or that it does have a property descriptor with the
|
|
2285
|
-
* given key `name` but
|
|
2313
|
+
* given key `name` but it’s not deeply equal to the given `descriptor`. It's
|
|
2286
2314
|
* often best to identify the exact output that's expected, and then write an
|
|
2287
2315
|
* assertion that only accepts that exact output.
|
|
2288
2316
|
*
|
|
@@ -3311,8 +3339,9 @@ module.exports = function (chai, _) {
|
|
|
3311
3339
|
new Assertion(obj, flagMsg, ssfi, true).is.a('number');
|
|
3312
3340
|
if (typeof expected !== 'number' || typeof delta !== 'number') {
|
|
3313
3341
|
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
3342
|
+
var deltaMessage = delta === undefined ? ", and a delta is required" : "";
|
|
3314
3343
|
throw new AssertionError(
|
|
3315
|
-
flagMsg + 'the arguments to closeTo or approximately must be numbers',
|
|
3344
|
+
flagMsg + 'the arguments to closeTo or approximately must be numbers' + deltaMessage,
|
|
3316
3345
|
undefined,
|
|
3317
3346
|
ssfi
|
|
3318
3347
|
);
|
|
@@ -3478,6 +3507,14 @@ module.exports = function (chai, _) {
|
|
|
3478
3507
|
* expect(1).to.equal(1); // Recommended
|
|
3479
3508
|
* expect(1).to.not.be.oneOf([2, 3, 4]); // Not recommended
|
|
3480
3509
|
*
|
|
3510
|
+
* It can also be chained with `.contain` or `.include`, which will work with
|
|
3511
|
+
* both arrays and strings:
|
|
3512
|
+
*
|
|
3513
|
+
* expect('Today is sunny').to.contain.oneOf(['sunny', 'cloudy'])
|
|
3514
|
+
* expect('Today is rainy').to.not.contain.oneOf(['sunny', 'cloudy'])
|
|
3515
|
+
* expect([1,2,3]).to.contain.oneOf([3,4,5])
|
|
3516
|
+
* expect([1,2,3]).to.not.contain.oneOf([4,5,6])
|
|
3517
|
+
*
|
|
3481
3518
|
* `.oneOf` accepts an optional `msg` argument which is a custom error message
|
|
3482
3519
|
* to show when the assertion fails. The message can also be given as the
|
|
3483
3520
|
* second argument to `expect`.
|
|
@@ -3496,16 +3533,38 @@ module.exports = function (chai, _) {
|
|
|
3496
3533
|
if (msg) flag(this, 'message', msg);
|
|
3497
3534
|
var expected = flag(this, 'object')
|
|
3498
3535
|
, flagMsg = flag(this, 'message')
|
|
3499
|
-
, ssfi = flag(this, 'ssfi')
|
|
3536
|
+
, ssfi = flag(this, 'ssfi')
|
|
3537
|
+
, contains = flag(this, 'contains')
|
|
3538
|
+
, isDeep = flag(this, 'deep');
|
|
3500
3539
|
new Assertion(list, flagMsg, ssfi, true).to.be.an('array');
|
|
3501
3540
|
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3541
|
+
if (contains) {
|
|
3542
|
+
this.assert(
|
|
3543
|
+
list.some(function(possibility) { return expected.indexOf(possibility) > -1 })
|
|
3544
|
+
, 'expected #{this} to contain one of #{exp}'
|
|
3545
|
+
, 'expected #{this} to not contain one of #{exp}'
|
|
3546
|
+
, list
|
|
3547
|
+
, expected
|
|
3548
|
+
);
|
|
3549
|
+
} else {
|
|
3550
|
+
if (isDeep) {
|
|
3551
|
+
this.assert(
|
|
3552
|
+
list.some(function(possibility) { return _.eql(expected, possibility) })
|
|
3553
|
+
, 'expected #{this} to deeply equal one of #{exp}'
|
|
3554
|
+
, 'expected #{this} to deeply equal one of #{exp}'
|
|
3555
|
+
, list
|
|
3556
|
+
, expected
|
|
3557
|
+
);
|
|
3558
|
+
} else {
|
|
3559
|
+
this.assert(
|
|
3560
|
+
list.indexOf(expected) > -1
|
|
3561
|
+
, 'expected #{this} to be one of #{exp}'
|
|
3562
|
+
, 'expected #{this} to not be one of #{exp}'
|
|
3563
|
+
, list
|
|
3564
|
+
, expected
|
|
3565
|
+
);
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3509
3568
|
}
|
|
3510
3569
|
|
|
3511
3570
|
Assertion.addMethod('oneOf', oneOf);
|
|
@@ -5993,7 +6052,7 @@ module.exports = function (chai, util) {
|
|
|
5993
6052
|
* assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {three: 'three'}]);
|
|
5994
6053
|
* assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]);
|
|
5995
6054
|
*
|
|
5996
|
-
* @name
|
|
6055
|
+
* @name hasAnyDeepKeys
|
|
5997
6056
|
* @param {Mixed} object
|
|
5998
6057
|
* @param {Array|Object} keys
|
|
5999
6058
|
* @param {String} message
|
|
@@ -6427,7 +6486,7 @@ module.exports = function (chai, util) {
|
|
|
6427
6486
|
* Asserts that `set1` and `set2` have the same members in the same order.
|
|
6428
6487
|
* Uses a deep equality check.
|
|
6429
6488
|
*
|
|
6430
|
-
*
|
|
6489
|
+
* assert.sameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { c: 3 } ], 'same deep ordered members');
|
|
6431
6490
|
*
|
|
6432
6491
|
* @name sameDeepOrderedMembers
|
|
6433
6492
|
* @param {Array} set1
|
|
@@ -6448,8 +6507,8 @@ module.exports = function (chai, util) {
|
|
|
6448
6507
|
* Asserts that `set1` and `set2` don't have the same members in the same
|
|
6449
6508
|
* order. Uses a deep equality check.
|
|
6450
6509
|
*
|
|
6451
|
-
*
|
|
6452
|
-
*
|
|
6510
|
+
* assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { z: 5 } ], 'not same deep ordered members');
|
|
6511
|
+
* assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 }, { c: 3 } ], 'not same deep ordered members');
|
|
6453
6512
|
*
|
|
6454
6513
|
* @name notSameDeepOrderedMembers
|
|
6455
6514
|
* @param {Array} set1
|
|
@@ -6869,7 +6928,7 @@ module.exports = function (chai, util) {
|
|
|
6869
6928
|
}
|
|
6870
6929
|
|
|
6871
6930
|
/**
|
|
6872
|
-
* ### .increasesButNotBy(function, object, property, [message])
|
|
6931
|
+
* ### .increasesButNotBy(function, object, property, delta, [message])
|
|
6873
6932
|
*
|
|
6874
6933
|
* Asserts that a function does not increase a numeric object property or function's return value by an amount (delta).
|
|
6875
6934
|
*
|
|
@@ -6999,7 +7058,7 @@ module.exports = function (chai, util) {
|
|
|
6999
7058
|
* var fn = function() { obj.val = 5 };
|
|
7000
7059
|
* assert.doesNotDecreaseBy(fn, obj, 'val', 1);
|
|
7001
7060
|
*
|
|
7002
|
-
* @name
|
|
7061
|
+
* @name doesNotDecreaseBy
|
|
7003
7062
|
* @param {Function} modifier function
|
|
7004
7063
|
* @param {Object} object or getter function
|
|
7005
7064
|
* @param {String} property name _optional_
|
|
@@ -7344,7 +7403,8 @@ module.exports = function (chai, util) {
|
|
|
7344
7403
|
if (this instanceof String
|
|
7345
7404
|
|| this instanceof Number
|
|
7346
7405
|
|| this instanceof Boolean
|
|
7347
|
-
|| typeof Symbol === 'function' && this instanceof Symbol
|
|
7406
|
+
|| typeof Symbol === 'function' && this instanceof Symbol
|
|
7407
|
+
|| typeof BigInt === 'function' && this instanceof BigInt) {
|
|
7348
7408
|
return new Assertion(this.valueOf(), null, shouldGetter);
|
|
7349
7409
|
}
|
|
7350
7410
|
return new Assertion(this, null, shouldGetter);
|
|
@@ -7702,7 +7762,7 @@ module.exports = function addChainableMethod(ctx, name, method, chainingBehavior
|
|
|
7702
7762
|
});
|
|
7703
7763
|
};
|
|
7704
7764
|
|
|
7705
|
-
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":
|
|
7765
|
+
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":31,"./transferFlags":33}],10:[function(require,module,exports){
|
|
7706
7766
|
var fnLengthDesc = Object.getOwnPropertyDescriptor(function () {}, 'length');
|
|
7707
7767
|
|
|
7708
7768
|
/*!
|
|
@@ -7834,7 +7894,7 @@ module.exports = function addMethod(ctx, name, method) {
|
|
|
7834
7894
|
ctx[name] = proxify(methodWrapper, name);
|
|
7835
7895
|
};
|
|
7836
7896
|
|
|
7837
|
-
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":
|
|
7897
|
+
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":31,"./transferFlags":33}],12:[function(require,module,exports){
|
|
7838
7898
|
/*!
|
|
7839
7899
|
* Chai - addProperty utility
|
|
7840
7900
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -7908,7 +7968,7 @@ module.exports = function addProperty(ctx, name, getter) {
|
|
|
7908
7968
|
});
|
|
7909
7969
|
};
|
|
7910
7970
|
|
|
7911
|
-
},{"../../chai":2,"./flag":15,"./isProxyEnabled":
|
|
7971
|
+
},{"../../chai":2,"./flag":15,"./isProxyEnabled":26,"./transferFlags":33}],13:[function(require,module,exports){
|
|
7912
7972
|
/*!
|
|
7913
7973
|
* Chai - compareByInspect utility
|
|
7914
7974
|
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -7941,7 +8001,7 @@ module.exports = function compareByInspect(a, b) {
|
|
|
7941
8001
|
return inspect(a) < inspect(b) ? -1 : 1;
|
|
7942
8002
|
};
|
|
7943
8003
|
|
|
7944
|
-
},{"./inspect":
|
|
8004
|
+
},{"./inspect":24}],14:[function(require,module,exports){
|
|
7945
8005
|
/*!
|
|
7946
8006
|
* Chai - expectTypes utility
|
|
7947
8007
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -7994,7 +8054,7 @@ module.exports = function expectTypes(obj, types) {
|
|
|
7994
8054
|
}
|
|
7995
8055
|
};
|
|
7996
8056
|
|
|
7997
|
-
},{"./flag":15,"assertion-error":
|
|
8057
|
+
},{"./flag":15,"assertion-error":34,"type-detect":39}],15:[function(require,module,exports){
|
|
7998
8058
|
/*!
|
|
7999
8059
|
* Chai - flag utility
|
|
8000
8060
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8131,7 +8191,64 @@ module.exports = function getMessage(obj, args) {
|
|
|
8131
8191
|
return flagMsg ? flagMsg + ': ' + msg : msg;
|
|
8132
8192
|
};
|
|
8133
8193
|
|
|
8134
|
-
},{"./flag":15,"./getActual":16,"./objDisplay":
|
|
8194
|
+
},{"./flag":15,"./getActual":16,"./objDisplay":27}],19:[function(require,module,exports){
|
|
8195
|
+
var type = require('type-detect');
|
|
8196
|
+
|
|
8197
|
+
var flag = require('./flag');
|
|
8198
|
+
|
|
8199
|
+
function isObjectType(obj) {
|
|
8200
|
+
var objectType = type(obj);
|
|
8201
|
+
var objectTypes = ['Array', 'Object', 'function'];
|
|
8202
|
+
|
|
8203
|
+
return objectTypes.indexOf(objectType) !== -1;
|
|
8204
|
+
}
|
|
8205
|
+
|
|
8206
|
+
/**
|
|
8207
|
+
* ### .getOperator(message)
|
|
8208
|
+
*
|
|
8209
|
+
* Extract the operator from error message.
|
|
8210
|
+
* Operator defined is based on below link
|
|
8211
|
+
* https://nodejs.org/api/assert.html#assert_assert.
|
|
8212
|
+
*
|
|
8213
|
+
* Returns the `operator` or `undefined` value for an Assertion.
|
|
8214
|
+
*
|
|
8215
|
+
* @param {Object} object (constructed Assertion)
|
|
8216
|
+
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
|
8217
|
+
* @namespace Utils
|
|
8218
|
+
* @name getOperator
|
|
8219
|
+
* @api public
|
|
8220
|
+
*/
|
|
8221
|
+
|
|
8222
|
+
module.exports = function getOperator(obj, args) {
|
|
8223
|
+
var operator = flag(obj, 'operator');
|
|
8224
|
+
var negate = flag(obj, 'negate');
|
|
8225
|
+
var expected = args[3];
|
|
8226
|
+
var msg = negate ? args[2] : args[1];
|
|
8227
|
+
|
|
8228
|
+
if (operator) {
|
|
8229
|
+
return operator;
|
|
8230
|
+
}
|
|
8231
|
+
|
|
8232
|
+
if (typeof msg === 'function') msg = msg();
|
|
8233
|
+
|
|
8234
|
+
msg = msg || '';
|
|
8235
|
+
if (!msg) {
|
|
8236
|
+
return undefined;
|
|
8237
|
+
}
|
|
8238
|
+
|
|
8239
|
+
if (/\shave\s/.test(msg)) {
|
|
8240
|
+
return undefined;
|
|
8241
|
+
}
|
|
8242
|
+
|
|
8243
|
+
var isObject = isObjectType(expected);
|
|
8244
|
+
if (/\snot\s/.test(msg)) {
|
|
8245
|
+
return isObject ? 'notDeepStrictEqual' : 'notStrictEqual';
|
|
8246
|
+
}
|
|
8247
|
+
|
|
8248
|
+
return isObject ? 'deepStrictEqual' : 'strictEqual';
|
|
8249
|
+
};
|
|
8250
|
+
|
|
8251
|
+
},{"./flag":15,"type-detect":39}],20:[function(require,module,exports){
|
|
8135
8252
|
/*!
|
|
8136
8253
|
* Chai - getOwnEnumerableProperties utility
|
|
8137
8254
|
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8162,7 +8279,7 @@ module.exports = function getOwnEnumerableProperties(obj) {
|
|
|
8162
8279
|
return Object.keys(obj).concat(getOwnEnumerablePropertySymbols(obj));
|
|
8163
8280
|
};
|
|
8164
8281
|
|
|
8165
|
-
},{"./getOwnEnumerablePropertySymbols":
|
|
8282
|
+
},{"./getOwnEnumerablePropertySymbols":21}],21:[function(require,module,exports){
|
|
8166
8283
|
/*!
|
|
8167
8284
|
* Chai - getOwnEnumerablePropertySymbols utility
|
|
8168
8285
|
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8191,7 +8308,7 @@ module.exports = function getOwnEnumerablePropertySymbols(obj) {
|
|
|
8191
8308
|
});
|
|
8192
8309
|
};
|
|
8193
8310
|
|
|
8194
|
-
},{}],
|
|
8311
|
+
},{}],22:[function(require,module,exports){
|
|
8195
8312
|
/*!
|
|
8196
8313
|
* Chai - getProperties utility
|
|
8197
8314
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8229,7 +8346,7 @@ module.exports = function getProperties(object) {
|
|
|
8229
8346
|
return result;
|
|
8230
8347
|
};
|
|
8231
8348
|
|
|
8232
|
-
},{}],
|
|
8349
|
+
},{}],23:[function(require,module,exports){
|
|
8233
8350
|
/*!
|
|
8234
8351
|
* chai
|
|
8235
8352
|
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8403,7 +8520,12 @@ exports.isProxyEnabled = require('./isProxyEnabled');
|
|
|
8403
8520
|
|
|
8404
8521
|
exports.isNaN = require('./isNaN');
|
|
8405
8522
|
|
|
8406
|
-
|
|
8523
|
+
/*!
|
|
8524
|
+
* getOperator method
|
|
8525
|
+
*/
|
|
8526
|
+
|
|
8527
|
+
exports.getOperator = require('./getOperator');
|
|
8528
|
+
},{"./addChainableMethod":9,"./addLengthGuard":10,"./addMethod":11,"./addProperty":12,"./compareByInspect":13,"./expectTypes":14,"./flag":15,"./getActual":16,"./getMessage":18,"./getOperator":19,"./getOwnEnumerableProperties":20,"./getOwnEnumerablePropertySymbols":21,"./inspect":24,"./isNaN":25,"./isProxyEnabled":26,"./objDisplay":27,"./overwriteChainableMethod":28,"./overwriteMethod":29,"./overwriteProperty":30,"./proxify":31,"./test":32,"./transferFlags":33,"check-error":35,"deep-eql":36,"get-func-name":37,"pathval":38,"type-detect":39}],24:[function(require,module,exports){
|
|
8407
8529
|
// This is (almost) directly from Node.js utils
|
|
8408
8530
|
// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js
|
|
8409
8531
|
|
|
@@ -8781,7 +8903,7 @@ function objectToString(o) {
|
|
|
8781
8903
|
return Object.prototype.toString.call(o);
|
|
8782
8904
|
}
|
|
8783
8905
|
|
|
8784
|
-
},{"../config":4,"./getEnumerableProperties":17,"./getProperties":
|
|
8906
|
+
},{"../config":4,"./getEnumerableProperties":17,"./getProperties":22,"get-func-name":37}],25:[function(require,module,exports){
|
|
8785
8907
|
/*!
|
|
8786
8908
|
* Chai - isNaN utility
|
|
8787
8909
|
* Copyright(c) 2012-2015 Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
|
|
@@ -8809,7 +8931,7 @@ function isNaN(value) {
|
|
|
8809
8931
|
// If ECMAScript 6's Number.isNaN is present, prefer that.
|
|
8810
8932
|
module.exports = Number.isNaN || isNaN;
|
|
8811
8933
|
|
|
8812
|
-
},{}],
|
|
8934
|
+
},{}],26:[function(require,module,exports){
|
|
8813
8935
|
var config = require('../config');
|
|
8814
8936
|
|
|
8815
8937
|
/*!
|
|
@@ -8835,7 +8957,7 @@ module.exports = function isProxyEnabled() {
|
|
|
8835
8957
|
typeof Reflect !== 'undefined';
|
|
8836
8958
|
};
|
|
8837
8959
|
|
|
8838
|
-
},{"../config":4}],
|
|
8960
|
+
},{"../config":4}],27:[function(require,module,exports){
|
|
8839
8961
|
/*!
|
|
8840
8962
|
* Chai - flag utility
|
|
8841
8963
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8887,7 +9009,7 @@ module.exports = function objDisplay(obj) {
|
|
|
8887
9009
|
}
|
|
8888
9010
|
};
|
|
8889
9011
|
|
|
8890
|
-
},{"../config":4,"./inspect":
|
|
9012
|
+
},{"../config":4,"./inspect":24}],28:[function(require,module,exports){
|
|
8891
9013
|
/*!
|
|
8892
9014
|
* Chai - overwriteChainableMethod utility
|
|
8893
9015
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8958,7 +9080,7 @@ module.exports = function overwriteChainableMethod(ctx, name, method, chainingBe
|
|
|
8958
9080
|
};
|
|
8959
9081
|
};
|
|
8960
9082
|
|
|
8961
|
-
},{"../../chai":2,"./transferFlags":
|
|
9083
|
+
},{"../../chai":2,"./transferFlags":33}],29:[function(require,module,exports){
|
|
8962
9084
|
/*!
|
|
8963
9085
|
* Chai - overwriteMethod utility
|
|
8964
9086
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -9052,7 +9174,7 @@ module.exports = function overwriteMethod(ctx, name, method) {
|
|
|
9052
9174
|
ctx[name] = proxify(overwritingMethodWrapper, name);
|
|
9053
9175
|
};
|
|
9054
9176
|
|
|
9055
|
-
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":
|
|
9177
|
+
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":31,"./transferFlags":33}],30:[function(require,module,exports){
|
|
9056
9178
|
/*!
|
|
9057
9179
|
* Chai - overwriteProperty utility
|
|
9058
9180
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -9146,7 +9268,7 @@ module.exports = function overwriteProperty(ctx, name, getter) {
|
|
|
9146
9268
|
});
|
|
9147
9269
|
};
|
|
9148
9270
|
|
|
9149
|
-
},{"../../chai":2,"./flag":15,"./isProxyEnabled":
|
|
9271
|
+
},{"../../chai":2,"./flag":15,"./isProxyEnabled":26,"./transferFlags":33}],31:[function(require,module,exports){
|
|
9150
9272
|
var config = require('../config');
|
|
9151
9273
|
var flag = require('./flag');
|
|
9152
9274
|
var getProperties = require('./getProperties');
|
|
@@ -9295,7 +9417,7 @@ function stringDistanceCapped(strA, strB, cap) {
|
|
|
9295
9417
|
return memo[strA.length][strB.length];
|
|
9296
9418
|
}
|
|
9297
9419
|
|
|
9298
|
-
},{"../config":4,"./flag":15,"./getProperties":
|
|
9420
|
+
},{"../config":4,"./flag":15,"./getProperties":22,"./isProxyEnabled":26}],32:[function(require,module,exports){
|
|
9299
9421
|
/*!
|
|
9300
9422
|
* Chai - test utility
|
|
9301
9423
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -9325,7 +9447,7 @@ module.exports = function test(obj, args) {
|
|
|
9325
9447
|
return negate ? !expr : expr;
|
|
9326
9448
|
};
|
|
9327
9449
|
|
|
9328
|
-
},{"./flag":15}],
|
|
9450
|
+
},{"./flag":15}],33:[function(require,module,exports){
|
|
9329
9451
|
/*!
|
|
9330
9452
|
* Chai - transferFlags utility
|
|
9331
9453
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -9372,7 +9494,7 @@ module.exports = function transferFlags(assertion, object, includeAll) {
|
|
|
9372
9494
|
}
|
|
9373
9495
|
};
|
|
9374
9496
|
|
|
9375
|
-
},{}],
|
|
9497
|
+
},{}],34:[function(require,module,exports){
|
|
9376
9498
|
/*!
|
|
9377
9499
|
* assertion-error
|
|
9378
9500
|
* Copyright(c) 2013 Jake Luer <jake@qualiancy.com>
|
|
@@ -9490,7 +9612,7 @@ AssertionError.prototype.toJSON = function (stack) {
|
|
|
9490
9612
|
return props;
|
|
9491
9613
|
};
|
|
9492
9614
|
|
|
9493
|
-
},{}],
|
|
9615
|
+
},{}],35:[function(require,module,exports){
|
|
9494
9616
|
'use strict';
|
|
9495
9617
|
|
|
9496
9618
|
/* !
|
|
@@ -9664,7 +9786,7 @@ module.exports = {
|
|
|
9664
9786
|
getConstructorName: getConstructorName,
|
|
9665
9787
|
};
|
|
9666
9788
|
|
|
9667
|
-
},{}],
|
|
9789
|
+
},{}],36:[function(require,module,exports){
|
|
9668
9790
|
'use strict';
|
|
9669
9791
|
/* globals Symbol: false, Uint8Array: false, WeakMap: false */
|
|
9670
9792
|
/*!
|
|
@@ -10121,7 +10243,7 @@ function isPrimitive(value) {
|
|
|
10121
10243
|
return value === null || typeof value !== 'object';
|
|
10122
10244
|
}
|
|
10123
10245
|
|
|
10124
|
-
},{"type-detect":
|
|
10246
|
+
},{"type-detect":39}],37:[function(require,module,exports){
|
|
10125
10247
|
'use strict';
|
|
10126
10248
|
|
|
10127
10249
|
/* !
|
|
@@ -10167,7 +10289,7 @@ function getFuncName(aFunc) {
|
|
|
10167
10289
|
|
|
10168
10290
|
module.exports = getFuncName;
|
|
10169
10291
|
|
|
10170
|
-
},{}],
|
|
10292
|
+
},{}],38:[function(require,module,exports){
|
|
10171
10293
|
'use strict';
|
|
10172
10294
|
|
|
10173
10295
|
/* !
|
|
@@ -10246,13 +10368,20 @@ function parsePath(path) {
|
|
|
10246
10368
|
var str = path.replace(/([^\\])\[/g, '$1.[');
|
|
10247
10369
|
var parts = str.match(/(\\\.|[^.]+?)+/g);
|
|
10248
10370
|
return parts.map(function mapMatches(value) {
|
|
10371
|
+
if (
|
|
10372
|
+
value === 'constructor' ||
|
|
10373
|
+
value === '__proto__' ||
|
|
10374
|
+
value === 'prototype'
|
|
10375
|
+
) {
|
|
10376
|
+
return {};
|
|
10377
|
+
}
|
|
10249
10378
|
var regexp = /^\[(\d+)\]$/;
|
|
10250
10379
|
var mArr = regexp.exec(value);
|
|
10251
10380
|
var parsed = null;
|
|
10252
10381
|
if (mArr) {
|
|
10253
10382
|
parsed = { i: parseFloat(mArr[1]) };
|
|
10254
10383
|
} else {
|
|
10255
|
-
parsed = { p: value.replace(/\\([
|
|
10384
|
+
parsed = { p: value.replace(/\\([.[\]])/g, '$1') };
|
|
10256
10385
|
}
|
|
10257
10386
|
|
|
10258
10387
|
return parsed;
|
|
@@ -10277,7 +10406,7 @@ function parsePath(path) {
|
|
|
10277
10406
|
function internalGetPathValue(obj, parsed, pathDepth) {
|
|
10278
10407
|
var temporaryValue = obj;
|
|
10279
10408
|
var res = null;
|
|
10280
|
-
pathDepth =
|
|
10409
|
+
pathDepth = typeof pathDepth === 'undefined' ? parsed.length : pathDepth;
|
|
10281
10410
|
|
|
10282
10411
|
for (var i = 0; i < pathDepth; i++) {
|
|
10283
10412
|
var part = parsed[i];
|
|
@@ -10288,7 +10417,7 @@ function internalGetPathValue(obj, parsed, pathDepth) {
|
|
|
10288
10417
|
temporaryValue = temporaryValue[part.p];
|
|
10289
10418
|
}
|
|
10290
10419
|
|
|
10291
|
-
if (i ===
|
|
10420
|
+
if (i === pathDepth - 1) {
|
|
10292
10421
|
res = temporaryValue;
|
|
10293
10422
|
}
|
|
10294
10423
|
}
|
|
@@ -10322,7 +10451,7 @@ function internalSetPathValue(obj, val, parsed) {
|
|
|
10322
10451
|
part = parsed[i];
|
|
10323
10452
|
|
|
10324
10453
|
// If it's the last part of the path, we set the 'propName' value with the property name
|
|
10325
|
-
if (i ===
|
|
10454
|
+
if (i === pathDepth - 1) {
|
|
10326
10455
|
propName = typeof part.p === 'undefined' ? part.i : part.p;
|
|
10327
10456
|
// Now we set the property with the name held by 'propName' on object with the desired val
|
|
10328
10457
|
tempObj[propName] = val;
|
|
@@ -10369,7 +10498,10 @@ function getPathInfo(obj, path) {
|
|
|
10369
10498
|
var parsed = parsePath(path);
|
|
10370
10499
|
var last = parsed[parsed.length - 1];
|
|
10371
10500
|
var info = {
|
|
10372
|
-
parent:
|
|
10501
|
+
parent:
|
|
10502
|
+
parsed.length > 1 ?
|
|
10503
|
+
internalGetPathValue(obj, parsed, parsed.length - 1) :
|
|
10504
|
+
obj,
|
|
10373
10505
|
name: last.p || last.i,
|
|
10374
10506
|
value: internalGetPathValue(obj, parsed),
|
|
10375
10507
|
};
|
|
@@ -10460,7 +10592,7 @@ module.exports = {
|
|
|
10460
10592
|
setPathValue: setPathValue,
|
|
10461
10593
|
};
|
|
10462
10594
|
|
|
10463
|
-
},{}],
|
|
10595
|
+
},{}],39:[function(require,module,exports){
|
|
10464
10596
|
(function (global, factory) {
|
|
10465
10597
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
10466
10598
|
typeof define === 'function' && define.amd ? define(factory) :
|
package/index.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import chai from './index.js';
|
|
2
|
+
|
|
3
|
+
export const expect = chai.expect;
|
|
4
|
+
export const version = chai.version;
|
|
5
|
+
export const Assertion = chai.Assertion;
|
|
6
|
+
export const AssertionError = chai.AssertionError;
|
|
7
|
+
export const util = chai.util;
|
|
8
|
+
export const config = chai.config;
|
|
9
|
+
export const use = chai.use;
|
|
10
|
+
export const should = chai.should;
|
|
11
|
+
export const assert = chai.assert;
|
|
12
|
+
export const core = chai.core;
|
|
13
|
+
|
|
14
|
+
export default chai;
|
package/karma.conf.js
CHANGED
|
@@ -10,7 +10,13 @@ module.exports = function(config) {
|
|
|
10
10
|
, colors: true
|
|
11
11
|
, logLevel: config.LOG_INFO
|
|
12
12
|
, autoWatch: false
|
|
13
|
-
, browsers: [ '
|
|
13
|
+
, browsers: [ 'HeadlessChrome' ]
|
|
14
|
+
, customLaunchers: {
|
|
15
|
+
HeadlessChrome: {
|
|
16
|
+
base: 'ChromeHeadless'
|
|
17
|
+
, flags: [ '--no-sandbox',]
|
|
18
|
+
, }
|
|
19
|
+
, }
|
|
14
20
|
, browserDisconnectTimeout: 10000
|
|
15
21
|
, browserDisconnectTolerance: 2
|
|
16
22
|
, browserNoActivityTimeout: 20000
|
package/karma.sauce.js
CHANGED
|
@@ -26,7 +26,7 @@ module.exports = function(config) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
config.browsers = config.browsers.concat(browsers);
|
|
29
|
-
config.customLaunchers
|
|
29
|
+
Object.assign(config.customLaunchers, browserConfig);
|
|
30
30
|
config.reporters.push('saucelabs');
|
|
31
31
|
config.captureTimeout = 300000;
|
|
32
32
|
|
package/lib/chai/assertion.js
CHANGED
|
@@ -138,11 +138,21 @@ module.exports = function (_chai, util) {
|
|
|
138
138
|
if (!ok) {
|
|
139
139
|
msg = util.getMessage(this, arguments);
|
|
140
140
|
var actual = util.getActual(this, arguments);
|
|
141
|
-
|
|
141
|
+
var assertionErrorObjectProperties = {
|
|
142
142
|
actual: actual
|
|
143
143
|
, expected: expected
|
|
144
144
|
, showDiff: showDiff
|
|
145
|
-
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
var operator = util.getOperator(this, arguments);
|
|
148
|
+
if (operator) {
|
|
149
|
+
assertionErrorObjectProperties.operator = operator;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
throw new AssertionError(
|
|
153
|
+
msg,
|
|
154
|
+
assertionErrorObjectProperties,
|
|
155
|
+
(config.includeStack) ? this.assert : flag(this, 'ssfi'));
|
|
146
156
|
}
|
|
147
157
|
};
|
|
148
158
|
|
|
@@ -34,6 +34,7 @@ module.exports = function (chai, _) {
|
|
|
34
34
|
* - but
|
|
35
35
|
* - does
|
|
36
36
|
* - still
|
|
37
|
+
* - also
|
|
37
38
|
*
|
|
38
39
|
* @name language chains
|
|
39
40
|
* @namespace BDD
|
|
@@ -43,7 +44,7 @@ module.exports = function (chai, _) {
|
|
|
43
44
|
[ 'to', 'be', 'been', 'is'
|
|
44
45
|
, 'and', 'has', 'have', 'with'
|
|
45
46
|
, 'that', 'which', 'at', 'of'
|
|
46
|
-
, 'same', 'but', 'does', 'still' ].forEach(function (chain) {
|
|
47
|
+
, 'same', 'but', 'does', 'still', "also" ].forEach(function (chain) {
|
|
47
48
|
Assertion.addProperty(chain);
|
|
48
49
|
});
|
|
49
50
|
|
|
@@ -533,8 +534,13 @@ module.exports = function (chai, _) {
|
|
|
533
534
|
// objects with a custom `@@toStringTag`.
|
|
534
535
|
if (val !== Object(val)) {
|
|
535
536
|
throw new AssertionError(
|
|
536
|
-
flagMsg + '
|
|
537
|
-
|
|
537
|
+
flagMsg + 'the given combination of arguments ('
|
|
538
|
+
+ objType + ' and '
|
|
539
|
+
+ _.type(val).toLowerCase() + ')'
|
|
540
|
+
+ ' is invalid for this assertion. '
|
|
541
|
+
+ 'You can use an array, a map, an object, a set, a string, '
|
|
542
|
+
+ 'or a weakset instead of a '
|
|
543
|
+
+ _.type(val).toLowerCase(),
|
|
538
544
|
undefined,
|
|
539
545
|
ssfi
|
|
540
546
|
);
|
|
@@ -818,19 +824,25 @@ module.exports = function (chai, _) {
|
|
|
818
824
|
*
|
|
819
825
|
* expect(null, 'nooo why fail??').to.exist;
|
|
820
826
|
*
|
|
827
|
+
* The alias `.exists` can be used interchangeably with `.exist`.
|
|
828
|
+
*
|
|
821
829
|
* @name exist
|
|
830
|
+
* @alias exists
|
|
822
831
|
* @namespace BDD
|
|
823
832
|
* @api public
|
|
824
833
|
*/
|
|
825
834
|
|
|
826
|
-
|
|
835
|
+
function assertExist () {
|
|
827
836
|
var val = flag(this, 'object');
|
|
828
837
|
this.assert(
|
|
829
838
|
val !== null && val !== undefined
|
|
830
839
|
, 'expected #{this} to exist'
|
|
831
840
|
, 'expected #{this} to not exist'
|
|
832
841
|
);
|
|
833
|
-
}
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
Assertion.addProperty('exist', assertExist);
|
|
845
|
+
Assertion.addProperty('exists', assertExist);
|
|
834
846
|
|
|
835
847
|
/**
|
|
836
848
|
* ### .empty
|
|
@@ -939,7 +951,7 @@ module.exports = function (chai, _) {
|
|
|
939
951
|
*
|
|
940
952
|
* Add `.not` earlier in the chain to negate `.arguments`. However, it's often
|
|
941
953
|
* best to assert which type the target is expected to be, rather than
|
|
942
|
-
* asserting that
|
|
954
|
+
* asserting that it’s not an `arguments` object.
|
|
943
955
|
*
|
|
944
956
|
* expect('foo').to.be.a('string'); // Recommended
|
|
945
957
|
* expect('foo').to.not.be.arguments; // Not recommended
|
|
@@ -1230,10 +1242,12 @@ module.exports = function (chai, _) {
|
|
|
1230
1242
|
* expect(1).to.be.at.least(2, 'nooo why fail??');
|
|
1231
1243
|
* expect(1, 'nooo why fail??').to.be.at.least(2);
|
|
1232
1244
|
*
|
|
1233
|
-
* The
|
|
1245
|
+
* The aliases `.gte` and `.greaterThanOrEqual` can be used interchangeably with
|
|
1246
|
+
* `.least`.
|
|
1234
1247
|
*
|
|
1235
1248
|
* @name least
|
|
1236
1249
|
* @alias gte
|
|
1250
|
+
* @alias greaterThanOrEqual
|
|
1237
1251
|
* @param {Number} n
|
|
1238
1252
|
* @param {String} msg _optional_
|
|
1239
1253
|
* @namespace BDD
|
|
@@ -1299,6 +1313,7 @@ module.exports = function (chai, _) {
|
|
|
1299
1313
|
|
|
1300
1314
|
Assertion.addMethod('least', assertLeast);
|
|
1301
1315
|
Assertion.addMethod('gte', assertLeast);
|
|
1316
|
+
Assertion.addMethod('greaterThanOrEqual', assertLeast);
|
|
1302
1317
|
|
|
1303
1318
|
/**
|
|
1304
1319
|
* ### .below(n[, msg])
|
|
@@ -1436,10 +1451,12 @@ module.exports = function (chai, _) {
|
|
|
1436
1451
|
* expect(2).to.be.at.most(1, 'nooo why fail??');
|
|
1437
1452
|
* expect(2, 'nooo why fail??').to.be.at.most(1);
|
|
1438
1453
|
*
|
|
1439
|
-
* The
|
|
1454
|
+
* The aliases `.lte` and `.lessThanOrEqual` can be used interchangeably with
|
|
1455
|
+
* `.most`.
|
|
1440
1456
|
*
|
|
1441
1457
|
* @name most
|
|
1442
1458
|
* @alias lte
|
|
1459
|
+
* @alias lessThanOrEqual
|
|
1443
1460
|
* @param {Number} n
|
|
1444
1461
|
* @param {String} msg _optional_
|
|
1445
1462
|
* @namespace BDD
|
|
@@ -1505,6 +1522,7 @@ module.exports = function (chai, _) {
|
|
|
1505
1522
|
|
|
1506
1523
|
Assertion.addMethod('most', assertMost);
|
|
1507
1524
|
Assertion.addMethod('lte', assertMost);
|
|
1525
|
+
Assertion.addMethod('lessThanOrEqual', assertMost);
|
|
1508
1526
|
|
|
1509
1527
|
/**
|
|
1510
1528
|
* ### .within(start, finish[, msg])
|
|
@@ -1921,7 +1939,7 @@ module.exports = function (chai, _) {
|
|
|
1921
1939
|
* a `descriptor`. The problem is that it creates uncertain expectations by
|
|
1922
1940
|
* asserting that the target either doesn't have a property descriptor with
|
|
1923
1941
|
* the given key `name`, or that it does have a property descriptor with the
|
|
1924
|
-
* given key `name` but
|
|
1942
|
+
* given key `name` but it’s not deeply equal to the given `descriptor`. It's
|
|
1925
1943
|
* often best to identify the exact output that's expected, and then write an
|
|
1926
1944
|
* assertion that only accepts that exact output.
|
|
1927
1945
|
*
|
|
@@ -2950,8 +2968,9 @@ module.exports = function (chai, _) {
|
|
|
2950
2968
|
new Assertion(obj, flagMsg, ssfi, true).is.a('number');
|
|
2951
2969
|
if (typeof expected !== 'number' || typeof delta !== 'number') {
|
|
2952
2970
|
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
2971
|
+
var deltaMessage = delta === undefined ? ", and a delta is required" : "";
|
|
2953
2972
|
throw new AssertionError(
|
|
2954
|
-
flagMsg + 'the arguments to closeTo or approximately must be numbers',
|
|
2973
|
+
flagMsg + 'the arguments to closeTo or approximately must be numbers' + deltaMessage,
|
|
2955
2974
|
undefined,
|
|
2956
2975
|
ssfi
|
|
2957
2976
|
);
|
|
@@ -3117,6 +3136,14 @@ module.exports = function (chai, _) {
|
|
|
3117
3136
|
* expect(1).to.equal(1); // Recommended
|
|
3118
3137
|
* expect(1).to.not.be.oneOf([2, 3, 4]); // Not recommended
|
|
3119
3138
|
*
|
|
3139
|
+
* It can also be chained with `.contain` or `.include`, which will work with
|
|
3140
|
+
* both arrays and strings:
|
|
3141
|
+
*
|
|
3142
|
+
* expect('Today is sunny').to.contain.oneOf(['sunny', 'cloudy'])
|
|
3143
|
+
* expect('Today is rainy').to.not.contain.oneOf(['sunny', 'cloudy'])
|
|
3144
|
+
* expect([1,2,3]).to.contain.oneOf([3,4,5])
|
|
3145
|
+
* expect([1,2,3]).to.not.contain.oneOf([4,5,6])
|
|
3146
|
+
*
|
|
3120
3147
|
* `.oneOf` accepts an optional `msg` argument which is a custom error message
|
|
3121
3148
|
* to show when the assertion fails. The message can also be given as the
|
|
3122
3149
|
* second argument to `expect`.
|
|
@@ -3135,16 +3162,38 @@ module.exports = function (chai, _) {
|
|
|
3135
3162
|
if (msg) flag(this, 'message', msg);
|
|
3136
3163
|
var expected = flag(this, 'object')
|
|
3137
3164
|
, flagMsg = flag(this, 'message')
|
|
3138
|
-
, ssfi = flag(this, 'ssfi')
|
|
3165
|
+
, ssfi = flag(this, 'ssfi')
|
|
3166
|
+
, contains = flag(this, 'contains')
|
|
3167
|
+
, isDeep = flag(this, 'deep');
|
|
3139
3168
|
new Assertion(list, flagMsg, ssfi, true).to.be.an('array');
|
|
3140
3169
|
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3170
|
+
if (contains) {
|
|
3171
|
+
this.assert(
|
|
3172
|
+
list.some(function(possibility) { return expected.indexOf(possibility) > -1 })
|
|
3173
|
+
, 'expected #{this} to contain one of #{exp}'
|
|
3174
|
+
, 'expected #{this} to not contain one of #{exp}'
|
|
3175
|
+
, list
|
|
3176
|
+
, expected
|
|
3177
|
+
);
|
|
3178
|
+
} else {
|
|
3179
|
+
if (isDeep) {
|
|
3180
|
+
this.assert(
|
|
3181
|
+
list.some(function(possibility) { return _.eql(expected, possibility) })
|
|
3182
|
+
, 'expected #{this} to deeply equal one of #{exp}'
|
|
3183
|
+
, 'expected #{this} to deeply equal one of #{exp}'
|
|
3184
|
+
, list
|
|
3185
|
+
, expected
|
|
3186
|
+
);
|
|
3187
|
+
} else {
|
|
3188
|
+
this.assert(
|
|
3189
|
+
list.indexOf(expected) > -1
|
|
3190
|
+
, 'expected #{this} to be one of #{exp}'
|
|
3191
|
+
, 'expected #{this} to not be one of #{exp}'
|
|
3192
|
+
, list
|
|
3193
|
+
, expected
|
|
3194
|
+
);
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3148
3197
|
}
|
|
3149
3198
|
|
|
3150
3199
|
Assertion.addMethod('oneOf', oneOf);
|
|
@@ -1826,7 +1826,7 @@ module.exports = function (chai, util) {
|
|
|
1826
1826
|
* assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {three: 'three'}]);
|
|
1827
1827
|
* assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]);
|
|
1828
1828
|
*
|
|
1829
|
-
* @name
|
|
1829
|
+
* @name hasAnyDeepKeys
|
|
1830
1830
|
* @param {Mixed} object
|
|
1831
1831
|
* @param {Array|Object} keys
|
|
1832
1832
|
* @param {String} message
|
|
@@ -2260,7 +2260,7 @@ module.exports = function (chai, util) {
|
|
|
2260
2260
|
* Asserts that `set1` and `set2` have the same members in the same order.
|
|
2261
2261
|
* Uses a deep equality check.
|
|
2262
2262
|
*
|
|
2263
|
-
*
|
|
2263
|
+
* assert.sameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { c: 3 } ], 'same deep ordered members');
|
|
2264
2264
|
*
|
|
2265
2265
|
* @name sameDeepOrderedMembers
|
|
2266
2266
|
* @param {Array} set1
|
|
@@ -2281,8 +2281,8 @@ module.exports = function (chai, util) {
|
|
|
2281
2281
|
* Asserts that `set1` and `set2` don't have the same members in the same
|
|
2282
2282
|
* order. Uses a deep equality check.
|
|
2283
2283
|
*
|
|
2284
|
-
*
|
|
2285
|
-
*
|
|
2284
|
+
* assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { z: 5 } ], 'not same deep ordered members');
|
|
2285
|
+
* assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 }, { c: 3 } ], 'not same deep ordered members');
|
|
2286
2286
|
*
|
|
2287
2287
|
* @name notSameDeepOrderedMembers
|
|
2288
2288
|
* @param {Array} set1
|
|
@@ -2702,7 +2702,7 @@ module.exports = function (chai, util) {
|
|
|
2702
2702
|
}
|
|
2703
2703
|
|
|
2704
2704
|
/**
|
|
2705
|
-
* ### .increasesButNotBy(function, object, property, [message])
|
|
2705
|
+
* ### .increasesButNotBy(function, object, property, delta, [message])
|
|
2706
2706
|
*
|
|
2707
2707
|
* Asserts that a function does not increase a numeric object property or function's return value by an amount (delta).
|
|
2708
2708
|
*
|
|
@@ -2832,7 +2832,7 @@ module.exports = function (chai, util) {
|
|
|
2832
2832
|
* var fn = function() { obj.val = 5 };
|
|
2833
2833
|
* assert.doesNotDecreaseBy(fn, obj, 'val', 1);
|
|
2834
2834
|
*
|
|
2835
|
-
* @name
|
|
2835
|
+
* @name doesNotDecreaseBy
|
|
2836
2836
|
* @param {Function} modifier function
|
|
2837
2837
|
* @param {Object} object or getter function
|
|
2838
2838
|
* @param {String} property name _optional_
|
|
@@ -13,7 +13,8 @@ module.exports = function (chai, util) {
|
|
|
13
13
|
if (this instanceof String
|
|
14
14
|
|| this instanceof Number
|
|
15
15
|
|| this instanceof Boolean
|
|
16
|
-
|| typeof Symbol === 'function' && this instanceof Symbol
|
|
16
|
+
|| typeof Symbol === 'function' && this instanceof Symbol
|
|
17
|
+
|| typeof BigInt === 'function' && this instanceof BigInt) {
|
|
17
18
|
return new Assertion(this.valueOf(), null, shouldGetter);
|
|
18
19
|
}
|
|
19
20
|
return new Assertion(this, null, shouldGetter);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var type = require('type-detect');
|
|
2
|
+
|
|
3
|
+
var flag = require('./flag');
|
|
4
|
+
|
|
5
|
+
function isObjectType(obj) {
|
|
6
|
+
var objectType = type(obj);
|
|
7
|
+
var objectTypes = ['Array', 'Object', 'function'];
|
|
8
|
+
|
|
9
|
+
return objectTypes.indexOf(objectType) !== -1;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* ### .getOperator(message)
|
|
14
|
+
*
|
|
15
|
+
* Extract the operator from error message.
|
|
16
|
+
* Operator defined is based on below link
|
|
17
|
+
* https://nodejs.org/api/assert.html#assert_assert.
|
|
18
|
+
*
|
|
19
|
+
* Returns the `operator` or `undefined` value for an Assertion.
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} object (constructed Assertion)
|
|
22
|
+
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
|
23
|
+
* @namespace Utils
|
|
24
|
+
* @name getOperator
|
|
25
|
+
* @api public
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
module.exports = function getOperator(obj, args) {
|
|
29
|
+
var operator = flag(obj, 'operator');
|
|
30
|
+
var negate = flag(obj, 'negate');
|
|
31
|
+
var expected = args[3];
|
|
32
|
+
var msg = negate ? args[2] : args[1];
|
|
33
|
+
|
|
34
|
+
if (operator) {
|
|
35
|
+
return operator;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (typeof msg === 'function') msg = msg();
|
|
39
|
+
|
|
40
|
+
msg = msg || '';
|
|
41
|
+
if (!msg) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (/\shave\s/.test(msg)) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var isObject = isObjectType(expected);
|
|
50
|
+
if (/\snot\s/.test(msg)) {
|
|
51
|
+
return isObject ? 'notDeepStrictEqual' : 'notStrictEqual';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return isObject ? 'deepStrictEqual' : 'strictEqual';
|
|
55
|
+
};
|
package/lib/chai/utils/index.js
CHANGED
package/lib/chai.js
CHANGED
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"Veselin Todorov <hi@vesln.com>",
|
|
18
18
|
"John Firebaugh <john.firebaugh@gmail.com>"
|
|
19
19
|
],
|
|
20
|
-
"version": "4.
|
|
20
|
+
"version": "4.3.3",
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
23
|
"url": "https://github.com/chaijs/chai"
|
|
@@ -26,6 +26,13 @@
|
|
|
26
26
|
"url": "https://github.com/chaijs/chai/issues"
|
|
27
27
|
},
|
|
28
28
|
"main": "./index",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"require": "./index.js",
|
|
32
|
+
"import": "./index.mjs"
|
|
33
|
+
},
|
|
34
|
+
"./": "./"
|
|
35
|
+
},
|
|
29
36
|
"scripts": {
|
|
30
37
|
"test": "make test"
|
|
31
38
|
},
|
|
@@ -37,19 +44,19 @@
|
|
|
37
44
|
"check-error": "^1.0.2",
|
|
38
45
|
"deep-eql": "^3.0.1",
|
|
39
46
|
"get-func-name": "^2.0.0",
|
|
40
|
-
"pathval": "^1.1.
|
|
47
|
+
"pathval": "^1.1.1",
|
|
41
48
|
"type-detect": "^4.0.5"
|
|
42
49
|
},
|
|
43
50
|
"devDependencies": {
|
|
44
|
-
"browserify": "^16.
|
|
51
|
+
"browserify": "^16.2.3",
|
|
45
52
|
"bump-cli": "^1.1.3",
|
|
46
53
|
"codecov": "^3.0.0",
|
|
47
54
|
"istanbul": "^0.4.3",
|
|
48
|
-
"karma": "^
|
|
55
|
+
"karma": "^6.1.1",
|
|
56
|
+
"karma-chrome-launcher": "^2.2.0",
|
|
49
57
|
"karma-firefox-launcher": "^1.0.0",
|
|
50
|
-
"karma-mocha": "^
|
|
51
|
-
"karma-phantomjs-launcher": "^1.0.0",
|
|
58
|
+
"karma-mocha": "^2.0.1",
|
|
52
59
|
"karma-sauce-launcher": "^1.2.0",
|
|
53
|
-
"mocha": "^
|
|
60
|
+
"mocha": "^7.1.2"
|
|
54
61
|
}
|
|
55
62
|
}
|
package/sauce.browsers.js
CHANGED
|
@@ -32,11 +32,15 @@ exports['SL_IE'] = {
|
|
|
32
32
|
, browserName: 'internet explorer'
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
/*!
|
|
36
|
+
* TODO: fails because of Uint8Array support
|
|
37
|
+
*
|
|
35
38
|
exports['SL_IE_Old'] = {
|
|
36
39
|
base: 'SauceLabs'
|
|
37
40
|
, browserName: 'internet explorer'
|
|
38
41
|
, version: 10
|
|
39
42
|
};
|
|
43
|
+
*/
|
|
40
44
|
|
|
41
45
|
exports['SL_Edge'] = {
|
|
42
46
|
base: 'SauceLabs'
|