chai 4.1.0 → 4.3.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/CONTRIBUTING.md +2 -2
- package/LICENSE +1 -1
- package/README.md +6 -6
- package/chai.js +635 -782
- package/index.mjs +13 -0
- package/karma.conf.js +7 -1
- package/karma.sauce.js +1 -1
- package/lib/chai/assertion.js +12 -2
- package/lib/chai/config.js +1 -1
- package/lib/chai/core/assertions.js +267 -162
- package/lib/chai/interface/assert.js +74 -59
- package/lib/chai/interface/expect.js +13 -0
- package/lib/chai/interface/should.js +16 -1
- package/lib/chai/utils/addLengthGuard.js +0 -2
- package/lib/chai/utils/addProperty.js +1 -1
- package/lib/chai/utils/compareByInspect.js +2 -2
- package/lib/chai/utils/getMessage.js +1 -2
- package/lib/chai/utils/getOperator.js +55 -0
- package/lib/chai/utils/getOwnEnumerableProperties.js +1 -1
- package/lib/chai/utils/index.js +6 -0
- package/lib/chai/utils/inspect.js +1 -8
- package/lib/chai/utils/isProxyEnabled.js +1 -1
- package/lib/chai/utils/objDisplay.js +1 -1
- package/lib/chai/utils/overwriteChainableMethod.js +1 -1
- package/lib/chai/utils/overwriteMethod.js +1 -1
- package/lib/chai/utils/overwriteProperty.js +1 -1
- package/lib/chai/utils/proxify.js +54 -32
- package/lib/chai/utils/test.js +1 -1
- package/lib/chai/utils/transferFlags.js +1 -1
- package/lib/chai.js +1 -1
- package/package.json +20 -12
- package/sauce.browsers.js +0 -9
- package/.npmignore +0 -14
package/chai.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.chai = f()}})(function(){var define,module,exports;return (function e
|
|
1
|
+
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.chai = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
2
2
|
module.exports = require('./lib/chai');
|
|
3
3
|
|
|
4
4
|
},{"./lib/chai":2}],2:[function(require,module,exports){
|
|
@@ -14,7 +14,7 @@ var used = [];
|
|
|
14
14
|
* Chai version
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
exports.version = '4.
|
|
17
|
+
exports.version = '4.3.0';
|
|
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
|
|
|
@@ -355,7 +365,7 @@ module.exports = {
|
|
|
355
365
|
* @api public
|
|
356
366
|
*/
|
|
357
367
|
|
|
358
|
-
proxyExcludedKeys: ['then', 'inspect', 'toJSON']
|
|
368
|
+
proxyExcludedKeys: ['then', 'catch', 'inspect', 'toJSON']
|
|
359
369
|
};
|
|
360
370
|
|
|
361
371
|
},{}],5:[function(require,module,exports){
|
|
@@ -394,16 +404,17 @@ module.exports = function (chai, _) {
|
|
|
394
404
|
* - same
|
|
395
405
|
* - but
|
|
396
406
|
* - does
|
|
407
|
+
* - still
|
|
397
408
|
*
|
|
398
409
|
* @name language chains
|
|
399
410
|
* @namespace BDD
|
|
400
411
|
* @api public
|
|
401
412
|
*/
|
|
402
413
|
|
|
403
|
-
[ 'to', 'be', 'been'
|
|
404
|
-
, '
|
|
405
|
-
, '
|
|
406
|
-
, '
|
|
414
|
+
[ 'to', 'be', 'been', 'is'
|
|
415
|
+
, 'and', 'has', 'have', 'with'
|
|
416
|
+
, 'that', 'which', 'at', 'of'
|
|
417
|
+
, 'same', 'but', 'does', 'still' ].forEach(function (chain) {
|
|
407
418
|
Assertion.addProperty(chain);
|
|
408
419
|
});
|
|
409
420
|
|
|
@@ -510,7 +521,8 @@ module.exports = function (chai, _) {
|
|
|
510
521
|
* Object.prototype.b = 2;
|
|
511
522
|
*
|
|
512
523
|
* expect({a: 1}).to.have.own.property('a');
|
|
513
|
-
* expect({a: 1}).to.have.property('b')
|
|
524
|
+
* expect({a: 1}).to.have.property('b');
|
|
525
|
+
* expect({a: 1}).to.not.have.own.property('b');
|
|
514
526
|
*
|
|
515
527
|
* expect({a: 1}).to.own.include({a: 1});
|
|
516
528
|
* expect({a: 1}).to.include({b: 2}).but.not.own.include({b: 2});
|
|
@@ -571,7 +583,6 @@ module.exports = function (chai, _) {
|
|
|
571
583
|
flag(this, 'all', false);
|
|
572
584
|
});
|
|
573
585
|
|
|
574
|
-
|
|
575
586
|
/**
|
|
576
587
|
* ### .all
|
|
577
588
|
*
|
|
@@ -643,7 +654,7 @@ module.exports = function (chai, _) {
|
|
|
643
654
|
* expect(1, 'nooo why fail??').to.be.a('string');
|
|
644
655
|
*
|
|
645
656
|
* `.a` can also be used as a language chain to improve the readability of
|
|
646
|
-
* your assertions.
|
|
657
|
+
* your assertions.
|
|
647
658
|
*
|
|
648
659
|
* expect({b: 2}).to.have.a.property('b');
|
|
649
660
|
*
|
|
@@ -757,7 +768,7 @@ module.exports = function (chai, _) {
|
|
|
757
768
|
*
|
|
758
769
|
* expect('foobar').to.not.include('taco');
|
|
759
770
|
* expect([1, 2, 3]).to.not.include(4);
|
|
760
|
-
*
|
|
771
|
+
*
|
|
761
772
|
* However, it's dangerous to negate `.include` when the target is an object.
|
|
762
773
|
* The problem is that it creates uncertain expectations by asserting that the
|
|
763
774
|
* target object doesn't have all of `val`'s key/value pairs but may or may
|
|
@@ -831,52 +842,17 @@ module.exports = function (chai, _) {
|
|
|
831
842
|
function include (val, msg) {
|
|
832
843
|
if (msg) flag(this, 'message', msg);
|
|
833
844
|
|
|
834
|
-
_.expectTypes(this, [
|
|
835
|
-
'array', 'object', 'string',
|
|
836
|
-
'map', 'set', 'weakset',
|
|
837
|
-
]);
|
|
838
|
-
|
|
839
845
|
var obj = flag(this, 'object')
|
|
840
|
-
, objType = _.type(obj).toLowerCase()
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
, firstErr = null
|
|
847
|
-
, numErrs = 0;
|
|
848
|
-
|
|
849
|
-
props.forEach(function (prop) {
|
|
850
|
-
var propAssertion = new Assertion(obj);
|
|
851
|
-
_.transferFlags(this, propAssertion, true);
|
|
852
|
-
flag(propAssertion, 'lockSsfi', true);
|
|
853
|
-
|
|
854
|
-
if (!negate || props.length === 1) {
|
|
855
|
-
propAssertion.property(prop, val[prop]);
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
try {
|
|
860
|
-
propAssertion.property(prop, val[prop]);
|
|
861
|
-
} catch (err) {
|
|
862
|
-
if (!_.checkError.compatibleConstructor(err, AssertionError)) throw err;
|
|
863
|
-
if (firstErr === null) firstErr = err;
|
|
864
|
-
numErrs++;
|
|
865
|
-
}
|
|
866
|
-
}, this);
|
|
867
|
-
|
|
868
|
-
// When validating .not.include with multiple properties, we only want
|
|
869
|
-
// to throw an assertion error if all of the properties are included,
|
|
870
|
-
// in which case we throw the first property assertion error that we
|
|
871
|
-
// encountered.
|
|
872
|
-
if (negate && props.length > 1 && numErrs === props.length) throw firstErr;
|
|
846
|
+
, objType = _.type(obj).toLowerCase()
|
|
847
|
+
, flagMsg = flag(this, 'message')
|
|
848
|
+
, negate = flag(this, 'negate')
|
|
849
|
+
, ssfi = flag(this, 'ssfi')
|
|
850
|
+
, isDeep = flag(this, 'deep')
|
|
851
|
+
, descriptor = isDeep ? 'deep ' : '';
|
|
873
852
|
|
|
874
|
-
|
|
875
|
-
}
|
|
853
|
+
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
876
854
|
|
|
877
|
-
var
|
|
878
|
-
, descriptor = isDeep ? 'deep ' : ''
|
|
879
|
-
, included = false;
|
|
855
|
+
var included = false;
|
|
880
856
|
|
|
881
857
|
switch (objType) {
|
|
882
858
|
case 'string':
|
|
@@ -885,10 +861,6 @@ module.exports = function (chai, _) {
|
|
|
885
861
|
|
|
886
862
|
case 'weakset':
|
|
887
863
|
if (isDeep) {
|
|
888
|
-
var flagMsg = flag(this, 'message')
|
|
889
|
-
, ssfi = flag(this, 'ssfi');
|
|
890
|
-
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
891
|
-
|
|
892
864
|
throw new AssertionError(
|
|
893
865
|
flagMsg + 'unable to use .deep.include with WeakSet',
|
|
894
866
|
undefined,
|
|
@@ -925,6 +897,58 @@ module.exports = function (chai, _) {
|
|
|
925
897
|
included = obj.indexOf(val) !== -1;
|
|
926
898
|
}
|
|
927
899
|
break;
|
|
900
|
+
|
|
901
|
+
default:
|
|
902
|
+
// This block is for asserting a subset of properties in an object.
|
|
903
|
+
// `_.expectTypes` isn't used here because `.include` should work with
|
|
904
|
+
// objects with a custom `@@toStringTag`.
|
|
905
|
+
if (val !== Object(val)) {
|
|
906
|
+
throw new AssertionError(
|
|
907
|
+
flagMsg + 'the given combination of arguments ('
|
|
908
|
+
+ objType + ' and '
|
|
909
|
+
+ _.type(val).toLowerCase() + ')'
|
|
910
|
+
+ ' is invalid for this assertion. '
|
|
911
|
+
+ 'You can use an array, a map, an object, a set, a string, '
|
|
912
|
+
+ 'or a weakset instead of a '
|
|
913
|
+
+ _.type(val).toLowerCase(),
|
|
914
|
+
undefined,
|
|
915
|
+
ssfi
|
|
916
|
+
);
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
var props = Object.keys(val)
|
|
920
|
+
, firstErr = null
|
|
921
|
+
, numErrs = 0;
|
|
922
|
+
|
|
923
|
+
props.forEach(function (prop) {
|
|
924
|
+
var propAssertion = new Assertion(obj);
|
|
925
|
+
_.transferFlags(this, propAssertion, true);
|
|
926
|
+
flag(propAssertion, 'lockSsfi', true);
|
|
927
|
+
|
|
928
|
+
if (!negate || props.length === 1) {
|
|
929
|
+
propAssertion.property(prop, val[prop]);
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
try {
|
|
934
|
+
propAssertion.property(prop, val[prop]);
|
|
935
|
+
} catch (err) {
|
|
936
|
+
if (!_.checkError.compatibleConstructor(err, AssertionError)) {
|
|
937
|
+
throw err;
|
|
938
|
+
}
|
|
939
|
+
if (firstErr === null) firstErr = err;
|
|
940
|
+
numErrs++;
|
|
941
|
+
}
|
|
942
|
+
}, this);
|
|
943
|
+
|
|
944
|
+
// When validating .not.include with multiple properties, we only want
|
|
945
|
+
// to throw an assertion error if all of the properties are included,
|
|
946
|
+
// in which case we throw the first property assertion error that we
|
|
947
|
+
// encountered.
|
|
948
|
+
if (negate && props.length > 1 && numErrs === props.length) {
|
|
949
|
+
throw firstErr;
|
|
950
|
+
}
|
|
951
|
+
return;
|
|
928
952
|
}
|
|
929
953
|
|
|
930
954
|
// Assert inclusion in collection or substring in a string.
|
|
@@ -942,9 +966,9 @@ module.exports = function (chai, _) {
|
|
|
942
966
|
/**
|
|
943
967
|
* ### .ok
|
|
944
968
|
*
|
|
945
|
-
* Asserts that the target is
|
|
946
|
-
* often best to assert that the target is strictly (`===`) or
|
|
947
|
-
* its expected value.
|
|
969
|
+
* Asserts that the target is a truthy value (considered `true` in boolean context).
|
|
970
|
+
* However, it's often best to assert that the target is strictly (`===`) or
|
|
971
|
+
* deeply equal to its expected value.
|
|
948
972
|
*
|
|
949
973
|
* expect(1).to.equal(1); // Recommended
|
|
950
974
|
* expect(1).to.be.ok; // Not recommended
|
|
@@ -1291,7 +1315,7 @@ module.exports = function (chai, _) {
|
|
|
1291
1315
|
*
|
|
1292
1316
|
* Add `.not` earlier in the chain to negate `.arguments`. However, it's often
|
|
1293
1317
|
* best to assert which type the target is expected to be, rather than
|
|
1294
|
-
* asserting that
|
|
1318
|
+
* asserting that it’s not an `arguments` object.
|
|
1295
1319
|
*
|
|
1296
1320
|
* expect('foo').to.be.a('string'); // Recommended
|
|
1297
1321
|
* expect('foo').to.not.be.arguments; // Not recommended
|
|
@@ -1328,7 +1352,7 @@ module.exports = function (chai, _) {
|
|
|
1328
1352
|
*
|
|
1329
1353
|
* expect(1).to.equal(1);
|
|
1330
1354
|
* expect('foo').to.equal('foo');
|
|
1331
|
-
*
|
|
1355
|
+
*
|
|
1332
1356
|
* Add `.deep` earlier in the chain to use deep equality instead. See the
|
|
1333
1357
|
* `deep-eql` project page for info on the deep equality algorithm:
|
|
1334
1358
|
* https://github.com/chaijs/deep-eql.
|
|
@@ -1370,7 +1394,10 @@ module.exports = function (chai, _) {
|
|
|
1370
1394
|
if (msg) flag(this, 'message', msg);
|
|
1371
1395
|
var obj = flag(this, 'object');
|
|
1372
1396
|
if (flag(this, 'deep')) {
|
|
1373
|
-
|
|
1397
|
+
var prevLockSsfi = flag(this, 'lockSsfi');
|
|
1398
|
+
flag(this, 'lockSsfi', true);
|
|
1399
|
+
this.eql(val);
|
|
1400
|
+
flag(this, 'lockSsfi', prevLockSsfi);
|
|
1374
1401
|
} else {
|
|
1375
1402
|
this.assert(
|
|
1376
1403
|
val === obj
|
|
@@ -1453,8 +1480,8 @@ module.exports = function (chai, _) {
|
|
|
1453
1480
|
* expect(2).to.equal(2); // Recommended
|
|
1454
1481
|
* expect(2).to.be.above(1); // Not recommended
|
|
1455
1482
|
*
|
|
1456
|
-
* Add `.lengthOf` earlier in the chain to assert that the
|
|
1457
|
-
*
|
|
1483
|
+
* Add `.lengthOf` earlier in the chain to assert that the target's `length`
|
|
1484
|
+
* or `size` is greater than the given number `n`.
|
|
1458
1485
|
*
|
|
1459
1486
|
* expect('foo').to.have.lengthOf(3); // Recommended
|
|
1460
1487
|
* expect('foo').to.have.lengthOf.above(2); // Not recommended
|
|
@@ -1495,12 +1522,13 @@ module.exports = function (chai, _) {
|
|
|
1495
1522
|
, ssfi = flag(this, 'ssfi')
|
|
1496
1523
|
, objType = _.type(obj).toLowerCase()
|
|
1497
1524
|
, nType = _.type(n).toLowerCase()
|
|
1525
|
+
, errorMessage
|
|
1498
1526
|
, shouldThrow = true;
|
|
1499
1527
|
|
|
1500
|
-
if (doLength) {
|
|
1528
|
+
if (doLength && objType !== 'map' && objType !== 'set') {
|
|
1501
1529
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
|
|
1502
1530
|
}
|
|
1503
|
-
|
|
1531
|
+
|
|
1504
1532
|
if (!doLength && (objType === 'date' && nType !== 'date')) {
|
|
1505
1533
|
errorMessage = msgPrefix + 'the argument to above must be a date';
|
|
1506
1534
|
} else if (nType !== 'number' && (doLength || objType === 'number')) {
|
|
@@ -1517,13 +1545,20 @@ module.exports = function (chai, _) {
|
|
|
1517
1545
|
}
|
|
1518
1546
|
|
|
1519
1547
|
if (doLength) {
|
|
1520
|
-
var
|
|
1548
|
+
var descriptor = 'length'
|
|
1549
|
+
, itemsCount;
|
|
1550
|
+
if (objType === 'map' || objType === 'set') {
|
|
1551
|
+
descriptor = 'size';
|
|
1552
|
+
itemsCount = obj.size;
|
|
1553
|
+
} else {
|
|
1554
|
+
itemsCount = obj.length;
|
|
1555
|
+
}
|
|
1521
1556
|
this.assert(
|
|
1522
|
-
|
|
1523
|
-
, 'expected #{this} to have a
|
|
1524
|
-
, 'expected #{this} to not have a
|
|
1557
|
+
itemsCount > n
|
|
1558
|
+
, 'expected #{this} to have a ' + descriptor + ' above #{exp} but got #{act}'
|
|
1559
|
+
, 'expected #{this} to not have a ' + descriptor + ' above #{exp}'
|
|
1525
1560
|
, n
|
|
1526
|
-
,
|
|
1561
|
+
, itemsCount
|
|
1527
1562
|
);
|
|
1528
1563
|
} else {
|
|
1529
1564
|
this.assert(
|
|
@@ -1550,9 +1585,8 @@ module.exports = function (chai, _) {
|
|
|
1550
1585
|
* expect(2).to.be.at.least(1); // Not recommended
|
|
1551
1586
|
* expect(2).to.be.at.least(2); // Not recommended
|
|
1552
1587
|
*
|
|
1553
|
-
* Add `.lengthOf` earlier in the chain to assert that the
|
|
1554
|
-
*
|
|
1555
|
-
* `n`.
|
|
1588
|
+
* Add `.lengthOf` earlier in the chain to assert that the target's `length`
|
|
1589
|
+
* or `size` is greater than or equal to the given number `n`.
|
|
1556
1590
|
*
|
|
1557
1591
|
* expect('foo').to.have.lengthOf(3); // Recommended
|
|
1558
1592
|
* expect('foo').to.have.lengthOf.at.least(2); // Not recommended
|
|
@@ -1591,9 +1625,10 @@ module.exports = function (chai, _) {
|
|
|
1591
1625
|
, ssfi = flag(this, 'ssfi')
|
|
1592
1626
|
, objType = _.type(obj).toLowerCase()
|
|
1593
1627
|
, nType = _.type(n).toLowerCase()
|
|
1628
|
+
, errorMessage
|
|
1594
1629
|
, shouldThrow = true;
|
|
1595
1630
|
|
|
1596
|
-
if (doLength) {
|
|
1631
|
+
if (doLength && objType !== 'map' && objType !== 'set') {
|
|
1597
1632
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
|
|
1598
1633
|
}
|
|
1599
1634
|
|
|
@@ -1613,13 +1648,20 @@ module.exports = function (chai, _) {
|
|
|
1613
1648
|
}
|
|
1614
1649
|
|
|
1615
1650
|
if (doLength) {
|
|
1616
|
-
var
|
|
1651
|
+
var descriptor = 'length'
|
|
1652
|
+
, itemsCount;
|
|
1653
|
+
if (objType === 'map' || objType === 'set') {
|
|
1654
|
+
descriptor = 'size';
|
|
1655
|
+
itemsCount = obj.size;
|
|
1656
|
+
} else {
|
|
1657
|
+
itemsCount = obj.length;
|
|
1658
|
+
}
|
|
1617
1659
|
this.assert(
|
|
1618
|
-
|
|
1619
|
-
, 'expected #{this} to have a
|
|
1620
|
-
, 'expected #{this} to have a
|
|
1660
|
+
itemsCount >= n
|
|
1661
|
+
, 'expected #{this} to have a ' + descriptor + ' at least #{exp} but got #{act}'
|
|
1662
|
+
, 'expected #{this} to have a ' + descriptor + ' below #{exp}'
|
|
1621
1663
|
, n
|
|
1622
|
-
,
|
|
1664
|
+
, itemsCount
|
|
1623
1665
|
);
|
|
1624
1666
|
} else {
|
|
1625
1667
|
this.assert(
|
|
@@ -1644,8 +1686,8 @@ module.exports = function (chai, _) {
|
|
|
1644
1686
|
* expect(1).to.equal(1); // Recommended
|
|
1645
1687
|
* expect(1).to.be.below(2); // Not recommended
|
|
1646
1688
|
*
|
|
1647
|
-
* Add `.lengthOf` earlier in the chain to assert that the
|
|
1648
|
-
*
|
|
1689
|
+
* Add `.lengthOf` earlier in the chain to assert that the target's `length`
|
|
1690
|
+
* or `size` is less than the given number `n`.
|
|
1649
1691
|
*
|
|
1650
1692
|
* expect('foo').to.have.lengthOf(3); // Recommended
|
|
1651
1693
|
* expect('foo').to.have.lengthOf.below(4); // Not recommended
|
|
@@ -1686,9 +1728,10 @@ module.exports = function (chai, _) {
|
|
|
1686
1728
|
, ssfi = flag(this, 'ssfi')
|
|
1687
1729
|
, objType = _.type(obj).toLowerCase()
|
|
1688
1730
|
, nType = _.type(n).toLowerCase()
|
|
1731
|
+
, errorMessage
|
|
1689
1732
|
, shouldThrow = true;
|
|
1690
1733
|
|
|
1691
|
-
if (doLength) {
|
|
1734
|
+
if (doLength && objType !== 'map' && objType !== 'set') {
|
|
1692
1735
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
|
|
1693
1736
|
}
|
|
1694
1737
|
|
|
@@ -1708,13 +1751,20 @@ module.exports = function (chai, _) {
|
|
|
1708
1751
|
}
|
|
1709
1752
|
|
|
1710
1753
|
if (doLength) {
|
|
1711
|
-
var
|
|
1754
|
+
var descriptor = 'length'
|
|
1755
|
+
, itemsCount;
|
|
1756
|
+
if (objType === 'map' || objType === 'set') {
|
|
1757
|
+
descriptor = 'size';
|
|
1758
|
+
itemsCount = obj.size;
|
|
1759
|
+
} else {
|
|
1760
|
+
itemsCount = obj.length;
|
|
1761
|
+
}
|
|
1712
1762
|
this.assert(
|
|
1713
|
-
|
|
1714
|
-
, 'expected #{this} to have a
|
|
1715
|
-
, 'expected #{this} to not have a
|
|
1763
|
+
itemsCount < n
|
|
1764
|
+
, 'expected #{this} to have a ' + descriptor + ' below #{exp} but got #{act}'
|
|
1765
|
+
, 'expected #{this} to not have a ' + descriptor + ' below #{exp}'
|
|
1716
1766
|
, n
|
|
1717
|
-
,
|
|
1767
|
+
, itemsCount
|
|
1718
1768
|
);
|
|
1719
1769
|
} else {
|
|
1720
1770
|
this.assert(
|
|
@@ -1741,8 +1791,8 @@ module.exports = function (chai, _) {
|
|
|
1741
1791
|
* expect(1).to.be.at.most(2); // Not recommended
|
|
1742
1792
|
* expect(1).to.be.at.most(1); // Not recommended
|
|
1743
1793
|
*
|
|
1744
|
-
* Add `.lengthOf` earlier in the chain to assert that the
|
|
1745
|
-
*
|
|
1794
|
+
* Add `.lengthOf` earlier in the chain to assert that the target's `length`
|
|
1795
|
+
* or `size` is less than or equal to the given number `n`.
|
|
1746
1796
|
*
|
|
1747
1797
|
* expect('foo').to.have.lengthOf(3); // Recommended
|
|
1748
1798
|
* expect('foo').to.have.lengthOf.at.most(4); // Not recommended
|
|
@@ -1781,12 +1831,13 @@ module.exports = function (chai, _) {
|
|
|
1781
1831
|
, ssfi = flag(this, 'ssfi')
|
|
1782
1832
|
, objType = _.type(obj).toLowerCase()
|
|
1783
1833
|
, nType = _.type(n).toLowerCase()
|
|
1834
|
+
, errorMessage
|
|
1784
1835
|
, shouldThrow = true;
|
|
1785
1836
|
|
|
1786
|
-
if (doLength) {
|
|
1837
|
+
if (doLength && objType !== 'map' && objType !== 'set') {
|
|
1787
1838
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
|
|
1788
1839
|
}
|
|
1789
|
-
|
|
1840
|
+
|
|
1790
1841
|
if (!doLength && (objType === 'date' && nType !== 'date')) {
|
|
1791
1842
|
errorMessage = msgPrefix + 'the argument to most must be a date';
|
|
1792
1843
|
} else if (nType !== 'number' && (doLength || objType === 'number')) {
|
|
@@ -1803,13 +1854,20 @@ module.exports = function (chai, _) {
|
|
|
1803
1854
|
}
|
|
1804
1855
|
|
|
1805
1856
|
if (doLength) {
|
|
1806
|
-
var
|
|
1857
|
+
var descriptor = 'length'
|
|
1858
|
+
, itemsCount;
|
|
1859
|
+
if (objType === 'map' || objType === 'set') {
|
|
1860
|
+
descriptor = 'size';
|
|
1861
|
+
itemsCount = obj.size;
|
|
1862
|
+
} else {
|
|
1863
|
+
itemsCount = obj.length;
|
|
1864
|
+
}
|
|
1807
1865
|
this.assert(
|
|
1808
|
-
|
|
1809
|
-
, 'expected #{this} to have a
|
|
1810
|
-
, 'expected #{this} to have a
|
|
1866
|
+
itemsCount <= n
|
|
1867
|
+
, 'expected #{this} to have a ' + descriptor + ' at most #{exp} but got #{act}'
|
|
1868
|
+
, 'expected #{this} to have a ' + descriptor + ' above #{exp}'
|
|
1811
1869
|
, n
|
|
1812
|
-
,
|
|
1870
|
+
, itemsCount
|
|
1813
1871
|
);
|
|
1814
1872
|
} else {
|
|
1815
1873
|
this.assert(
|
|
@@ -1837,9 +1895,9 @@ module.exports = function (chai, _) {
|
|
|
1837
1895
|
* expect(2).to.be.within(2, 3); // Not recommended
|
|
1838
1896
|
* expect(2).to.be.within(1, 2); // Not recommended
|
|
1839
1897
|
*
|
|
1840
|
-
* Add `.lengthOf` earlier in the chain to assert that the
|
|
1841
|
-
*
|
|
1842
|
-
*
|
|
1898
|
+
* Add `.lengthOf` earlier in the chain to assert that the target's `length`
|
|
1899
|
+
* or `size` is greater than or equal to the given number `start`, and less
|
|
1900
|
+
* than or equal to the given number `finish`.
|
|
1843
1901
|
*
|
|
1844
1902
|
* expect('foo').to.have.lengthOf(3); // Recommended
|
|
1845
1903
|
* expect('foo').to.have.lengthOf.within(2, 4); // Not recommended
|
|
@@ -1877,12 +1935,13 @@ module.exports = function (chai, _) {
|
|
|
1877
1935
|
, objType = _.type(obj).toLowerCase()
|
|
1878
1936
|
, startType = _.type(start).toLowerCase()
|
|
1879
1937
|
, finishType = _.type(finish).toLowerCase()
|
|
1938
|
+
, errorMessage
|
|
1880
1939
|
, shouldThrow = true
|
|
1881
1940
|
, range = (startType === 'date' && finishType === 'date')
|
|
1882
1941
|
? start.toUTCString() + '..' + finish.toUTCString()
|
|
1883
1942
|
: start + '..' + finish;
|
|
1884
1943
|
|
|
1885
|
-
if (doLength) {
|
|
1944
|
+
if (doLength && objType !== 'map' && objType !== 'set') {
|
|
1886
1945
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
|
|
1887
1946
|
}
|
|
1888
1947
|
|
|
@@ -1902,11 +1961,18 @@ module.exports = function (chai, _) {
|
|
|
1902
1961
|
}
|
|
1903
1962
|
|
|
1904
1963
|
if (doLength) {
|
|
1905
|
-
var
|
|
1964
|
+
var descriptor = 'length'
|
|
1965
|
+
, itemsCount;
|
|
1966
|
+
if (objType === 'map' || objType === 'set') {
|
|
1967
|
+
descriptor = 'size';
|
|
1968
|
+
itemsCount = obj.size;
|
|
1969
|
+
} else {
|
|
1970
|
+
itemsCount = obj.length;
|
|
1971
|
+
}
|
|
1906
1972
|
this.assert(
|
|
1907
|
-
|
|
1908
|
-
, 'expected #{this} to have a
|
|
1909
|
-
, 'expected #{this} to not have a
|
|
1973
|
+
itemsCount >= start && itemsCount <= finish
|
|
1974
|
+
, 'expected #{this} to have a ' + descriptor + ' within ' + range
|
|
1975
|
+
, 'expected #{this} to not have a ' + descriptor + ' within ' + range
|
|
1910
1976
|
);
|
|
1911
1977
|
} else {
|
|
1912
1978
|
this.assert(
|
|
@@ -1962,28 +2028,25 @@ module.exports = function (chai, _) {
|
|
|
1962
2028
|
var target = flag(this, 'object')
|
|
1963
2029
|
var ssfi = flag(this, 'ssfi');
|
|
1964
2030
|
var flagMsg = flag(this, 'message');
|
|
1965
|
-
var validInstanceOfTarget = constructor === Object(constructor) && (
|
|
1966
|
-
typeof constructor === 'function' ||
|
|
1967
|
-
(typeof Symbol !== 'undefined' &&
|
|
1968
|
-
typeof Symbol.hasInstance !== 'undefined' &&
|
|
1969
|
-
Symbol.hasInstance in constructor)
|
|
1970
|
-
);
|
|
1971
2031
|
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
flagMsg
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
2032
|
+
try {
|
|
2033
|
+
var isInstanceOf = target instanceof constructor;
|
|
2034
|
+
} catch (err) {
|
|
2035
|
+
if (err instanceof TypeError) {
|
|
2036
|
+
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
2037
|
+
throw new AssertionError(
|
|
2038
|
+
flagMsg + 'The instanceof assertion needs a constructor but '
|
|
2039
|
+
+ _.type(constructor) + ' was given.',
|
|
2040
|
+
undefined,
|
|
2041
|
+
ssfi
|
|
2042
|
+
);
|
|
2043
|
+
}
|
|
2044
|
+
throw err;
|
|
1980
2045
|
}
|
|
1981
2046
|
|
|
1982
|
-
var isInstanceOf = target instanceof constructor
|
|
1983
|
-
|
|
1984
2047
|
var name = _.getName(constructor);
|
|
1985
2048
|
if (name === null) {
|
|
1986
|
-
|
|
2049
|
+
name = 'an unnamed constructor';
|
|
1987
2050
|
}
|
|
1988
2051
|
|
|
1989
2052
|
this.assert(
|
|
@@ -2025,7 +2088,8 @@ module.exports = function (chai, _) {
|
|
|
2025
2088
|
*
|
|
2026
2089
|
* expect({a: 1}).to.have.own.property('a');
|
|
2027
2090
|
* expect({a: 1}).to.have.own.property('a', 1);
|
|
2028
|
-
* expect({a: 1}).to.have.property('b')
|
|
2091
|
+
* expect({a: 1}).to.have.property('b');
|
|
2092
|
+
* expect({a: 1}).to.not.have.own.property('b');
|
|
2029
2093
|
*
|
|
2030
2094
|
* `.deep` and `.own` can be combined.
|
|
2031
2095
|
*
|
|
@@ -2052,7 +2116,7 @@ module.exports = function (chai, _) {
|
|
|
2052
2116
|
* Add `.not` earlier in the chain to negate `.property`.
|
|
2053
2117
|
*
|
|
2054
2118
|
* expect({a: 1}).to.not.have.property('b');
|
|
2055
|
-
*
|
|
2119
|
+
*
|
|
2056
2120
|
* However, it's dangerous to negate `.property` when providing `val`. The
|
|
2057
2121
|
* problem is that it creates uncertain expectations by asserting that the
|
|
2058
2122
|
* target either doesn't have a property with the given key `name`, or that it
|
|
@@ -2090,7 +2154,7 @@ module.exports = function (chai, _) {
|
|
|
2090
2154
|
*
|
|
2091
2155
|
* // Not recommended
|
|
2092
2156
|
* expect({a: 1}).to.have.property('b', undefined, 'nooo why fail??');
|
|
2093
|
-
*
|
|
2157
|
+
*
|
|
2094
2158
|
* The above assertion isn't the same thing as not providing `val`. Instead,
|
|
2095
2159
|
* it's asserting that the target object has a `b` property that's equal to
|
|
2096
2160
|
* `undefined`.
|
|
@@ -2114,10 +2178,30 @@ module.exports = function (chai, _) {
|
|
|
2114
2178
|
, isOwn = flag(this, 'own')
|
|
2115
2179
|
, flagMsg = flag(this, 'message')
|
|
2116
2180
|
, obj = flag(this, 'object')
|
|
2117
|
-
, ssfi = flag(this, 'ssfi')
|
|
2181
|
+
, ssfi = flag(this, 'ssfi')
|
|
2182
|
+
, nameType = typeof name;
|
|
2183
|
+
|
|
2184
|
+
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
2185
|
+
|
|
2186
|
+
if (isNested) {
|
|
2187
|
+
if (nameType !== 'string') {
|
|
2188
|
+
throw new AssertionError(
|
|
2189
|
+
flagMsg + 'the argument to property must be a string when using nested syntax',
|
|
2190
|
+
undefined,
|
|
2191
|
+
ssfi
|
|
2192
|
+
);
|
|
2193
|
+
}
|
|
2194
|
+
} else {
|
|
2195
|
+
if (nameType !== 'string' && nameType !== 'number' && nameType !== 'symbol') {
|
|
2196
|
+
throw new AssertionError(
|
|
2197
|
+
flagMsg + 'the argument to property must be a string, number, or symbol',
|
|
2198
|
+
undefined,
|
|
2199
|
+
ssfi
|
|
2200
|
+
);
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2118
2203
|
|
|
2119
2204
|
if (isNested && isOwn) {
|
|
2120
|
-
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
2121
2205
|
throw new AssertionError(
|
|
2122
2206
|
flagMsg + 'The "nested" and "own" flags cannot be combined.',
|
|
2123
2207
|
undefined,
|
|
@@ -2126,7 +2210,6 @@ module.exports = function (chai, _) {
|
|
|
2126
2210
|
}
|
|
2127
2211
|
|
|
2128
2212
|
if (obj === null || obj === undefined) {
|
|
2129
|
-
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
2130
2213
|
throw new AssertionError(
|
|
2131
2214
|
flagMsg + 'Target cannot be null or undefined.',
|
|
2132
2215
|
undefined,
|
|
@@ -2209,12 +2292,12 @@ module.exports = function (chai, _) {
|
|
|
2209
2292
|
* Add `.not` earlier in the chain to negate `.ownPropertyDescriptor`.
|
|
2210
2293
|
*
|
|
2211
2294
|
* expect({a: 1}).to.not.have.ownPropertyDescriptor('b');
|
|
2212
|
-
*
|
|
2295
|
+
*
|
|
2213
2296
|
* However, it's dangerous to negate `.ownPropertyDescriptor` when providing
|
|
2214
2297
|
* a `descriptor`. The problem is that it creates uncertain expectations by
|
|
2215
2298
|
* asserting that the target either doesn't have a property descriptor with
|
|
2216
2299
|
* the given key `name`, or that it does have a property descriptor with the
|
|
2217
|
-
* given key `name` but
|
|
2300
|
+
* given key `name` but it’s not deeply equal to the given `descriptor`. It's
|
|
2218
2301
|
* often best to identify the exact output that's expected, and then write an
|
|
2219
2302
|
* assertion that only accepts that exact output.
|
|
2220
2303
|
*
|
|
@@ -2280,7 +2363,7 @@ module.exports = function (chai, _) {
|
|
|
2280
2363
|
* writable: true,
|
|
2281
2364
|
* value: 2,
|
|
2282
2365
|
* });
|
|
2283
|
-
*
|
|
2366
|
+
*
|
|
2284
2367
|
* // Recommended
|
|
2285
2368
|
* expect({a: 1}, 'nooo why fail??').to.have.ownPropertyDescriptor('b');
|
|
2286
2369
|
*
|
|
@@ -2337,11 +2420,13 @@ module.exports = function (chai, _) {
|
|
|
2337
2420
|
/**
|
|
2338
2421
|
* ### .lengthOf(n[, msg])
|
|
2339
2422
|
*
|
|
2340
|
-
* Asserts that the target's `length`
|
|
2423
|
+
* Asserts that the target's `length` or `size` is equal to the given number
|
|
2341
2424
|
* `n`.
|
|
2342
2425
|
*
|
|
2343
2426
|
* expect([1, 2, 3]).to.have.lengthOf(3);
|
|
2344
2427
|
* expect('foo').to.have.lengthOf(3);
|
|
2428
|
+
* expect(new Set([1, 2, 3])).to.have.lengthOf(3);
|
|
2429
|
+
* expect(new Map([['a', 1], ['b', 2], ['c', 3]])).to.have.lengthOf(3);
|
|
2345
2430
|
*
|
|
2346
2431
|
* Add `.not` earlier in the chain to negate `.lengthOf`. However, it's often
|
|
2347
2432
|
* best to assert that the target's `length` property is equal to its expected
|
|
@@ -2397,17 +2482,29 @@ module.exports = function (chai, _) {
|
|
|
2397
2482
|
function assertLength (n, msg) {
|
|
2398
2483
|
if (msg) flag(this, 'message', msg);
|
|
2399
2484
|
var obj = flag(this, 'object')
|
|
2485
|
+
, objType = _.type(obj).toLowerCase()
|
|
2400
2486
|
, flagMsg = flag(this, 'message')
|
|
2401
|
-
, ssfi = flag(this, 'ssfi')
|
|
2402
|
-
|
|
2403
|
-
|
|
2487
|
+
, ssfi = flag(this, 'ssfi')
|
|
2488
|
+
, descriptor = 'length'
|
|
2489
|
+
, itemsCount;
|
|
2490
|
+
|
|
2491
|
+
switch (objType) {
|
|
2492
|
+
case 'map':
|
|
2493
|
+
case 'set':
|
|
2494
|
+
descriptor = 'size';
|
|
2495
|
+
itemsCount = obj.size;
|
|
2496
|
+
break;
|
|
2497
|
+
default:
|
|
2498
|
+
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
|
|
2499
|
+
itemsCount = obj.length;
|
|
2500
|
+
}
|
|
2404
2501
|
|
|
2405
2502
|
this.assert(
|
|
2406
|
-
|
|
2407
|
-
, 'expected #{this} to have a
|
|
2408
|
-
, 'expected #{this} to not have a
|
|
2503
|
+
itemsCount == n
|
|
2504
|
+
, 'expected #{this} to have a ' + descriptor + ' of #{exp} but got #{act}'
|
|
2505
|
+
, 'expected #{this} to not have a ' + descriptor + ' of #{act}'
|
|
2409
2506
|
, n
|
|
2410
|
-
,
|
|
2507
|
+
, itemsCount
|
|
2411
2508
|
);
|
|
2412
2509
|
}
|
|
2413
2510
|
|
|
@@ -2469,8 +2566,8 @@ module.exports = function (chai, _) {
|
|
|
2469
2566
|
* message to show when the assertion fails. The message can also be given as
|
|
2470
2567
|
* the second argument to `expect`.
|
|
2471
2568
|
*
|
|
2472
|
-
* expect('foobar').to.have.string(
|
|
2473
|
-
* expect('foobar', 'nooo why fail??').to.have.string(
|
|
2569
|
+
* expect('foobar').to.have.string('taco', 'nooo why fail??');
|
|
2570
|
+
* expect('foobar', 'nooo why fail??').to.have.string('taco');
|
|
2474
2571
|
*
|
|
2475
2572
|
* @name string
|
|
2476
2573
|
* @param {String} str
|
|
@@ -2497,7 +2594,7 @@ module.exports = function (chai, _) {
|
|
|
2497
2594
|
* ### .keys(key1[, key2[, ...]])
|
|
2498
2595
|
*
|
|
2499
2596
|
* Asserts that the target object, array, map, or set has the given keys. Only
|
|
2500
|
-
* the target's own inherited properties are included in the search.
|
|
2597
|
+
* the target's own inherited properties are included in the search.
|
|
2501
2598
|
*
|
|
2502
2599
|
* When the target is an object or array, keys can be provided as one or more
|
|
2503
2600
|
* string arguments, a single array argument, or a single object argument. In
|
|
@@ -2605,6 +2702,7 @@ module.exports = function (chai, _) {
|
|
|
2605
2702
|
, isDeep = flag(this, 'deep')
|
|
2606
2703
|
, str
|
|
2607
2704
|
, deepStr = ''
|
|
2705
|
+
, actual
|
|
2608
2706
|
, ok = true
|
|
2609
2707
|
, flagMsg = flag(this, 'message');
|
|
2610
2708
|
|
|
@@ -2621,7 +2719,6 @@ module.exports = function (chai, _) {
|
|
|
2621
2719
|
if (keysType !== 'Array') {
|
|
2622
2720
|
keys = Array.prototype.slice.call(arguments);
|
|
2623
2721
|
}
|
|
2624
|
-
|
|
2625
2722
|
} else {
|
|
2626
2723
|
actual = _.getOwnEnumerableProperties(obj);
|
|
2627
2724
|
|
|
@@ -2654,8 +2751,7 @@ module.exports = function (chai, _) {
|
|
|
2654
2751
|
var len = keys.length
|
|
2655
2752
|
, any = flag(this, 'any')
|
|
2656
2753
|
, all = flag(this, 'all')
|
|
2657
|
-
, expected = keys
|
|
2658
|
-
, actual;
|
|
2754
|
+
, expected = keys;
|
|
2659
2755
|
|
|
2660
2756
|
if (!any && !all) {
|
|
2661
2757
|
all = true;
|
|
@@ -2732,7 +2828,7 @@ module.exports = function (chai, _) {
|
|
|
2732
2828
|
*
|
|
2733
2829
|
* When no arguments are provided, `.throw` invokes the target function and
|
|
2734
2830
|
* asserts that an error is thrown.
|
|
2735
|
-
*
|
|
2831
|
+
*
|
|
2736
2832
|
* var badFn = function () { throw new TypeError('Illegal salmon!'); };
|
|
2737
2833
|
*
|
|
2738
2834
|
* expect(badFn).to.throw();
|
|
@@ -2784,11 +2880,11 @@ module.exports = function (chai, _) {
|
|
|
2784
2880
|
* expect(badFn).to.throw(err, /salmon/);
|
|
2785
2881
|
*
|
|
2786
2882
|
* Add `.not` earlier in the chain to negate `.throw`.
|
|
2787
|
-
*
|
|
2883
|
+
*
|
|
2788
2884
|
* var goodFn = function () {};
|
|
2789
2885
|
*
|
|
2790
2886
|
* expect(goodFn).to.not.throw();
|
|
2791
|
-
*
|
|
2887
|
+
*
|
|
2792
2888
|
* However, it's dangerous to negate `.throw` when providing any arguments.
|
|
2793
2889
|
* The problem is that it creates uncertain expectations by asserting that the
|
|
2794
2890
|
* target either doesn't throw an error, or that it throws an error but of a
|
|
@@ -3136,7 +3232,7 @@ module.exports = function (chai, _) {
|
|
|
3136
3232
|
* first argument, and asserts that the value returned is truthy.
|
|
3137
3233
|
*
|
|
3138
3234
|
* expect(1).to.satisfy(function(num) {
|
|
3139
|
-
* return num > 0;
|
|
3235
|
+
* return num > 0;
|
|
3140
3236
|
* });
|
|
3141
3237
|
*
|
|
3142
3238
|
* Add `.not` earlier in the chain to negate `.satisfy`.
|
|
@@ -3230,8 +3326,9 @@ module.exports = function (chai, _) {
|
|
|
3230
3326
|
new Assertion(obj, flagMsg, ssfi, true).is.a('number');
|
|
3231
3327
|
if (typeof expected !== 'number' || typeof delta !== 'number') {
|
|
3232
3328
|
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
3329
|
+
var deltaMessage = delta === undefined ? ", and a delta is required" : "";
|
|
3233
3330
|
throw new AssertionError(
|
|
3234
|
-
flagMsg + 'the arguments to closeTo or approximately must be numbers',
|
|
3331
|
+
flagMsg + 'the arguments to closeTo or approximately must be numbers' + deltaMessage,
|
|
3235
3332
|
undefined,
|
|
3236
3333
|
ssfi
|
|
3237
3334
|
);
|
|
@@ -3357,7 +3454,7 @@ module.exports = function (chai, _) {
|
|
|
3357
3454
|
var contains = flag(this, 'contains');
|
|
3358
3455
|
var ordered = flag(this, 'ordered');
|
|
3359
3456
|
|
|
3360
|
-
var subject, failMsg, failNegateMsg
|
|
3457
|
+
var subject, failMsg, failNegateMsg;
|
|
3361
3458
|
|
|
3362
3459
|
if (contains) {
|
|
3363
3460
|
subject = ordered ? 'an ordered superset' : 'a superset';
|
|
@@ -3397,6 +3494,14 @@ module.exports = function (chai, _) {
|
|
|
3397
3494
|
* expect(1).to.equal(1); // Recommended
|
|
3398
3495
|
* expect(1).to.not.be.oneOf([2, 3, 4]); // Not recommended
|
|
3399
3496
|
*
|
|
3497
|
+
* It can also be chained with `.contain` or `.include`, which will work with
|
|
3498
|
+
* both arrays and strings:
|
|
3499
|
+
*
|
|
3500
|
+
* expect('Today is sunny').to.contain.oneOf(['sunny', 'cloudy'])
|
|
3501
|
+
* expect('Today is rainy').to.not.contain.oneOf(['sunny', 'cloudy'])
|
|
3502
|
+
* expect([1,2,3]).to.contain.oneOf([3,4,5])
|
|
3503
|
+
* expect([1,2,3]).to.not.contain.oneOf([4,5,6])
|
|
3504
|
+
*
|
|
3400
3505
|
* `.oneOf` accepts an optional `msg` argument which is a custom error message
|
|
3401
3506
|
* to show when the assertion fails. The message can also be given as the
|
|
3402
3507
|
* second argument to `expect`.
|
|
@@ -3415,21 +3520,31 @@ module.exports = function (chai, _) {
|
|
|
3415
3520
|
if (msg) flag(this, 'message', msg);
|
|
3416
3521
|
var expected = flag(this, 'object')
|
|
3417
3522
|
, flagMsg = flag(this, 'message')
|
|
3418
|
-
, ssfi = flag(this, 'ssfi')
|
|
3523
|
+
, ssfi = flag(this, 'ssfi')
|
|
3524
|
+
, contains = flag(this, 'contains');
|
|
3419
3525
|
new Assertion(list, flagMsg, ssfi, true).to.be.an('array');
|
|
3420
3526
|
|
|
3421
|
-
|
|
3527
|
+
if (contains) {
|
|
3528
|
+
this.assert(
|
|
3529
|
+
list.some(function(possibility) { return expected.indexOf(possibility) > -1 })
|
|
3530
|
+
, 'expected #{this} to contain one of #{exp}'
|
|
3531
|
+
, 'expected #{this} to not contain one of #{exp}'
|
|
3532
|
+
, list
|
|
3533
|
+
, expected
|
|
3534
|
+
);
|
|
3535
|
+
} else {
|
|
3536
|
+
this.assert(
|
|
3422
3537
|
list.indexOf(expected) > -1
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3538
|
+
, 'expected #{this} to be one of #{exp}'
|
|
3539
|
+
, 'expected #{this} to not be one of #{exp}'
|
|
3540
|
+
, list
|
|
3541
|
+
, expected
|
|
3542
|
+
);
|
|
3543
|
+
}
|
|
3428
3544
|
}
|
|
3429
3545
|
|
|
3430
3546
|
Assertion.addMethod('oneOf', oneOf);
|
|
3431
3547
|
|
|
3432
|
-
|
|
3433
3548
|
/**
|
|
3434
3549
|
* ### .change(subject[, prop[, msg]])
|
|
3435
3550
|
*
|
|
@@ -3605,7 +3720,7 @@ module.exports = function (chai, _) {
|
|
|
3605
3720
|
*
|
|
3606
3721
|
* expect(subtractTwo).to.decrease(myObj, 'val').by(2); // Recommended
|
|
3607
3722
|
* expect(subtractTwo).to.not.increase(myObj, 'val'); // Not recommended
|
|
3608
|
-
*
|
|
3723
|
+
*
|
|
3609
3724
|
* When the subject is expected to stay the same, it's often best to assert
|
|
3610
3725
|
* exactly that.
|
|
3611
3726
|
*
|
|
@@ -3702,7 +3817,7 @@ module.exports = function (chai, _) {
|
|
|
3702
3817
|
*
|
|
3703
3818
|
* When two arguments are provided, `.decrease` asserts that the value of the
|
|
3704
3819
|
* given object `subject`'s `prop` property is lesser after invoking the
|
|
3705
|
-
* target function compared to beforehand.
|
|
3820
|
+
* target function compared to beforehand.
|
|
3706
3821
|
*
|
|
3707
3822
|
* var myObj = {val: 1}
|
|
3708
3823
|
* , subtractTwo = function () { myObj.val -= 2; };
|
|
@@ -3724,7 +3839,7 @@ module.exports = function (chai, _) {
|
|
|
3724
3839
|
*
|
|
3725
3840
|
* expect(addTwo).to.increase(myObj, 'val').by(2); // Recommended
|
|
3726
3841
|
* expect(addTwo).to.not.decrease(myObj, 'val'); // Not recommended
|
|
3727
|
-
*
|
|
3842
|
+
*
|
|
3728
3843
|
* When the subject is expected to stay the same, it's often best to assert
|
|
3729
3844
|
* exactly that.
|
|
3730
3845
|
*
|
|
@@ -4077,7 +4192,7 @@ module.exports = function (chai, _) {
|
|
|
4077
4192
|
var obj = flag(this, 'object');
|
|
4078
4193
|
|
|
4079
4194
|
this.assert(
|
|
4080
|
-
typeof obj ===
|
|
4195
|
+
typeof obj === 'number' && isFinite(obj)
|
|
4081
4196
|
, 'expected #{this} to be a finite number'
|
|
4082
4197
|
, 'expected #{this} to not be a finite number'
|
|
4083
4198
|
);
|
|
@@ -4091,9 +4206,7 @@ module.exports = function (chai, _) {
|
|
|
4091
4206
|
* MIT Licensed
|
|
4092
4207
|
*/
|
|
4093
4208
|
|
|
4094
|
-
|
|
4095
4209
|
module.exports = function (chai, util) {
|
|
4096
|
-
|
|
4097
4210
|
/*!
|
|
4098
4211
|
* Chai dependencies.
|
|
4099
4212
|
*/
|
|
@@ -4130,10 +4243,18 @@ module.exports = function (chai, util) {
|
|
|
4130
4243
|
};
|
|
4131
4244
|
|
|
4132
4245
|
/**
|
|
4246
|
+
* ### .fail([message])
|
|
4133
4247
|
* ### .fail(actual, expected, [message], [operator])
|
|
4134
4248
|
*
|
|
4135
4249
|
* Throw a failure. Node.js `assert` module-compatible.
|
|
4136
4250
|
*
|
|
4251
|
+
* assert.fail();
|
|
4252
|
+
* assert.fail("custom error message");
|
|
4253
|
+
* assert.fail(1, 2);
|
|
4254
|
+
* assert.fail(1, 2, "custom error message");
|
|
4255
|
+
* assert.fail(1, 2, "custom error message", ">");
|
|
4256
|
+
* assert.fail(1, 2, undefined, ">");
|
|
4257
|
+
*
|
|
4137
4258
|
* @name fail
|
|
4138
4259
|
* @param {Mixed} actual
|
|
4139
4260
|
* @param {Mixed} expected
|
|
@@ -4144,6 +4265,13 @@ module.exports = function (chai, util) {
|
|
|
4144
4265
|
*/
|
|
4145
4266
|
|
|
4146
4267
|
assert.fail = function (actual, expected, message, operator) {
|
|
4268
|
+
if (arguments.length < 2) {
|
|
4269
|
+
// Comply with Node's fail([message]) interface
|
|
4270
|
+
|
|
4271
|
+
message = actual;
|
|
4272
|
+
actual = undefined;
|
|
4273
|
+
}
|
|
4274
|
+
|
|
4147
4275
|
message = message || 'assert.fail()';
|
|
4148
4276
|
throw new chai.AssertionError(message, {
|
|
4149
4277
|
actual: actual
|
|
@@ -4993,7 +5121,7 @@ module.exports = function (chai, util) {
|
|
|
4993
5121
|
* an array, the array is searched for an element that's strictly equal to the
|
|
4994
5122
|
* given value. When asserting a subset of properties in an object, the object
|
|
4995
5123
|
* is searched for the given property keys, checking that each one is present
|
|
4996
|
-
* and
|
|
5124
|
+
* and strictly equal to the given property value. For instance:
|
|
4997
5125
|
*
|
|
4998
5126
|
* var obj1 = {a: 1}
|
|
4999
5127
|
* , obj2 = {b: 2};
|
|
@@ -5020,8 +5148,8 @@ module.exports = function (chai, util) {
|
|
|
5020
5148
|
* the absence of a value in an array, a substring in a string, or a subset of
|
|
5021
5149
|
* properties in an object.
|
|
5022
5150
|
*
|
|
5023
|
-
* assert.notInclude([1,2,3], 4,
|
|
5024
|
-
* assert.notInclude('foobar', 'baz',
|
|
5151
|
+
* assert.notInclude([1,2,3], 4, "array doesn't contain value");
|
|
5152
|
+
* assert.notInclude('foobar', 'baz', "string doesn't contain substring");
|
|
5025
5153
|
* assert.notInclude({ foo: 'bar', hello: 'universe' }, { foo: 'baz' }, 'object doesn't contain property');
|
|
5026
5154
|
*
|
|
5027
5155
|
* Strict equality (===) is used. When asserting the absence of a value in an
|
|
@@ -5101,24 +5229,24 @@ module.exports = function (chai, util) {
|
|
|
5101
5229
|
|
|
5102
5230
|
/**
|
|
5103
5231
|
* ### .nestedInclude(haystack, needle, [message])
|
|
5104
|
-
*
|
|
5105
|
-
* Asserts that 'haystack' includes 'needle'.
|
|
5106
|
-
* Can be used to assert the inclusion of a subset of properties in an
|
|
5232
|
+
*
|
|
5233
|
+
* Asserts that 'haystack' includes 'needle'.
|
|
5234
|
+
* Can be used to assert the inclusion of a subset of properties in an
|
|
5107
5235
|
* object.
|
|
5108
|
-
* Enables the use of dot- and bracket-notation for referencing nested
|
|
5236
|
+
* Enables the use of dot- and bracket-notation for referencing nested
|
|
5109
5237
|
* properties.
|
|
5110
5238
|
* '[]' and '.' in property names can be escaped using double backslashes.
|
|
5111
|
-
*
|
|
5239
|
+
*
|
|
5112
5240
|
* assert.nestedInclude({'.a': {'b': 'x'}}, {'\\.a.[b]': 'x'});
|
|
5113
5241
|
* assert.nestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'x'});
|
|
5114
|
-
*
|
|
5242
|
+
*
|
|
5115
5243
|
* @name nestedInclude
|
|
5116
5244
|
* @param {Object} haystack
|
|
5117
5245
|
* @param {Object} needle
|
|
5118
5246
|
* @param {String} message
|
|
5119
5247
|
* @namespace Assert
|
|
5120
|
-
* @api public
|
|
5121
|
-
*/
|
|
5248
|
+
* @api public
|
|
5249
|
+
*/
|
|
5122
5250
|
|
|
5123
5251
|
assert.nestedInclude = function (exp, inc, msg) {
|
|
5124
5252
|
new Assertion(exp, msg, assert.nestedInclude, true).nested.include(inc);
|
|
@@ -5126,24 +5254,24 @@ module.exports = function (chai, util) {
|
|
|
5126
5254
|
|
|
5127
5255
|
/**
|
|
5128
5256
|
* ### .notNestedInclude(haystack, needle, [message])
|
|
5129
|
-
*
|
|
5130
|
-
* Asserts that 'haystack' does not include 'needle'.
|
|
5131
|
-
* Can be used to assert the absence of a subset of properties in an
|
|
5257
|
+
*
|
|
5258
|
+
* Asserts that 'haystack' does not include 'needle'.
|
|
5259
|
+
* Can be used to assert the absence of a subset of properties in an
|
|
5132
5260
|
* object.
|
|
5133
|
-
* Enables the use of dot- and bracket-notation for referencing nested
|
|
5134
|
-
* properties.
|
|
5261
|
+
* Enables the use of dot- and bracket-notation for referencing nested
|
|
5262
|
+
* properties.
|
|
5135
5263
|
* '[]' and '.' in property names can be escaped using double backslashes.
|
|
5136
|
-
*
|
|
5264
|
+
*
|
|
5137
5265
|
* assert.notNestedInclude({'.a': {'b': 'x'}}, {'\\.a.b': 'y'});
|
|
5138
5266
|
* assert.notNestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'y'});
|
|
5139
|
-
*
|
|
5267
|
+
*
|
|
5140
5268
|
* @name notNestedInclude
|
|
5141
5269
|
* @param {Object} haystack
|
|
5142
5270
|
* @param {Object} needle
|
|
5143
5271
|
* @param {String} message
|
|
5144
5272
|
* @namespace Assert
|
|
5145
|
-
* @api public
|
|
5146
|
-
*/
|
|
5273
|
+
* @api public
|
|
5274
|
+
*/
|
|
5147
5275
|
|
|
5148
5276
|
assert.notNestedInclude = function (exp, inc, msg) {
|
|
5149
5277
|
new Assertion(exp, msg, assert.notNestedInclude, true)
|
|
@@ -5152,23 +5280,23 @@ module.exports = function (chai, util) {
|
|
|
5152
5280
|
|
|
5153
5281
|
/**
|
|
5154
5282
|
* ### .deepNestedInclude(haystack, needle, [message])
|
|
5155
|
-
*
|
|
5283
|
+
*
|
|
5156
5284
|
* Asserts that 'haystack' includes 'needle'.
|
|
5157
|
-
* Can be used to assert the inclusion of a subset of properties in an
|
|
5285
|
+
* Can be used to assert the inclusion of a subset of properties in an
|
|
5158
5286
|
* object while checking for deep equality.
|
|
5159
|
-
* Enables the use of dot- and bracket-notation for referencing nested
|
|
5287
|
+
* Enables the use of dot- and bracket-notation for referencing nested
|
|
5160
5288
|
* properties.
|
|
5161
5289
|
* '[]' and '.' in property names can be escaped using double backslashes.
|
|
5162
|
-
*
|
|
5290
|
+
*
|
|
5163
5291
|
* assert.deepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {x: 1}});
|
|
5164
5292
|
* assert.deepNestedInclude({'.a': {'[b]': {x: 1}}}, {'\\.a.\\[b\\]': {x: 1}});
|
|
5165
|
-
*
|
|
5293
|
+
*
|
|
5166
5294
|
* @name deepNestedInclude
|
|
5167
5295
|
* @param {Object} haystack
|
|
5168
5296
|
* @param {Object} needle
|
|
5169
5297
|
* @param {String} message
|
|
5170
5298
|
* @namespace Assert
|
|
5171
|
-
* @api public
|
|
5299
|
+
* @api public
|
|
5172
5300
|
*/
|
|
5173
5301
|
|
|
5174
5302
|
assert.deepNestedInclude = function(exp, inc, msg) {
|
|
@@ -5178,23 +5306,23 @@ module.exports = function (chai, util) {
|
|
|
5178
5306
|
|
|
5179
5307
|
/**
|
|
5180
5308
|
* ### .notDeepNestedInclude(haystack, needle, [message])
|
|
5181
|
-
*
|
|
5309
|
+
*
|
|
5182
5310
|
* Asserts that 'haystack' does not include 'needle'.
|
|
5183
|
-
* Can be used to assert the absence of a subset of properties in an
|
|
5311
|
+
* Can be used to assert the absence of a subset of properties in an
|
|
5184
5312
|
* object while checking for deep equality.
|
|
5185
|
-
* Enables the use of dot- and bracket-notation for referencing nested
|
|
5313
|
+
* Enables the use of dot- and bracket-notation for referencing nested
|
|
5186
5314
|
* properties.
|
|
5187
5315
|
* '[]' and '.' in property names can be escaped using double backslashes.
|
|
5188
|
-
*
|
|
5316
|
+
*
|
|
5189
5317
|
* assert.notDeepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {y: 1}})
|
|
5190
5318
|
* assert.notDeepNestedInclude({'.a': {'[b]': {x: 1}}}, {'\\.a.\\[b\\]': {y: 2}});
|
|
5191
|
-
*
|
|
5319
|
+
*
|
|
5192
5320
|
* @name notDeepNestedInclude
|
|
5193
5321
|
* @param {Object} haystack
|
|
5194
5322
|
* @param {Object} needle
|
|
5195
5323
|
* @param {String} message
|
|
5196
5324
|
* @namespace Assert
|
|
5197
|
-
* @api public
|
|
5325
|
+
* @api public
|
|
5198
5326
|
*/
|
|
5199
5327
|
|
|
5200
5328
|
assert.notDeepNestedInclude = function(exp, inc, msg) {
|
|
@@ -5204,13 +5332,13 @@ module.exports = function (chai, util) {
|
|
|
5204
5332
|
|
|
5205
5333
|
/**
|
|
5206
5334
|
* ### .ownInclude(haystack, needle, [message])
|
|
5207
|
-
*
|
|
5335
|
+
*
|
|
5208
5336
|
* Asserts that 'haystack' includes 'needle'.
|
|
5209
|
-
* Can be used to assert the inclusion of a subset of properties in an
|
|
5337
|
+
* Can be used to assert the inclusion of a subset of properties in an
|
|
5210
5338
|
* object while ignoring inherited properties.
|
|
5211
|
-
*
|
|
5339
|
+
*
|
|
5212
5340
|
* assert.ownInclude({ a: 1 }, { a: 1 });
|
|
5213
|
-
*
|
|
5341
|
+
*
|
|
5214
5342
|
* @name ownInclude
|
|
5215
5343
|
* @param {Object} haystack
|
|
5216
5344
|
* @param {Object} needle
|
|
@@ -5225,15 +5353,15 @@ module.exports = function (chai, util) {
|
|
|
5225
5353
|
|
|
5226
5354
|
/**
|
|
5227
5355
|
* ### .notOwnInclude(haystack, needle, [message])
|
|
5228
|
-
*
|
|
5356
|
+
*
|
|
5229
5357
|
* Asserts that 'haystack' includes 'needle'.
|
|
5230
|
-
* Can be used to assert the absence of a subset of properties in an
|
|
5358
|
+
* Can be used to assert the absence of a subset of properties in an
|
|
5231
5359
|
* object while ignoring inherited properties.
|
|
5232
|
-
*
|
|
5360
|
+
*
|
|
5233
5361
|
* Object.prototype.b = 2;
|
|
5234
|
-
*
|
|
5362
|
+
*
|
|
5235
5363
|
* assert.notOwnInclude({ a: 1 }, { b: 2 });
|
|
5236
|
-
*
|
|
5364
|
+
*
|
|
5237
5365
|
* @name notOwnInclude
|
|
5238
5366
|
* @param {Object} haystack
|
|
5239
5367
|
* @param {Object} needle
|
|
@@ -5248,13 +5376,13 @@ module.exports = function (chai, util) {
|
|
|
5248
5376
|
|
|
5249
5377
|
/**
|
|
5250
5378
|
* ### .deepOwnInclude(haystack, needle, [message])
|
|
5251
|
-
*
|
|
5379
|
+
*
|
|
5252
5380
|
* Asserts that 'haystack' includes 'needle'.
|
|
5253
|
-
* Can be used to assert the inclusion of a subset of properties in an
|
|
5381
|
+
* Can be used to assert the inclusion of a subset of properties in an
|
|
5254
5382
|
* object while ignoring inherited properties and checking for deep equality.
|
|
5255
|
-
*
|
|
5383
|
+
*
|
|
5256
5384
|
* assert.deepOwnInclude({a: {b: 2}}, {a: {b: 2}});
|
|
5257
|
-
*
|
|
5385
|
+
*
|
|
5258
5386
|
* @name deepOwnInclude
|
|
5259
5387
|
* @param {Object} haystack
|
|
5260
5388
|
* @param {Object} needle
|
|
@@ -5270,13 +5398,13 @@ module.exports = function (chai, util) {
|
|
|
5270
5398
|
|
|
5271
5399
|
/**
|
|
5272
5400
|
* ### .notDeepOwnInclude(haystack, needle, [message])
|
|
5273
|
-
*
|
|
5401
|
+
*
|
|
5274
5402
|
* Asserts that 'haystack' includes 'needle'.
|
|
5275
|
-
* Can be used to assert the absence of a subset of properties in an
|
|
5403
|
+
* Can be used to assert the absence of a subset of properties in an
|
|
5276
5404
|
* object while ignoring inherited properties and checking for deep equality.
|
|
5277
|
-
*
|
|
5405
|
+
*
|
|
5278
5406
|
* assert.notDeepOwnInclude({a: {b: 2}}, {a: {c: 3}});
|
|
5279
|
-
*
|
|
5407
|
+
*
|
|
5280
5408
|
* @name notDeepOwnInclude
|
|
5281
5409
|
* @param {Object} haystack
|
|
5282
5410
|
* @param {Object} needle
|
|
@@ -5738,10 +5866,12 @@ module.exports = function (chai, util) {
|
|
|
5738
5866
|
/**
|
|
5739
5867
|
* ### .lengthOf(object, length, [message])
|
|
5740
5868
|
*
|
|
5741
|
-
* Asserts that `object` has a `length`
|
|
5869
|
+
* Asserts that `object` has a `length` or `size` with the expected value.
|
|
5742
5870
|
*
|
|
5743
5871
|
* assert.lengthOf([1,2,3], 3, 'array has length of 3');
|
|
5744
5872
|
* assert.lengthOf('foobar', 6, 'string has length of 6');
|
|
5873
|
+
* assert.lengthOf(new Set([1,2,3]), 3, 'set has size of 3');
|
|
5874
|
+
* assert.lengthOf(new Map([['a',1],['b',2],['c',3]]), 3, 'map has size of 3');
|
|
5745
5875
|
*
|
|
5746
5876
|
* @name lengthOf
|
|
5747
5877
|
* @param {Mixed} object
|
|
@@ -5762,10 +5892,10 @@ module.exports = function (chai, util) {
|
|
|
5762
5892
|
* You can also provide a single object instead of a `keys` array and its keys
|
|
5763
5893
|
* will be used as the expected set of keys.
|
|
5764
5894
|
*
|
|
5765
|
-
* assert.
|
|
5766
|
-
* assert.
|
|
5767
|
-
* assert.
|
|
5768
|
-
* assert.
|
|
5895
|
+
* assert.hasAnyKeys({foo: 1, bar: 2, baz: 3}, ['foo', 'iDontExist', 'baz']);
|
|
5896
|
+
* assert.hasAnyKeys({foo: 1, bar: 2, baz: 3}, {foo: 30, iDontExist: 99, baz: 1337});
|
|
5897
|
+
* assert.hasAnyKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}, 'key']);
|
|
5898
|
+
* assert.hasAnyKeys(new Set([{foo: 'bar'}, 'anotherKey']), [{foo: 'bar'}, 'anotherKey']);
|
|
5769
5899
|
*
|
|
5770
5900
|
* @name hasAnyKeys
|
|
5771
5901
|
* @param {Mixed} object
|
|
@@ -5898,7 +6028,7 @@ module.exports = function (chai, util) {
|
|
|
5898
6028
|
* assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {three: 'three'}]);
|
|
5899
6029
|
* assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]);
|
|
5900
6030
|
*
|
|
5901
|
-
* @name
|
|
6031
|
+
* @name hasAnyDeepKeys
|
|
5902
6032
|
* @param {Mixed} object
|
|
5903
6033
|
* @param {Array|Object} keys
|
|
5904
6034
|
* @param {String} message
|
|
@@ -6029,8 +6159,8 @@ module.exports = function (chai, util) {
|
|
|
6029
6159
|
* If `errMsgMatcher` is provided, it also asserts that the error thrown will have a
|
|
6030
6160
|
* message matching `errMsgMatcher`.
|
|
6031
6161
|
*
|
|
6032
|
-
* assert.throws(fn, '
|
|
6033
|
-
* assert.throws(fn, /
|
|
6162
|
+
* assert.throws(fn, 'Error thrown must have this msg');
|
|
6163
|
+
* assert.throws(fn, /Error thrown must have a msg that matches this/);
|
|
6034
6164
|
* assert.throws(fn, ReferenceError);
|
|
6035
6165
|
* assert.throws(fn, errorInstance);
|
|
6036
6166
|
* assert.throws(fn, ReferenceError, 'Error thrown must be a ReferenceError and have this msg');
|
|
@@ -7197,10 +7327,18 @@ module.exports = function (chai, util) {
|
|
|
7197
7327
|
};
|
|
7198
7328
|
|
|
7199
7329
|
/**
|
|
7330
|
+
* ### .fail([message])
|
|
7200
7331
|
* ### .fail(actual, expected, [message], [operator])
|
|
7201
7332
|
*
|
|
7202
7333
|
* Throw a failure.
|
|
7203
7334
|
*
|
|
7335
|
+
* expect.fail();
|
|
7336
|
+
* expect.fail("custom error message");
|
|
7337
|
+
* expect.fail(1, 2);
|
|
7338
|
+
* expect.fail(1, 2, "custom error message");
|
|
7339
|
+
* expect.fail(1, 2, "custom error message", ">");
|
|
7340
|
+
* expect.fail(1, 2, undefined, ">");
|
|
7341
|
+
*
|
|
7204
7342
|
* @name fail
|
|
7205
7343
|
* @param {Mixed} actual
|
|
7206
7344
|
* @param {Mixed} expected
|
|
@@ -7211,6 +7349,11 @@ module.exports = function (chai, util) {
|
|
|
7211
7349
|
*/
|
|
7212
7350
|
|
|
7213
7351
|
chai.expect.fail = function (actual, expected, message, operator) {
|
|
7352
|
+
if (arguments.length < 2) {
|
|
7353
|
+
message = actual;
|
|
7354
|
+
actual = undefined;
|
|
7355
|
+
}
|
|
7356
|
+
|
|
7214
7357
|
message = message || 'expect.fail()';
|
|
7215
7358
|
throw new chai.AssertionError(message, {
|
|
7216
7359
|
actual: actual
|
|
@@ -7236,7 +7379,8 @@ module.exports = function (chai, util) {
|
|
|
7236
7379
|
if (this instanceof String
|
|
7237
7380
|
|| this instanceof Number
|
|
7238
7381
|
|| this instanceof Boolean
|
|
7239
|
-
|| typeof Symbol === 'function' && this instanceof Symbol
|
|
7382
|
+
|| typeof Symbol === 'function' && this instanceof Symbol
|
|
7383
|
+
|| typeof BigInt === 'function' && this instanceof BigInt) {
|
|
7240
7384
|
return new Assertion(this.valueOf(), null, shouldGetter);
|
|
7241
7385
|
}
|
|
7242
7386
|
return new Assertion(this, null, shouldGetter);
|
|
@@ -7265,10 +7409,19 @@ module.exports = function (chai, util) {
|
|
|
7265
7409
|
var should = {};
|
|
7266
7410
|
|
|
7267
7411
|
/**
|
|
7412
|
+
* ### .fail([message])
|
|
7268
7413
|
* ### .fail(actual, expected, [message], [operator])
|
|
7269
7414
|
*
|
|
7270
7415
|
* Throw a failure.
|
|
7271
7416
|
*
|
|
7417
|
+
* should.fail();
|
|
7418
|
+
* should.fail("custom error message");
|
|
7419
|
+
* should.fail(1, 2);
|
|
7420
|
+
* should.fail(1, 2, "custom error message");
|
|
7421
|
+
* should.fail(1, 2, "custom error message", ">");
|
|
7422
|
+
* should.fail(1, 2, undefined, ">");
|
|
7423
|
+
*
|
|
7424
|
+
*
|
|
7272
7425
|
* @name fail
|
|
7273
7426
|
* @param {Mixed} actual
|
|
7274
7427
|
* @param {Mixed} expected
|
|
@@ -7279,6 +7432,11 @@ module.exports = function (chai, util) {
|
|
|
7279
7432
|
*/
|
|
7280
7433
|
|
|
7281
7434
|
should.fail = function (actual, expected, message, operator) {
|
|
7435
|
+
if (arguments.length < 2) {
|
|
7436
|
+
message = actual;
|
|
7437
|
+
actual = undefined;
|
|
7438
|
+
}
|
|
7439
|
+
|
|
7282
7440
|
message = message || 'should.fail()';
|
|
7283
7441
|
throw new chai.AssertionError(message, {
|
|
7284
7442
|
actual: actual
|
|
@@ -7580,9 +7738,7 @@ module.exports = function addChainableMethod(ctx, name, method, chainingBehavior
|
|
|
7580
7738
|
});
|
|
7581
7739
|
};
|
|
7582
7740
|
|
|
7583
|
-
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":
|
|
7584
|
-
var config = require('../config');
|
|
7585
|
-
|
|
7741
|
+
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":31,"./transferFlags":33}],10:[function(require,module,exports){
|
|
7586
7742
|
var fnLengthDesc = Object.getOwnPropertyDescriptor(function () {}, 'length');
|
|
7587
7743
|
|
|
7588
7744
|
/*!
|
|
@@ -7644,7 +7800,7 @@ module.exports = function addLengthGuard (fn, assertionName, isChainable) {
|
|
|
7644
7800
|
return fn;
|
|
7645
7801
|
};
|
|
7646
7802
|
|
|
7647
|
-
},{
|
|
7803
|
+
},{}],11:[function(require,module,exports){
|
|
7648
7804
|
/*!
|
|
7649
7805
|
* Chai - addMethod utility
|
|
7650
7806
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -7714,7 +7870,7 @@ module.exports = function addMethod(ctx, name, method) {
|
|
|
7714
7870
|
ctx[name] = proxify(methodWrapper, name);
|
|
7715
7871
|
};
|
|
7716
7872
|
|
|
7717
|
-
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":
|
|
7873
|
+
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":31,"./transferFlags":33}],12:[function(require,module,exports){
|
|
7718
7874
|
/*!
|
|
7719
7875
|
* Chai - addProperty utility
|
|
7720
7876
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -7753,7 +7909,7 @@ var transferFlags = require('./transferFlags');
|
|
|
7753
7909
|
*/
|
|
7754
7910
|
|
|
7755
7911
|
module.exports = function addProperty(ctx, name, getter) {
|
|
7756
|
-
getter = getter === undefined ?
|
|
7912
|
+
getter = getter === undefined ? function () {} : getter;
|
|
7757
7913
|
|
|
7758
7914
|
Object.defineProperty(ctx, name,
|
|
7759
7915
|
{ get: function propertyGetter() {
|
|
@@ -7788,7 +7944,7 @@ module.exports = function addProperty(ctx, name, getter) {
|
|
|
7788
7944
|
});
|
|
7789
7945
|
};
|
|
7790
7946
|
|
|
7791
|
-
},{"../../chai":2,"./flag":15,"./isProxyEnabled":
|
|
7947
|
+
},{"../../chai":2,"./flag":15,"./isProxyEnabled":26,"./transferFlags":33}],13:[function(require,module,exports){
|
|
7792
7948
|
/*!
|
|
7793
7949
|
* Chai - compareByInspect utility
|
|
7794
7950
|
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -7796,7 +7952,7 @@ module.exports = function addProperty(ctx, name, getter) {
|
|
|
7796
7952
|
*/
|
|
7797
7953
|
|
|
7798
7954
|
/*!
|
|
7799
|
-
* Module
|
|
7955
|
+
* Module dependencies
|
|
7800
7956
|
*/
|
|
7801
7957
|
|
|
7802
7958
|
var inspect = require('./inspect');
|
|
@@ -7811,7 +7967,7 @@ var inspect = require('./inspect');
|
|
|
7811
7967
|
*
|
|
7812
7968
|
* @param {Mixed} first element to compare
|
|
7813
7969
|
* @param {Mixed} second element to compare
|
|
7814
|
-
* @returns {Number} -1 if 'a' should come before 'b'; otherwise 1
|
|
7970
|
+
* @returns {Number} -1 if 'a' should come before 'b'; otherwise 1
|
|
7815
7971
|
* @name compareByInspect
|
|
7816
7972
|
* @namespace Utils
|
|
7817
7973
|
* @api public
|
|
@@ -7821,7 +7977,7 @@ module.exports = function compareByInspect(a, b) {
|
|
|
7821
7977
|
return inspect(a) < inspect(b) ? -1 : 1;
|
|
7822
7978
|
};
|
|
7823
7979
|
|
|
7824
|
-
},{"./inspect":
|
|
7980
|
+
},{"./inspect":24}],14:[function(require,module,exports){
|
|
7825
7981
|
/*!
|
|
7826
7982
|
* Chai - expectTypes utility
|
|
7827
7983
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -7874,7 +8030,7 @@ module.exports = function expectTypes(obj, types) {
|
|
|
7874
8030
|
}
|
|
7875
8031
|
};
|
|
7876
8032
|
|
|
7877
|
-
},{"./flag":15,"assertion-error":
|
|
8033
|
+
},{"./flag":15,"assertion-error":34,"type-detect":39}],15:[function(require,module,exports){
|
|
7878
8034
|
/*!
|
|
7879
8035
|
* Chai - flag utility
|
|
7880
8036
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -7967,12 +8123,11 @@ module.exports = function getEnumerableProperties(object) {
|
|
|
7967
8123
|
*/
|
|
7968
8124
|
|
|
7969
8125
|
/*!
|
|
7970
|
-
* Module
|
|
8126
|
+
* Module dependencies
|
|
7971
8127
|
*/
|
|
7972
8128
|
|
|
7973
8129
|
var flag = require('./flag')
|
|
7974
8130
|
, getActual = require('./getActual')
|
|
7975
|
-
, inspect = require('./inspect')
|
|
7976
8131
|
, objDisplay = require('./objDisplay');
|
|
7977
8132
|
|
|
7978
8133
|
/**
|
|
@@ -8012,7 +8167,64 @@ module.exports = function getMessage(obj, args) {
|
|
|
8012
8167
|
return flagMsg ? flagMsg + ': ' + msg : msg;
|
|
8013
8168
|
};
|
|
8014
8169
|
|
|
8015
|
-
},{"./flag":15,"./getActual":16,"./
|
|
8170
|
+
},{"./flag":15,"./getActual":16,"./objDisplay":27}],19:[function(require,module,exports){
|
|
8171
|
+
var type = require('type-detect');
|
|
8172
|
+
|
|
8173
|
+
var flag = require('./flag');
|
|
8174
|
+
|
|
8175
|
+
function isObjectType(obj) {
|
|
8176
|
+
var objectType = type(obj);
|
|
8177
|
+
var objectTypes = ['Array', 'Object', 'function'];
|
|
8178
|
+
|
|
8179
|
+
return objectTypes.indexOf(objectType) !== -1;
|
|
8180
|
+
}
|
|
8181
|
+
|
|
8182
|
+
/**
|
|
8183
|
+
* ### .getOperator(message)
|
|
8184
|
+
*
|
|
8185
|
+
* Extract the operator from error message.
|
|
8186
|
+
* Operator defined is based on below link
|
|
8187
|
+
* https://nodejs.org/api/assert.html#assert_assert.
|
|
8188
|
+
*
|
|
8189
|
+
* Returns the `operator` or `undefined` value for an Assertion.
|
|
8190
|
+
*
|
|
8191
|
+
* @param {Object} object (constructed Assertion)
|
|
8192
|
+
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
|
8193
|
+
* @namespace Utils
|
|
8194
|
+
* @name getOperator
|
|
8195
|
+
* @api public
|
|
8196
|
+
*/
|
|
8197
|
+
|
|
8198
|
+
module.exports = function getOperator(obj, args) {
|
|
8199
|
+
var operator = flag(obj, 'operator');
|
|
8200
|
+
var negate = flag(obj, 'negate');
|
|
8201
|
+
var expected = args[3];
|
|
8202
|
+
var msg = negate ? args[2] : args[1];
|
|
8203
|
+
|
|
8204
|
+
if (operator) {
|
|
8205
|
+
return operator;
|
|
8206
|
+
}
|
|
8207
|
+
|
|
8208
|
+
if (typeof msg === 'function') msg = msg();
|
|
8209
|
+
|
|
8210
|
+
msg = msg || '';
|
|
8211
|
+
if (!msg) {
|
|
8212
|
+
return undefined;
|
|
8213
|
+
}
|
|
8214
|
+
|
|
8215
|
+
if (/\shave\s/.test(msg)) {
|
|
8216
|
+
return undefined;
|
|
8217
|
+
}
|
|
8218
|
+
|
|
8219
|
+
var isObject = isObjectType(expected);
|
|
8220
|
+
if (/\snot\s/.test(msg)) {
|
|
8221
|
+
return isObject ? 'notDeepStrictEqual' : 'notStrictEqual';
|
|
8222
|
+
}
|
|
8223
|
+
|
|
8224
|
+
return isObject ? 'deepStrictEqual' : 'strictEqual';
|
|
8225
|
+
};
|
|
8226
|
+
|
|
8227
|
+
},{"./flag":15,"type-detect":39}],20:[function(require,module,exports){
|
|
8016
8228
|
/*!
|
|
8017
8229
|
* Chai - getOwnEnumerableProperties utility
|
|
8018
8230
|
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8020,7 +8232,7 @@ module.exports = function getMessage(obj, args) {
|
|
|
8020
8232
|
*/
|
|
8021
8233
|
|
|
8022
8234
|
/*!
|
|
8023
|
-
* Module
|
|
8235
|
+
* Module dependencies
|
|
8024
8236
|
*/
|
|
8025
8237
|
|
|
8026
8238
|
var getOwnEnumerablePropertySymbols = require('./getOwnEnumerablePropertySymbols');
|
|
@@ -8043,7 +8255,7 @@ module.exports = function getOwnEnumerableProperties(obj) {
|
|
|
8043
8255
|
return Object.keys(obj).concat(getOwnEnumerablePropertySymbols(obj));
|
|
8044
8256
|
};
|
|
8045
8257
|
|
|
8046
|
-
},{"./getOwnEnumerablePropertySymbols":
|
|
8258
|
+
},{"./getOwnEnumerablePropertySymbols":21}],21:[function(require,module,exports){
|
|
8047
8259
|
/*!
|
|
8048
8260
|
* Chai - getOwnEnumerablePropertySymbols utility
|
|
8049
8261
|
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8072,7 +8284,7 @@ module.exports = function getOwnEnumerablePropertySymbols(obj) {
|
|
|
8072
8284
|
});
|
|
8073
8285
|
};
|
|
8074
8286
|
|
|
8075
|
-
},{}],
|
|
8287
|
+
},{}],22:[function(require,module,exports){
|
|
8076
8288
|
/*!
|
|
8077
8289
|
* Chai - getProperties utility
|
|
8078
8290
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8110,7 +8322,7 @@ module.exports = function getProperties(object) {
|
|
|
8110
8322
|
return result;
|
|
8111
8323
|
};
|
|
8112
8324
|
|
|
8113
|
-
},{}],
|
|
8325
|
+
},{}],23:[function(require,module,exports){
|
|
8114
8326
|
/*!
|
|
8115
8327
|
* chai
|
|
8116
8328
|
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8284,7 +8496,12 @@ exports.isProxyEnabled = require('./isProxyEnabled');
|
|
|
8284
8496
|
|
|
8285
8497
|
exports.isNaN = require('./isNaN');
|
|
8286
8498
|
|
|
8287
|
-
|
|
8499
|
+
/*!
|
|
8500
|
+
* getOperator method
|
|
8501
|
+
*/
|
|
8502
|
+
|
|
8503
|
+
exports.getOperator = require('./getOperator');
|
|
8504
|
+
},{"./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){
|
|
8288
8505
|
// This is (almost) directly from Node.js utils
|
|
8289
8506
|
// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js
|
|
8290
8507
|
|
|
@@ -8392,7 +8609,7 @@ function formatValue(ctx, value, recurseTimes) {
|
|
|
8392
8609
|
|
|
8393
8610
|
var name, nameSuffix;
|
|
8394
8611
|
|
|
8395
|
-
// Some type of object without properties can be
|
|
8612
|
+
// Some type of object without properties can be shortcut.
|
|
8396
8613
|
// In IE, errors have a single `stack` property, or if they are vanilla `Error`,
|
|
8397
8614
|
// a `stack` plus `description` property; ignore those for consistency.
|
|
8398
8615
|
if (keys.length === 0 || (isError(value) && (
|
|
@@ -8483,7 +8700,6 @@ function formatValue(ctx, value, recurseTimes) {
|
|
|
8483
8700
|
return reduceToSingleString(output, base, braces);
|
|
8484
8701
|
}
|
|
8485
8702
|
|
|
8486
|
-
|
|
8487
8703
|
function formatPrimitive(ctx, value) {
|
|
8488
8704
|
switch (typeof value) {
|
|
8489
8705
|
case 'undefined':
|
|
@@ -8513,12 +8729,10 @@ function formatPrimitive(ctx, value) {
|
|
|
8513
8729
|
}
|
|
8514
8730
|
}
|
|
8515
8731
|
|
|
8516
|
-
|
|
8517
8732
|
function formatError(value) {
|
|
8518
8733
|
return '[' + Error.prototype.toString.call(value) + ']';
|
|
8519
8734
|
}
|
|
8520
8735
|
|
|
8521
|
-
|
|
8522
8736
|
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
|
8523
8737
|
var output = [];
|
|
8524
8738
|
for (var i = 0, l = value.length; i < l; ++i) {
|
|
@@ -8621,12 +8835,8 @@ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
|
|
8621
8835
|
return name + ': ' + str;
|
|
8622
8836
|
}
|
|
8623
8837
|
|
|
8624
|
-
|
|
8625
8838
|
function reduceToSingleString(output, base, braces) {
|
|
8626
|
-
var numLinesEst = 0;
|
|
8627
8839
|
var length = output.reduce(function(prev, cur) {
|
|
8628
|
-
numLinesEst++;
|
|
8629
|
-
if (cur.indexOf('\n') >= 0) numLinesEst++;
|
|
8630
8840
|
return prev + cur.length + 1;
|
|
8631
8841
|
}, 0);
|
|
8632
8842
|
|
|
@@ -8669,7 +8879,7 @@ function objectToString(o) {
|
|
|
8669
8879
|
return Object.prototype.toString.call(o);
|
|
8670
8880
|
}
|
|
8671
8881
|
|
|
8672
|
-
},{"../config":4,"./getEnumerableProperties":17,"./getProperties":
|
|
8882
|
+
},{"../config":4,"./getEnumerableProperties":17,"./getProperties":22,"get-func-name":37}],25:[function(require,module,exports){
|
|
8673
8883
|
/*!
|
|
8674
8884
|
* Chai - isNaN utility
|
|
8675
8885
|
* Copyright(c) 2012-2015 Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
|
|
@@ -8697,7 +8907,7 @@ function isNaN(value) {
|
|
|
8697
8907
|
// If ECMAScript 6's Number.isNaN is present, prefer that.
|
|
8698
8908
|
module.exports = Number.isNaN || isNaN;
|
|
8699
8909
|
|
|
8700
|
-
},{}],
|
|
8910
|
+
},{}],26:[function(require,module,exports){
|
|
8701
8911
|
var config = require('../config');
|
|
8702
8912
|
|
|
8703
8913
|
/*!
|
|
@@ -8718,12 +8928,12 @@ var config = require('../config');
|
|
|
8718
8928
|
*/
|
|
8719
8929
|
|
|
8720
8930
|
module.exports = function isProxyEnabled() {
|
|
8721
|
-
return config.useProxy &&
|
|
8931
|
+
return config.useProxy &&
|
|
8722
8932
|
typeof Proxy !== 'undefined' &&
|
|
8723
8933
|
typeof Reflect !== 'undefined';
|
|
8724
8934
|
};
|
|
8725
8935
|
|
|
8726
|
-
},{"../config":4}],
|
|
8936
|
+
},{"../config":4}],27:[function(require,module,exports){
|
|
8727
8937
|
/*!
|
|
8728
8938
|
* Chai - flag utility
|
|
8729
8939
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8731,7 +8941,7 @@ module.exports = function isProxyEnabled() {
|
|
|
8731
8941
|
*/
|
|
8732
8942
|
|
|
8733
8943
|
/*!
|
|
8734
|
-
* Module
|
|
8944
|
+
* Module dependencies
|
|
8735
8945
|
*/
|
|
8736
8946
|
|
|
8737
8947
|
var inspect = require('./inspect');
|
|
@@ -8775,7 +8985,7 @@ module.exports = function objDisplay(obj) {
|
|
|
8775
8985
|
}
|
|
8776
8986
|
};
|
|
8777
8987
|
|
|
8778
|
-
},{"../config":4,"./inspect":
|
|
8988
|
+
},{"../config":4,"./inspect":24}],28:[function(require,module,exports){
|
|
8779
8989
|
/*!
|
|
8780
8990
|
* Chai - overwriteChainableMethod utility
|
|
8781
8991
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8788,7 +8998,7 @@ var transferFlags = require('./transferFlags');
|
|
|
8788
8998
|
/**
|
|
8789
8999
|
* ### .overwriteChainableMethod(ctx, name, method, chainingBehavior)
|
|
8790
9000
|
*
|
|
8791
|
-
*
|
|
9001
|
+
* Overwrites an already existing chainable method
|
|
8792
9002
|
* and provides access to the previous function or
|
|
8793
9003
|
* property. Must return functions to be used for
|
|
8794
9004
|
* name.
|
|
@@ -8846,7 +9056,7 @@ module.exports = function overwriteChainableMethod(ctx, name, method, chainingBe
|
|
|
8846
9056
|
};
|
|
8847
9057
|
};
|
|
8848
9058
|
|
|
8849
|
-
},{"../../chai":2,"./transferFlags":
|
|
9059
|
+
},{"../../chai":2,"./transferFlags":33}],29:[function(require,module,exports){
|
|
8850
9060
|
/*!
|
|
8851
9061
|
* Chai - overwriteMethod utility
|
|
8852
9062
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8862,7 +9072,7 @@ var transferFlags = require('./transferFlags');
|
|
|
8862
9072
|
/**
|
|
8863
9073
|
* ### .overwriteMethod(ctx, name, fn)
|
|
8864
9074
|
*
|
|
8865
|
-
*
|
|
9075
|
+
* Overwrites an already existing method and provides
|
|
8866
9076
|
* access to previous function. Must return function
|
|
8867
9077
|
* to be used for name.
|
|
8868
9078
|
*
|
|
@@ -8940,7 +9150,7 @@ module.exports = function overwriteMethod(ctx, name, method) {
|
|
|
8940
9150
|
ctx[name] = proxify(overwritingMethodWrapper, name);
|
|
8941
9151
|
};
|
|
8942
9152
|
|
|
8943
|
-
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":
|
|
9153
|
+
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":31,"./transferFlags":33}],30:[function(require,module,exports){
|
|
8944
9154
|
/*!
|
|
8945
9155
|
* Chai - overwriteProperty utility
|
|
8946
9156
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8955,7 +9165,7 @@ var transferFlags = require('./transferFlags');
|
|
|
8955
9165
|
/**
|
|
8956
9166
|
* ### .overwriteProperty(ctx, name, fn)
|
|
8957
9167
|
*
|
|
8958
|
-
*
|
|
9168
|
+
* Overwrites an already existing property getter and provides
|
|
8959
9169
|
* access to previous value. Must return function to use as getter.
|
|
8960
9170
|
*
|
|
8961
9171
|
* utils.overwriteProperty(chai.Assertion.prototype, 'ok', function (_super) {
|
|
@@ -9034,7 +9244,7 @@ module.exports = function overwriteProperty(ctx, name, getter) {
|
|
|
9034
9244
|
});
|
|
9035
9245
|
};
|
|
9036
9246
|
|
|
9037
|
-
},{"../../chai":2,"./flag":15,"./isProxyEnabled":
|
|
9247
|
+
},{"../../chai":2,"./flag":15,"./isProxyEnabled":26,"./transferFlags":33}],31:[function(require,module,exports){
|
|
9038
9248
|
var config = require('../config');
|
|
9039
9249
|
var flag = require('./flag');
|
|
9040
9250
|
var getProperties = require('./getProperties');
|
|
@@ -9055,7 +9265,7 @@ var isProxyEnabled = require('./isProxyEnabled');
|
|
|
9055
9265
|
* the list of existing properties. However, if a nonChainableMethodName is
|
|
9056
9266
|
* provided, then the root cause is instead a failure to invoke a non-chainable
|
|
9057
9267
|
* method prior to reading the non-existent property.
|
|
9058
|
-
*
|
|
9268
|
+
*
|
|
9059
9269
|
* If proxies are unsupported or disabled via the user's Chai config, then
|
|
9060
9270
|
* return object without modification.
|
|
9061
9271
|
*
|
|
@@ -9086,19 +9296,31 @@ module.exports = function proxify(obj, nonChainableMethodName) {
|
|
|
9086
9296
|
nonChainableMethodName + '".');
|
|
9087
9297
|
}
|
|
9088
9298
|
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
|
|
9299
|
+
// If the property is reasonably close to an existing Chai property,
|
|
9300
|
+
// suggest that property to the user. Only suggest properties with a
|
|
9301
|
+
// distance less than 4.
|
|
9302
|
+
var suggestion = null;
|
|
9303
|
+
var suggestionDistance = 4;
|
|
9304
|
+
getProperties(target).forEach(function(prop) {
|
|
9305
|
+
if (
|
|
9306
|
+
!Object.prototype.hasOwnProperty(prop) &&
|
|
9307
|
+
builtins.indexOf(prop) === -1
|
|
9308
|
+
) {
|
|
9309
|
+
var dist = stringDistanceCapped(
|
|
9310
|
+
property,
|
|
9311
|
+
prop,
|
|
9312
|
+
suggestionDistance
|
|
9313
|
+
);
|
|
9314
|
+
if (dist < suggestionDistance) {
|
|
9315
|
+
suggestion = prop;
|
|
9316
|
+
suggestionDistance = dist;
|
|
9317
|
+
}
|
|
9318
|
+
}
|
|
9094
9319
|
});
|
|
9095
9320
|
|
|
9096
|
-
if (
|
|
9097
|
-
stringDistance(orderedProperties[0], property) < 4) {
|
|
9098
|
-
// If the property is reasonably close to an existing Chai property,
|
|
9099
|
-
// suggest that property to the user.
|
|
9321
|
+
if (suggestion !== null) {
|
|
9100
9322
|
throw Error('Invalid Chai property: ' + property +
|
|
9101
|
-
'. Did you mean "' +
|
|
9323
|
+
'. Did you mean "' + suggestion + '"?');
|
|
9102
9324
|
} else {
|
|
9103
9325
|
throw Error('Invalid Chai property: ' + property);
|
|
9104
9326
|
}
|
|
@@ -9126,34 +9348,44 @@ module.exports = function proxify(obj, nonChainableMethodName) {
|
|
|
9126
9348
|
};
|
|
9127
9349
|
|
|
9128
9350
|
/**
|
|
9129
|
-
* #
|
|
9130
|
-
* Return the Levenshtein distance between two strings.
|
|
9351
|
+
* # stringDistanceCapped(strA, strB, cap)
|
|
9352
|
+
* Return the Levenshtein distance between two strings, but no more than cap.
|
|
9131
9353
|
* @param {string} strA
|
|
9132
9354
|
* @param {string} strB
|
|
9133
|
-
* @
|
|
9355
|
+
* @param {number} number
|
|
9356
|
+
* @return {number} min(string distance between strA and strB, cap)
|
|
9134
9357
|
* @api private
|
|
9135
9358
|
*/
|
|
9136
9359
|
|
|
9137
|
-
function
|
|
9138
|
-
if (
|
|
9139
|
-
|
|
9140
|
-
// memo[i][j] is the distance between strA.slice(0, i) and
|
|
9141
|
-
// strB.slice(0, j).
|
|
9142
|
-
memo = [];
|
|
9143
|
-
for (var i = 0; i <= strA.length; i++) {
|
|
9144
|
-
memo[i] = [];
|
|
9145
|
-
}
|
|
9360
|
+
function stringDistanceCapped(strA, strB, cap) {
|
|
9361
|
+
if (Math.abs(strA.length - strB.length) >= cap) {
|
|
9362
|
+
return cap;
|
|
9146
9363
|
}
|
|
9147
9364
|
|
|
9148
|
-
|
|
9149
|
-
|
|
9150
|
-
|
|
9151
|
-
|
|
9152
|
-
|
|
9153
|
-
|
|
9154
|
-
|
|
9155
|
-
|
|
9156
|
-
|
|
9365
|
+
var memo = [];
|
|
9366
|
+
// `memo` is a two-dimensional array containing distances.
|
|
9367
|
+
// memo[i][j] is the distance between strA.slice(0, i) and
|
|
9368
|
+
// strB.slice(0, j).
|
|
9369
|
+
for (var i = 0; i <= strA.length; i++) {
|
|
9370
|
+
memo[i] = Array(strB.length + 1).fill(0);
|
|
9371
|
+
memo[i][0] = i;
|
|
9372
|
+
}
|
|
9373
|
+
for (var j = 0; j < strB.length; j++) {
|
|
9374
|
+
memo[0][j] = j;
|
|
9375
|
+
}
|
|
9376
|
+
|
|
9377
|
+
for (var i = 1; i <= strA.length; i++) {
|
|
9378
|
+
var ch = strA.charCodeAt(i - 1);
|
|
9379
|
+
for (var j = 1; j <= strB.length; j++) {
|
|
9380
|
+
if (Math.abs(i - j) >= cap) {
|
|
9381
|
+
memo[i][j] = cap;
|
|
9382
|
+
continue;
|
|
9383
|
+
}
|
|
9384
|
+
memo[i][j] = Math.min(
|
|
9385
|
+
memo[i - 1][j] + 1,
|
|
9386
|
+
memo[i][j - 1] + 1,
|
|
9387
|
+
memo[i - 1][j - 1] +
|
|
9388
|
+
(ch === strB.charCodeAt(j - 1) ? 0 : 1)
|
|
9157
9389
|
);
|
|
9158
9390
|
}
|
|
9159
9391
|
}
|
|
@@ -9161,7 +9393,7 @@ function stringDistance(strA, strB, memo) {
|
|
|
9161
9393
|
return memo[strA.length][strB.length];
|
|
9162
9394
|
}
|
|
9163
9395
|
|
|
9164
|
-
},{"../config":4,"./flag":15,"./getProperties":
|
|
9396
|
+
},{"../config":4,"./flag":15,"./getProperties":22,"./isProxyEnabled":26}],32:[function(require,module,exports){
|
|
9165
9397
|
/*!
|
|
9166
9398
|
* Chai - test utility
|
|
9167
9399
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -9169,7 +9401,7 @@ function stringDistance(strA, strB, memo) {
|
|
|
9169
9401
|
*/
|
|
9170
9402
|
|
|
9171
9403
|
/*!
|
|
9172
|
-
* Module
|
|
9404
|
+
* Module dependencies
|
|
9173
9405
|
*/
|
|
9174
9406
|
|
|
9175
9407
|
var flag = require('./flag');
|
|
@@ -9191,7 +9423,7 @@ module.exports = function test(obj, args) {
|
|
|
9191
9423
|
return negate ? !expr : expr;
|
|
9192
9424
|
};
|
|
9193
9425
|
|
|
9194
|
-
},{"./flag":15}],
|
|
9426
|
+
},{"./flag":15}],33:[function(require,module,exports){
|
|
9195
9427
|
/*!
|
|
9196
9428
|
* Chai - transferFlags utility
|
|
9197
9429
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -9210,7 +9442,7 @@ module.exports = function test(obj, args) {
|
|
|
9210
9442
|
* var newAssertion = new Assertion();
|
|
9211
9443
|
* utils.transferFlags(assertion, newAssertion);
|
|
9212
9444
|
*
|
|
9213
|
-
* var
|
|
9445
|
+
* var anotherAssertion = new Assertion(myObj);
|
|
9214
9446
|
* utils.transferFlags(assertion, anotherAssertion, false);
|
|
9215
9447
|
*
|
|
9216
9448
|
* @param {Assertion} assertion the assertion to transfer the flags from
|
|
@@ -9238,7 +9470,7 @@ module.exports = function transferFlags(assertion, object, includeAll) {
|
|
|
9238
9470
|
}
|
|
9239
9471
|
};
|
|
9240
9472
|
|
|
9241
|
-
},{}],
|
|
9473
|
+
},{}],34:[function(require,module,exports){
|
|
9242
9474
|
/*!
|
|
9243
9475
|
* assertion-error
|
|
9244
9476
|
* Copyright(c) 2013 Jake Luer <jake@qualiancy.com>
|
|
@@ -9307,8 +9539,8 @@ function AssertionError (message, _props, ssf) {
|
|
|
9307
9539
|
}
|
|
9308
9540
|
|
|
9309
9541
|
// capture stack trace
|
|
9310
|
-
ssf = ssf ||
|
|
9311
|
-
if (
|
|
9542
|
+
ssf = ssf || AssertionError;
|
|
9543
|
+
if (Error.captureStackTrace) {
|
|
9312
9544
|
Error.captureStackTrace(this, ssf);
|
|
9313
9545
|
} else {
|
|
9314
9546
|
try {
|
|
@@ -9356,7 +9588,7 @@ AssertionError.prototype.toJSON = function (stack) {
|
|
|
9356
9588
|
return props;
|
|
9357
9589
|
};
|
|
9358
9590
|
|
|
9359
|
-
},{}],
|
|
9591
|
+
},{}],35:[function(require,module,exports){
|
|
9360
9592
|
'use strict';
|
|
9361
9593
|
|
|
9362
9594
|
/* !
|
|
@@ -9530,59 +9762,35 @@ module.exports = {
|
|
|
9530
9762
|
getConstructorName: getConstructorName,
|
|
9531
9763
|
};
|
|
9532
9764
|
|
|
9533
|
-
},{}],
|
|
9765
|
+
},{}],36:[function(require,module,exports){
|
|
9534
9766
|
'use strict';
|
|
9535
|
-
/* globals Symbol:
|
|
9767
|
+
/* globals Symbol: false, Uint8Array: false, WeakMap: false */
|
|
9536
9768
|
/*!
|
|
9537
9769
|
* deep-eql
|
|
9538
9770
|
* Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
|
|
9539
9771
|
* MIT Licensed
|
|
9540
9772
|
*/
|
|
9541
9773
|
|
|
9542
|
-
/*!
|
|
9543
|
-
* Module dependencies
|
|
9544
|
-
*/
|
|
9545
|
-
|
|
9546
9774
|
var type = require('type-detect');
|
|
9547
9775
|
function FakeMap() {
|
|
9548
|
-
this.
|
|
9776
|
+
this._key = 'chai/deep-eql__' + Math.random() + Date.now();
|
|
9549
9777
|
}
|
|
9778
|
+
|
|
9550
9779
|
FakeMap.prototype = {
|
|
9551
|
-
clear: function clearMap() {
|
|
9552
|
-
this.keys = [];
|
|
9553
|
-
this.values = [];
|
|
9554
|
-
return this;
|
|
9555
|
-
},
|
|
9556
|
-
set: function setMap(key, value) {
|
|
9557
|
-
var index = this.keys.indexOf(key);
|
|
9558
|
-
if (index >= 0) {
|
|
9559
|
-
this.values[index] = value;
|
|
9560
|
-
} else {
|
|
9561
|
-
this.keys.push(key);
|
|
9562
|
-
this.values.push(value);
|
|
9563
|
-
}
|
|
9564
|
-
return this;
|
|
9565
|
-
},
|
|
9566
9780
|
get: function getMap(key) {
|
|
9567
|
-
return
|
|
9781
|
+
return key[this._key];
|
|
9568
9782
|
},
|
|
9569
|
-
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9783
|
+
set: function setMap(key, value) {
|
|
9784
|
+
if (Object.isExtensible(key)) {
|
|
9785
|
+
Object.defineProperty(key, this._key, {
|
|
9786
|
+
value: value,
|
|
9787
|
+
configurable: true,
|
|
9788
|
+
});
|
|
9574
9789
|
}
|
|
9575
|
-
return this;
|
|
9576
9790
|
},
|
|
9577
9791
|
};
|
|
9578
9792
|
|
|
9579
|
-
var MemoizeMap =
|
|
9580
|
-
if (typeof WeakMap === 'function') {
|
|
9581
|
-
MemoizeMap = WeakMap;
|
|
9582
|
-
} else {
|
|
9583
|
-
MemoizeMap = FakeMap;
|
|
9584
|
-
}
|
|
9585
|
-
|
|
9793
|
+
var MemoizeMap = typeof WeakMap === 'function' ? WeakMap : FakeMap;
|
|
9586
9794
|
/*!
|
|
9587
9795
|
* Check to see if the MemoizeMap has recorded a result of the two operands
|
|
9588
9796
|
*
|
|
@@ -10011,380 +10219,7 @@ function isPrimitive(value) {
|
|
|
10011
10219
|
return value === null || typeof value !== 'object';
|
|
10012
10220
|
}
|
|
10013
10221
|
|
|
10014
|
-
},{"type-detect":
|
|
10015
|
-
'use strict';
|
|
10016
|
-
/* !
|
|
10017
|
-
* type-detect
|
|
10018
|
-
* Copyright(c) 2013 jake luer <jake@alogicalparadox.com>
|
|
10019
|
-
* MIT Licensed
|
|
10020
|
-
*/
|
|
10021
|
-
var getPrototypeOfExists = typeof Object.getPrototypeOf === 'function';
|
|
10022
|
-
var promiseExists = typeof Promise === 'function';
|
|
10023
|
-
var globalObject = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : self; // eslint-disable-line
|
|
10024
|
-
var isDom = 'location' in globalObject && 'document' in globalObject;
|
|
10025
|
-
var htmlElementExists = typeof HTMLElement !== 'undefined';
|
|
10026
|
-
var isArrayExists = typeof Array.isArray === 'function';
|
|
10027
|
-
var symbolExists = typeof Symbol !== 'undefined';
|
|
10028
|
-
var mapExists = typeof Map !== 'undefined';
|
|
10029
|
-
var setExists = typeof Set !== 'undefined';
|
|
10030
|
-
var weakMapExists = typeof WeakMap !== 'undefined';
|
|
10031
|
-
var weakSetExists = typeof WeakSet !== 'undefined';
|
|
10032
|
-
var dataViewExists = typeof DataView !== 'undefined';
|
|
10033
|
-
var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== 'undefined';
|
|
10034
|
-
var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== 'undefined';
|
|
10035
|
-
var setEntriesExists = setExists && typeof Set.prototype.entries === 'function';
|
|
10036
|
-
var mapEntriesExists = mapExists && typeof Map.prototype.entries === 'function';
|
|
10037
|
-
var setIteratorPrototype = getPrototypeOfExists && setEntriesExists && Object.getPrototypeOf(new Set().entries());
|
|
10038
|
-
var mapIteratorPrototype = getPrototypeOfExists && mapEntriesExists && Object.getPrototypeOf(new Map().entries());
|
|
10039
|
-
var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function';
|
|
10040
|
-
var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
|
|
10041
|
-
var stringIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function';
|
|
10042
|
-
var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(''[Symbol.iterator]());
|
|
10043
|
-
var toStringLeftSliceLength = 8;
|
|
10044
|
-
var toStringRightSliceLength = -1;
|
|
10045
|
-
/**
|
|
10046
|
-
* ### typeOf (obj)
|
|
10047
|
-
*
|
|
10048
|
-
* Uses `Object.prototype.toString` to determine the type of an object,
|
|
10049
|
-
* normalising behaviour across engine versions & well optimised.
|
|
10050
|
-
*
|
|
10051
|
-
* @param {Mixed} object
|
|
10052
|
-
* @return {String} object type
|
|
10053
|
-
* @api public
|
|
10054
|
-
*/
|
|
10055
|
-
module.exports = function typeDetect(obj) {
|
|
10056
|
-
/* ! Speed optimisation
|
|
10057
|
-
* Pre:
|
|
10058
|
-
* string literal x 3,039,035 ops/sec ±1.62% (78 runs sampled)
|
|
10059
|
-
* boolean literal x 1,424,138 ops/sec ±4.54% (75 runs sampled)
|
|
10060
|
-
* number literal x 1,653,153 ops/sec ±1.91% (82 runs sampled)
|
|
10061
|
-
* undefined x 9,978,660 ops/sec ±1.92% (75 runs sampled)
|
|
10062
|
-
* function x 2,556,769 ops/sec ±1.73% (77 runs sampled)
|
|
10063
|
-
* Post:
|
|
10064
|
-
* string literal x 38,564,796 ops/sec ±1.15% (79 runs sampled)
|
|
10065
|
-
* boolean literal x 31,148,940 ops/sec ±1.10% (79 runs sampled)
|
|
10066
|
-
* number literal x 32,679,330 ops/sec ±1.90% (78 runs sampled)
|
|
10067
|
-
* undefined x 32,363,368 ops/sec ±1.07% (82 runs sampled)
|
|
10068
|
-
* function x 31,296,870 ops/sec ±0.96% (83 runs sampled)
|
|
10069
|
-
*/
|
|
10070
|
-
var typeofObj = typeof obj;
|
|
10071
|
-
if (typeofObj !== 'object') {
|
|
10072
|
-
return typeofObj;
|
|
10073
|
-
}
|
|
10074
|
-
|
|
10075
|
-
/* ! Speed optimisation
|
|
10076
|
-
* Pre:
|
|
10077
|
-
* null x 28,645,765 ops/sec ±1.17% (82 runs sampled)
|
|
10078
|
-
* Post:
|
|
10079
|
-
* null x 36,428,962 ops/sec ±1.37% (84 runs sampled)
|
|
10080
|
-
*/
|
|
10081
|
-
if (obj === null) {
|
|
10082
|
-
return 'null';
|
|
10083
|
-
}
|
|
10084
|
-
|
|
10085
|
-
/* ! Spec Conformance
|
|
10086
|
-
* Test: `Object.prototype.toString.call(window)``
|
|
10087
|
-
* - Node === "[object global]"
|
|
10088
|
-
* - Chrome === "[object global]"
|
|
10089
|
-
* - Firefox === "[object Window]"
|
|
10090
|
-
* - PhantomJS === "[object Window]"
|
|
10091
|
-
* - Safari === "[object Window]"
|
|
10092
|
-
* - IE 11 === "[object Window]"
|
|
10093
|
-
* - IE Edge === "[object Window]"
|
|
10094
|
-
* Test: `Object.prototype.toString.call(this)``
|
|
10095
|
-
* - Chrome Worker === "[object global]"
|
|
10096
|
-
* - Firefox Worker === "[object DedicatedWorkerGlobalScope]"
|
|
10097
|
-
* - Safari Worker === "[object DedicatedWorkerGlobalScope]"
|
|
10098
|
-
* - IE 11 Worker === "[object WorkerGlobalScope]"
|
|
10099
|
-
* - IE Edge Worker === "[object WorkerGlobalScope]"
|
|
10100
|
-
*/
|
|
10101
|
-
if (obj === globalObject) {
|
|
10102
|
-
return 'global';
|
|
10103
|
-
}
|
|
10104
|
-
|
|
10105
|
-
/* ! Speed optimisation
|
|
10106
|
-
* Pre:
|
|
10107
|
-
* array literal x 2,888,352 ops/sec ±0.67% (82 runs sampled)
|
|
10108
|
-
* Post:
|
|
10109
|
-
* array literal x 22,479,650 ops/sec ±0.96% (81 runs sampled)
|
|
10110
|
-
*/
|
|
10111
|
-
if (isArrayExists && Array.isArray(obj)) {
|
|
10112
|
-
return 'Array';
|
|
10113
|
-
}
|
|
10114
|
-
|
|
10115
|
-
if (isDom) {
|
|
10116
|
-
/* ! Spec Conformance
|
|
10117
|
-
* (https://html.spec.whatwg.org/multipage/browsers.html#location)
|
|
10118
|
-
* WhatWG HTML$7.7.3 - The `Location` interface
|
|
10119
|
-
* Test: `Object.prototype.toString.call(window.location)``
|
|
10120
|
-
* - IE <=11 === "[object Object]"
|
|
10121
|
-
* - IE Edge <=13 === "[object Object]"
|
|
10122
|
-
*/
|
|
10123
|
-
if (obj === globalObject.location) {
|
|
10124
|
-
return 'Location';
|
|
10125
|
-
}
|
|
10126
|
-
|
|
10127
|
-
/* ! Spec Conformance
|
|
10128
|
-
* (https://html.spec.whatwg.org/#document)
|
|
10129
|
-
* WhatWG HTML$3.1.1 - The `Document` object
|
|
10130
|
-
* Note: Most browsers currently adher to the W3C DOM Level 2 spec
|
|
10131
|
-
* (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268)
|
|
10132
|
-
* which suggests that browsers should use HTMLTableCellElement for
|
|
10133
|
-
* both TD and TH elements. WhatWG separates these.
|
|
10134
|
-
* WhatWG HTML states:
|
|
10135
|
-
* > For historical reasons, Window objects must also have a
|
|
10136
|
-
* > writable, configurable, non-enumerable property named
|
|
10137
|
-
* > HTMLDocument whose value is the Document interface object.
|
|
10138
|
-
* Test: `Object.prototype.toString.call(document)``
|
|
10139
|
-
* - Chrome === "[object HTMLDocument]"
|
|
10140
|
-
* - Firefox === "[object HTMLDocument]"
|
|
10141
|
-
* - Safari === "[object HTMLDocument]"
|
|
10142
|
-
* - IE <=10 === "[object Document]"
|
|
10143
|
-
* - IE 11 === "[object HTMLDocument]"
|
|
10144
|
-
* - IE Edge <=13 === "[object HTMLDocument]"
|
|
10145
|
-
*/
|
|
10146
|
-
if (obj === globalObject.document) {
|
|
10147
|
-
return 'Document';
|
|
10148
|
-
}
|
|
10149
|
-
|
|
10150
|
-
/* ! Spec Conformance
|
|
10151
|
-
* (https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray)
|
|
10152
|
-
* WhatWG HTML$8.6.1.5 - Plugins - Interface MimeTypeArray
|
|
10153
|
-
* Test: `Object.prototype.toString.call(navigator.mimeTypes)``
|
|
10154
|
-
* - IE <=10 === "[object MSMimeTypesCollection]"
|
|
10155
|
-
*/
|
|
10156
|
-
if (obj === (globalObject.navigator || {}).mimeTypes) {
|
|
10157
|
-
return 'MimeTypeArray';
|
|
10158
|
-
}
|
|
10159
|
-
|
|
10160
|
-
/* ! Spec Conformance
|
|
10161
|
-
* (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
|
|
10162
|
-
* WhatWG HTML$8.6.1.5 - Plugins - Interface PluginArray
|
|
10163
|
-
* Test: `Object.prototype.toString.call(navigator.plugins)``
|
|
10164
|
-
* - IE <=10 === "[object MSPluginsCollection]"
|
|
10165
|
-
*/
|
|
10166
|
-
if (obj === (globalObject.navigator || {}).plugins) {
|
|
10167
|
-
return 'PluginArray';
|
|
10168
|
-
}
|
|
10169
|
-
|
|
10170
|
-
/* ! Spec Conformance
|
|
10171
|
-
* (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
|
|
10172
|
-
* WhatWG HTML$4.4.4 - The `blockquote` element - Interface `HTMLQuoteElement`
|
|
10173
|
-
* Test: `Object.prototype.toString.call(document.createElement('blockquote'))``
|
|
10174
|
-
* - IE <=10 === "[object HTMLBlockElement]"
|
|
10175
|
-
*/
|
|
10176
|
-
if (htmlElementExists && obj instanceof HTMLElement && obj.tagName === 'BLOCKQUOTE') {
|
|
10177
|
-
return 'HTMLQuoteElement';
|
|
10178
|
-
}
|
|
10179
|
-
|
|
10180
|
-
/* ! Spec Conformance
|
|
10181
|
-
* (https://html.spec.whatwg.org/#htmltabledatacellelement)
|
|
10182
|
-
* WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableDataCellElement`
|
|
10183
|
-
* Note: Most browsers currently adher to the W3C DOM Level 2 spec
|
|
10184
|
-
* (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
|
|
10185
|
-
* which suggests that browsers should use HTMLTableCellElement for
|
|
10186
|
-
* both TD and TH elements. WhatWG separates these.
|
|
10187
|
-
* Test: Object.prototype.toString.call(document.createElement('td'))
|
|
10188
|
-
* - Chrome === "[object HTMLTableCellElement]"
|
|
10189
|
-
* - Firefox === "[object HTMLTableCellElement]"
|
|
10190
|
-
* - Safari === "[object HTMLTableCellElement]"
|
|
10191
|
-
*/
|
|
10192
|
-
if (htmlElementExists && obj instanceof HTMLElement && obj.tagName === 'TD') {
|
|
10193
|
-
return 'HTMLTableDataCellElement';
|
|
10194
|
-
}
|
|
10195
|
-
|
|
10196
|
-
/* ! Spec Conformance
|
|
10197
|
-
* (https://html.spec.whatwg.org/#htmltableheadercellelement)
|
|
10198
|
-
* WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableHeaderCellElement`
|
|
10199
|
-
* Note: Most browsers currently adher to the W3C DOM Level 2 spec
|
|
10200
|
-
* (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
|
|
10201
|
-
* which suggests that browsers should use HTMLTableCellElement for
|
|
10202
|
-
* both TD and TH elements. WhatWG separates these.
|
|
10203
|
-
* Test: Object.prototype.toString.call(document.createElement('th'))
|
|
10204
|
-
* - Chrome === "[object HTMLTableCellElement]"
|
|
10205
|
-
* - Firefox === "[object HTMLTableCellElement]"
|
|
10206
|
-
* - Safari === "[object HTMLTableCellElement]"
|
|
10207
|
-
*/
|
|
10208
|
-
if (htmlElementExists && obj instanceof HTMLElement && obj.tagName === 'TH') {
|
|
10209
|
-
return 'HTMLTableHeaderCellElement';
|
|
10210
|
-
}
|
|
10211
|
-
}
|
|
10212
|
-
|
|
10213
|
-
/* ! Speed optimisation
|
|
10214
|
-
* Pre:
|
|
10215
|
-
* Float64Array x 625,644 ops/sec ±1.58% (80 runs sampled)
|
|
10216
|
-
* Float32Array x 1,279,852 ops/sec ±2.91% (77 runs sampled)
|
|
10217
|
-
* Uint32Array x 1,178,185 ops/sec ±1.95% (83 runs sampled)
|
|
10218
|
-
* Uint16Array x 1,008,380 ops/sec ±2.25% (80 runs sampled)
|
|
10219
|
-
* Uint8Array x 1,128,040 ops/sec ±2.11% (81 runs sampled)
|
|
10220
|
-
* Int32Array x 1,170,119 ops/sec ±2.88% (80 runs sampled)
|
|
10221
|
-
* Int16Array x 1,176,348 ops/sec ±5.79% (86 runs sampled)
|
|
10222
|
-
* Int8Array x 1,058,707 ops/sec ±4.94% (77 runs sampled)
|
|
10223
|
-
* Uint8ClampedArray x 1,110,633 ops/sec ±4.20% (80 runs sampled)
|
|
10224
|
-
* Post:
|
|
10225
|
-
* Float64Array x 7,105,671 ops/sec ±13.47% (64 runs sampled)
|
|
10226
|
-
* Float32Array x 5,887,912 ops/sec ±1.46% (82 runs sampled)
|
|
10227
|
-
* Uint32Array x 6,491,661 ops/sec ±1.76% (79 runs sampled)
|
|
10228
|
-
* Uint16Array x 6,559,795 ops/sec ±1.67% (82 runs sampled)
|
|
10229
|
-
* Uint8Array x 6,463,966 ops/sec ±1.43% (85 runs sampled)
|
|
10230
|
-
* Int32Array x 5,641,841 ops/sec ±3.49% (81 runs sampled)
|
|
10231
|
-
* Int16Array x 6,583,511 ops/sec ±1.98% (80 runs sampled)
|
|
10232
|
-
* Int8Array x 6,606,078 ops/sec ±1.74% (81 runs sampled)
|
|
10233
|
-
* Uint8ClampedArray x 6,602,224 ops/sec ±1.77% (83 runs sampled)
|
|
10234
|
-
*/
|
|
10235
|
-
var stringTag = (symbolToStringTagExists && obj[Symbol.toStringTag]);
|
|
10236
|
-
if (typeof stringTag === 'string') {
|
|
10237
|
-
return stringTag;
|
|
10238
|
-
}
|
|
10239
|
-
|
|
10240
|
-
if (getPrototypeOfExists) {
|
|
10241
|
-
var objPrototype = Object.getPrototypeOf(obj);
|
|
10242
|
-
/* ! Speed optimisation
|
|
10243
|
-
* Pre:
|
|
10244
|
-
* regex literal x 1,772,385 ops/sec ±1.85% (77 runs sampled)
|
|
10245
|
-
* regex constructor x 2,143,634 ops/sec ±2.46% (78 runs sampled)
|
|
10246
|
-
* Post:
|
|
10247
|
-
* regex literal x 3,928,009 ops/sec ±0.65% (78 runs sampled)
|
|
10248
|
-
* regex constructor x 3,931,108 ops/sec ±0.58% (84 runs sampled)
|
|
10249
|
-
*/
|
|
10250
|
-
if (objPrototype === RegExp.prototype) {
|
|
10251
|
-
return 'RegExp';
|
|
10252
|
-
}
|
|
10253
|
-
|
|
10254
|
-
/* ! Speed optimisation
|
|
10255
|
-
* Pre:
|
|
10256
|
-
* date x 2,130,074 ops/sec ±4.42% (68 runs sampled)
|
|
10257
|
-
* Post:
|
|
10258
|
-
* date x 3,953,779 ops/sec ±1.35% (77 runs sampled)
|
|
10259
|
-
*/
|
|
10260
|
-
if (objPrototype === Date.prototype) {
|
|
10261
|
-
return 'Date';
|
|
10262
|
-
}
|
|
10263
|
-
|
|
10264
|
-
/* ! Spec Conformance
|
|
10265
|
-
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag)
|
|
10266
|
-
* ES6$25.4.5.4 - Promise.prototype[@@toStringTag] should be "Promise":
|
|
10267
|
-
* Test: `Object.prototype.toString.call(Promise.resolve())``
|
|
10268
|
-
* - Chrome <=47 === "[object Object]"
|
|
10269
|
-
* - Edge <=20 === "[object Object]"
|
|
10270
|
-
* - Firefox 29-Latest === "[object Promise]"
|
|
10271
|
-
* - Safari 7.1-Latest === "[object Promise]"
|
|
10272
|
-
*/
|
|
10273
|
-
if (promiseExists && objPrototype === Promise.prototype) {
|
|
10274
|
-
return 'Promise';
|
|
10275
|
-
}
|
|
10276
|
-
|
|
10277
|
-
/* ! Speed optimisation
|
|
10278
|
-
* Pre:
|
|
10279
|
-
* set x 2,222,186 ops/sec ±1.31% (82 runs sampled)
|
|
10280
|
-
* Post:
|
|
10281
|
-
* set x 4,545,879 ops/sec ±1.13% (83 runs sampled)
|
|
10282
|
-
*/
|
|
10283
|
-
if (setExists && objPrototype === Set.prototype) {
|
|
10284
|
-
return 'Set';
|
|
10285
|
-
}
|
|
10286
|
-
|
|
10287
|
-
/* ! Speed optimisation
|
|
10288
|
-
* Pre:
|
|
10289
|
-
* map x 2,396,842 ops/sec ±1.59% (81 runs sampled)
|
|
10290
|
-
* Post:
|
|
10291
|
-
* map x 4,183,945 ops/sec ±6.59% (82 runs sampled)
|
|
10292
|
-
*/
|
|
10293
|
-
if (mapExists && objPrototype === Map.prototype) {
|
|
10294
|
-
return 'Map';
|
|
10295
|
-
}
|
|
10296
|
-
|
|
10297
|
-
/* ! Speed optimisation
|
|
10298
|
-
* Pre:
|
|
10299
|
-
* weakset x 1,323,220 ops/sec ±2.17% (76 runs sampled)
|
|
10300
|
-
* Post:
|
|
10301
|
-
* weakset x 4,237,510 ops/sec ±2.01% (77 runs sampled)
|
|
10302
|
-
*/
|
|
10303
|
-
if (weakSetExists && objPrototype === WeakSet.prototype) {
|
|
10304
|
-
return 'WeakSet';
|
|
10305
|
-
}
|
|
10306
|
-
|
|
10307
|
-
/* ! Speed optimisation
|
|
10308
|
-
* Pre:
|
|
10309
|
-
* weakmap x 1,500,260 ops/sec ±2.02% (78 runs sampled)
|
|
10310
|
-
* Post:
|
|
10311
|
-
* weakmap x 3,881,384 ops/sec ±1.45% (82 runs sampled)
|
|
10312
|
-
*/
|
|
10313
|
-
if (weakMapExists && objPrototype === WeakMap.prototype) {
|
|
10314
|
-
return 'WeakMap';
|
|
10315
|
-
}
|
|
10316
|
-
|
|
10317
|
-
/* ! Spec Conformance
|
|
10318
|
-
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag)
|
|
10319
|
-
* ES6$24.2.4.21 - DataView.prototype[@@toStringTag] should be "DataView":
|
|
10320
|
-
* Test: `Object.prototype.toString.call(new DataView(new ArrayBuffer(1)))``
|
|
10321
|
-
* - Edge <=13 === "[object Object]"
|
|
10322
|
-
*/
|
|
10323
|
-
if (dataViewExists && objPrototype === DataView.prototype) {
|
|
10324
|
-
return 'DataView';
|
|
10325
|
-
}
|
|
10326
|
-
|
|
10327
|
-
/* ! Spec Conformance
|
|
10328
|
-
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag)
|
|
10329
|
-
* ES6$23.1.5.2.2 - %MapIteratorPrototype%[@@toStringTag] should be "Map Iterator":
|
|
10330
|
-
* Test: `Object.prototype.toString.call(new Map().entries())``
|
|
10331
|
-
* - Edge <=13 === "[object Object]"
|
|
10332
|
-
*/
|
|
10333
|
-
if (mapExists && objPrototype === mapIteratorPrototype) {
|
|
10334
|
-
return 'Map Iterator';
|
|
10335
|
-
}
|
|
10336
|
-
|
|
10337
|
-
/* ! Spec Conformance
|
|
10338
|
-
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag)
|
|
10339
|
-
* ES6$23.2.5.2.2 - %SetIteratorPrototype%[@@toStringTag] should be "Set Iterator":
|
|
10340
|
-
* Test: `Object.prototype.toString.call(new Set().entries())``
|
|
10341
|
-
* - Edge <=13 === "[object Object]"
|
|
10342
|
-
*/
|
|
10343
|
-
if (setExists && objPrototype === setIteratorPrototype) {
|
|
10344
|
-
return 'Set Iterator';
|
|
10345
|
-
}
|
|
10346
|
-
|
|
10347
|
-
/* ! Spec Conformance
|
|
10348
|
-
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag)
|
|
10349
|
-
* ES6$22.1.5.2.2 - %ArrayIteratorPrototype%[@@toStringTag] should be "Array Iterator":
|
|
10350
|
-
* Test: `Object.prototype.toString.call([][Symbol.iterator]())``
|
|
10351
|
-
* - Edge <=13 === "[object Object]"
|
|
10352
|
-
*/
|
|
10353
|
-
if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
|
|
10354
|
-
return 'Array Iterator';
|
|
10355
|
-
}
|
|
10356
|
-
|
|
10357
|
-
/* ! Spec Conformance
|
|
10358
|
-
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag)
|
|
10359
|
-
* ES6$21.1.5.2.2 - %StringIteratorPrototype%[@@toStringTag] should be "String Iterator":
|
|
10360
|
-
* Test: `Object.prototype.toString.call(''[Symbol.iterator]())``
|
|
10361
|
-
* - Edge <=13 === "[object Object]"
|
|
10362
|
-
*/
|
|
10363
|
-
if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
|
|
10364
|
-
return 'String Iterator';
|
|
10365
|
-
}
|
|
10366
|
-
|
|
10367
|
-
/* ! Speed optimisation
|
|
10368
|
-
* Pre:
|
|
10369
|
-
* object from null x 2,424,320 ops/sec ±1.67% (76 runs sampled)
|
|
10370
|
-
* Post:
|
|
10371
|
-
* object from null x 5,838,000 ops/sec ±0.99% (84 runs sampled)
|
|
10372
|
-
*/
|
|
10373
|
-
if (objPrototype === null) {
|
|
10374
|
-
return 'Object';
|
|
10375
|
-
}
|
|
10376
|
-
}
|
|
10377
|
-
|
|
10378
|
-
return Object
|
|
10379
|
-
.prototype
|
|
10380
|
-
.toString
|
|
10381
|
-
.call(obj)
|
|
10382
|
-
.slice(toStringLeftSliceLength, toStringRightSliceLength);
|
|
10383
|
-
};
|
|
10384
|
-
|
|
10385
|
-
module.exports.typeDetect = module.exports;
|
|
10386
|
-
|
|
10387
|
-
},{}],37:[function(require,module,exports){
|
|
10222
|
+
},{"type-detect":39}],37:[function(require,module,exports){
|
|
10388
10223
|
'use strict';
|
|
10389
10224
|
|
|
10390
10225
|
/* !
|
|
@@ -10724,7 +10559,11 @@ module.exports = {
|
|
|
10724
10559
|
};
|
|
10725
10560
|
|
|
10726
10561
|
},{}],39:[function(require,module,exports){
|
|
10727
|
-
|
|
10562
|
+
(function (global, factory) {
|
|
10563
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
10564
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
10565
|
+
(global.typeDetect = factory());
|
|
10566
|
+
}(this, (function () { 'use strict';
|
|
10728
10567
|
|
|
10729
10568
|
/* !
|
|
10730
10569
|
* type-detect
|
|
@@ -10732,8 +10571,10 @@ module.exports = {
|
|
|
10732
10571
|
* MIT Licensed
|
|
10733
10572
|
*/
|
|
10734
10573
|
var promiseExists = typeof Promise === 'function';
|
|
10735
|
-
|
|
10736
|
-
|
|
10574
|
+
|
|
10575
|
+
/* eslint-disable no-undef */
|
|
10576
|
+
var globalObject = typeof self === 'object' ? self : global; // eslint-disable-line id-blacklist
|
|
10577
|
+
|
|
10737
10578
|
var symbolExists = typeof Symbol !== 'undefined';
|
|
10738
10579
|
var mapExists = typeof Map !== 'undefined';
|
|
10739
10580
|
var setExists = typeof Set !== 'undefined';
|
|
@@ -10762,7 +10603,7 @@ var toStringRightSliceLength = -1;
|
|
|
10762
10603
|
* @return {String} object type
|
|
10763
10604
|
* @api public
|
|
10764
10605
|
*/
|
|
10765
|
-
|
|
10606
|
+
function typeDetect(obj) {
|
|
10766
10607
|
/* ! Speed optimisation
|
|
10767
10608
|
* Pre:
|
|
10768
10609
|
* string literal x 3,039,035 ops/sec ±1.62% (78 runs sampled)
|
|
@@ -10825,7 +10666,9 @@ module.exports = function typeDetect(obj) {
|
|
|
10825
10666
|
return 'Array';
|
|
10826
10667
|
}
|
|
10827
10668
|
|
|
10828
|
-
|
|
10669
|
+
// Not caching existence of `window` and related properties due to potential
|
|
10670
|
+
// for `window` to be unset before tests in quasi-browser environments.
|
|
10671
|
+
if (typeof window === 'object' && window !== null) {
|
|
10829
10672
|
/* ! Spec Conformance
|
|
10830
10673
|
* (https://html.spec.whatwg.org/multipage/browsers.html#location)
|
|
10831
10674
|
* WhatWG HTML$7.7.3 - The `Location` interface
|
|
@@ -10833,7 +10676,7 @@ module.exports = function typeDetect(obj) {
|
|
|
10833
10676
|
* - IE <=11 === "[object Object]"
|
|
10834
10677
|
* - IE Edge <=13 === "[object Object]"
|
|
10835
10678
|
*/
|
|
10836
|
-
if (obj ===
|
|
10679
|
+
if (typeof window.location === 'object' && obj === window.location) {
|
|
10837
10680
|
return 'Location';
|
|
10838
10681
|
}
|
|
10839
10682
|
|
|
@@ -10856,70 +10699,78 @@ module.exports = function typeDetect(obj) {
|
|
|
10856
10699
|
* - IE 11 === "[object HTMLDocument]"
|
|
10857
10700
|
* - IE Edge <=13 === "[object HTMLDocument]"
|
|
10858
10701
|
*/
|
|
10859
|
-
if (obj ===
|
|
10702
|
+
if (typeof window.document === 'object' && obj === window.document) {
|
|
10860
10703
|
return 'Document';
|
|
10861
10704
|
}
|
|
10862
10705
|
|
|
10863
|
-
|
|
10864
|
-
|
|
10865
|
-
|
|
10866
|
-
|
|
10867
|
-
|
|
10868
|
-
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10706
|
+
if (typeof window.navigator === 'object') {
|
|
10707
|
+
/* ! Spec Conformance
|
|
10708
|
+
* (https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray)
|
|
10709
|
+
* WhatWG HTML$8.6.1.5 - Plugins - Interface MimeTypeArray
|
|
10710
|
+
* Test: `Object.prototype.toString.call(navigator.mimeTypes)``
|
|
10711
|
+
* - IE <=10 === "[object MSMimeTypesCollection]"
|
|
10712
|
+
*/
|
|
10713
|
+
if (typeof window.navigator.mimeTypes === 'object' &&
|
|
10714
|
+
obj === window.navigator.mimeTypes) {
|
|
10715
|
+
return 'MimeTypeArray';
|
|
10716
|
+
}
|
|
10872
10717
|
|
|
10873
|
-
|
|
10874
|
-
|
|
10875
|
-
|
|
10876
|
-
|
|
10877
|
-
|
|
10878
|
-
|
|
10879
|
-
|
|
10880
|
-
|
|
10718
|
+
/* ! Spec Conformance
|
|
10719
|
+
* (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
|
|
10720
|
+
* WhatWG HTML$8.6.1.5 - Plugins - Interface PluginArray
|
|
10721
|
+
* Test: `Object.prototype.toString.call(navigator.plugins)``
|
|
10722
|
+
* - IE <=10 === "[object MSPluginsCollection]"
|
|
10723
|
+
*/
|
|
10724
|
+
if (typeof window.navigator.plugins === 'object' &&
|
|
10725
|
+
obj === window.navigator.plugins) {
|
|
10726
|
+
return 'PluginArray';
|
|
10727
|
+
}
|
|
10881
10728
|
}
|
|
10882
10729
|
|
|
10883
|
-
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
|
|
10890
|
-
|
|
10891
|
-
|
|
10730
|
+
if ((typeof window.HTMLElement === 'function' ||
|
|
10731
|
+
typeof window.HTMLElement === 'object') &&
|
|
10732
|
+
obj instanceof window.HTMLElement) {
|
|
10733
|
+
/* ! Spec Conformance
|
|
10734
|
+
* (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
|
|
10735
|
+
* WhatWG HTML$4.4.4 - The `blockquote` element - Interface `HTMLQuoteElement`
|
|
10736
|
+
* Test: `Object.prototype.toString.call(document.createElement('blockquote'))``
|
|
10737
|
+
* - IE <=10 === "[object HTMLBlockElement]"
|
|
10738
|
+
*/
|
|
10739
|
+
if (obj.tagName === 'BLOCKQUOTE') {
|
|
10740
|
+
return 'HTMLQuoteElement';
|
|
10741
|
+
}
|
|
10892
10742
|
|
|
10893
|
-
|
|
10894
|
-
|
|
10895
|
-
|
|
10896
|
-
|
|
10897
|
-
|
|
10898
|
-
|
|
10899
|
-
|
|
10900
|
-
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
10743
|
+
/* ! Spec Conformance
|
|
10744
|
+
* (https://html.spec.whatwg.org/#htmltabledatacellelement)
|
|
10745
|
+
* WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableDataCellElement`
|
|
10746
|
+
* Note: Most browsers currently adher to the W3C DOM Level 2 spec
|
|
10747
|
+
* (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
|
|
10748
|
+
* which suggests that browsers should use HTMLTableCellElement for
|
|
10749
|
+
* both TD and TH elements. WhatWG separates these.
|
|
10750
|
+
* Test: Object.prototype.toString.call(document.createElement('td'))
|
|
10751
|
+
* - Chrome === "[object HTMLTableCellElement]"
|
|
10752
|
+
* - Firefox === "[object HTMLTableCellElement]"
|
|
10753
|
+
* - Safari === "[object HTMLTableCellElement]"
|
|
10754
|
+
*/
|
|
10755
|
+
if (obj.tagName === 'TD') {
|
|
10756
|
+
return 'HTMLTableDataCellElement';
|
|
10757
|
+
}
|
|
10908
10758
|
|
|
10909
|
-
|
|
10910
|
-
|
|
10911
|
-
|
|
10912
|
-
|
|
10913
|
-
|
|
10914
|
-
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
|
|
10918
|
-
|
|
10919
|
-
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
|
|
10759
|
+
/* ! Spec Conformance
|
|
10760
|
+
* (https://html.spec.whatwg.org/#htmltableheadercellelement)
|
|
10761
|
+
* WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableHeaderCellElement`
|
|
10762
|
+
* Note: Most browsers currently adher to the W3C DOM Level 2 spec
|
|
10763
|
+
* (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
|
|
10764
|
+
* which suggests that browsers should use HTMLTableCellElement for
|
|
10765
|
+
* both TD and TH elements. WhatWG separates these.
|
|
10766
|
+
* Test: Object.prototype.toString.call(document.createElement('th'))
|
|
10767
|
+
* - Chrome === "[object HTMLTableCellElement]"
|
|
10768
|
+
* - Firefox === "[object HTMLTableCellElement]"
|
|
10769
|
+
* - Safari === "[object HTMLTableCellElement]"
|
|
10770
|
+
*/
|
|
10771
|
+
if (obj.tagName === 'TH') {
|
|
10772
|
+
return 'HTMLTableHeaderCellElement';
|
|
10773
|
+
}
|
|
10923
10774
|
}
|
|
10924
10775
|
}
|
|
10925
10776
|
|
|
@@ -11091,9 +10942,11 @@ module.exports = function typeDetect(obj) {
|
|
|
11091
10942
|
.toString
|
|
11092
10943
|
.call(obj)
|
|
11093
10944
|
.slice(toStringLeftSliceLength, toStringRightSliceLength);
|
|
11094
|
-
}
|
|
10945
|
+
}
|
|
10946
|
+
|
|
10947
|
+
return typeDetect;
|
|
11095
10948
|
|
|
11096
|
-
|
|
10949
|
+
})));
|
|
11097
10950
|
|
|
11098
10951
|
},{}]},{},[1])(1)
|
|
11099
|
-
});
|
|
10952
|
+
});
|