chai 4.0.1 → 4.1.2
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/CODEOWNERS +1 -0
- package/LICENSE +1 -1
- package/chai.js +272 -604
- package/lib/chai/core/assertions.js +244 -122
- package/lib/chai/interface/assert.js +4 -4
- package/lib/chai/utils/addProperty.js +1 -1
- package/lib/chai/utils/expectTypes.js +3 -4
- package/lib/chai/utils/inspect.js +1 -1
- package/lib/chai.js +1 -1
- package/package.json +3 -3
package/chai.js
CHANGED
|
@@ -14,7 +14,7 @@ var used = [];
|
|
|
14
14
|
* Chai version
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
exports.version =
|
|
17
|
+
exports.version = '4.1.2';
|
|
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
|
-
},{"
|
|
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":22,"assertion-error":33}],3:[function(require,module,exports){
|
|
99
99
|
/*!
|
|
100
100
|
* chai
|
|
101
101
|
* http://chaijs.com
|
|
@@ -691,6 +691,16 @@ module.exports = function (chai, _) {
|
|
|
691
691
|
*
|
|
692
692
|
* expect({a: 1, b: 2, c: 3}).to.include({a: 1, b: 2});
|
|
693
693
|
*
|
|
694
|
+
* When the target is a Set or WeakSet, `.include` asserts that the given `val` is a
|
|
695
|
+
* member of the target. SameValueZero equality algorithm is used.
|
|
696
|
+
*
|
|
697
|
+
* expect(new Set([1, 2])).to.include(2);
|
|
698
|
+
*
|
|
699
|
+
* When the target is a Map, `.include` asserts that the given `val` is one of
|
|
700
|
+
* the values of the target. SameValueZero equality algorithm is used.
|
|
701
|
+
*
|
|
702
|
+
* expect(new Map([['a', 1], ['b', 2]])).to.include(2);
|
|
703
|
+
*
|
|
694
704
|
* Because `.include` does different things based on the target's type, it's
|
|
695
705
|
* important to check the target's type before using `.include`. See the `.a`
|
|
696
706
|
* doc for info on testing a target's type.
|
|
@@ -699,8 +709,8 @@ module.exports = function (chai, _) {
|
|
|
699
709
|
*
|
|
700
710
|
* By default, strict (`===`) equality is used to compare array members and
|
|
701
711
|
* object properties. Add `.deep` earlier in the chain to use deep equality
|
|
702
|
-
* instead. See the `deep-eql` project
|
|
703
|
-
* algorithm: https://github.com/chaijs/deep-eql.
|
|
712
|
+
* instead (WeakSet targets are not supported). See the `deep-eql` project
|
|
713
|
+
* page for info on the deep equality algorithm: https://github.com/chaijs/deep-eql.
|
|
704
714
|
*
|
|
705
715
|
* // Target array deeply (but not strictly) includes `{a: 1}`
|
|
706
716
|
* expect([{a: 1}]).to.deep.include({a: 1});
|
|
@@ -810,65 +820,124 @@ module.exports = function (chai, _) {
|
|
|
810
820
|
* @api public
|
|
811
821
|
*/
|
|
812
822
|
|
|
813
|
-
function
|
|
814
|
-
|
|
823
|
+
function SameValueZero(a, b) {
|
|
824
|
+
return (_.isNaN(a) && _.isNaN(b)) || a === b;
|
|
815
825
|
}
|
|
816
826
|
|
|
817
|
-
function
|
|
818
|
-
|
|
819
|
-
return _.eql(arrVal, val);
|
|
820
|
-
});
|
|
827
|
+
function includeChainingBehavior () {
|
|
828
|
+
flag(this, 'contains', true);
|
|
821
829
|
}
|
|
822
830
|
|
|
823
831
|
function include (val, msg) {
|
|
824
832
|
if (msg) flag(this, 'message', msg);
|
|
825
|
-
|
|
826
|
-
_.expectTypes(this, ['array', 'object', 'string'], flag(this, 'ssfi'));
|
|
827
|
-
|
|
833
|
+
|
|
828
834
|
var obj = flag(this, 'object')
|
|
829
835
|
, objType = _.type(obj).toLowerCase()
|
|
836
|
+
, flagMsg = flag(this, 'message')
|
|
837
|
+
, negate = flag(this, 'negate')
|
|
838
|
+
, ssfi = flag(this, 'ssfi')
|
|
830
839
|
, isDeep = flag(this, 'deep')
|
|
831
840
|
, descriptor = isDeep ? 'deep ' : '';
|
|
832
841
|
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
842
|
+
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
843
|
+
|
|
844
|
+
var included = false;
|
|
845
|
+
|
|
846
|
+
switch (objType) {
|
|
847
|
+
case 'string':
|
|
848
|
+
included = obj.indexOf(val) !== -1;
|
|
849
|
+
break;
|
|
850
|
+
|
|
851
|
+
case 'weakset':
|
|
852
|
+
if (isDeep) {
|
|
853
|
+
throw new AssertionError(
|
|
854
|
+
flagMsg + 'unable to use .deep.include with WeakSet',
|
|
855
|
+
undefined,
|
|
856
|
+
ssfi
|
|
857
|
+
);
|
|
848
858
|
}
|
|
849
859
|
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
860
|
+
included = obj.has(val);
|
|
861
|
+
break;
|
|
862
|
+
|
|
863
|
+
case 'map':
|
|
864
|
+
var isEql = isDeep ? _.eql : SameValueZero;
|
|
865
|
+
obj.forEach(function (item) {
|
|
866
|
+
included = included || isEql(item, val);
|
|
867
|
+
});
|
|
868
|
+
break;
|
|
869
|
+
|
|
870
|
+
case 'set':
|
|
871
|
+
if (isDeep) {
|
|
872
|
+
obj.forEach(function (item) {
|
|
873
|
+
included = included || _.eql(item, val);
|
|
874
|
+
});
|
|
875
|
+
} else {
|
|
876
|
+
included = obj.has(val);
|
|
856
877
|
}
|
|
857
|
-
|
|
878
|
+
break;
|
|
879
|
+
|
|
880
|
+
case 'array':
|
|
881
|
+
if (isDeep) {
|
|
882
|
+
included = obj.some(function (item) {
|
|
883
|
+
return _.eql(item, val);
|
|
884
|
+
})
|
|
885
|
+
} else {
|
|
886
|
+
included = obj.indexOf(val) !== -1;
|
|
887
|
+
}
|
|
888
|
+
break;
|
|
858
889
|
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
890
|
+
default:
|
|
891
|
+
// This block is for asserting a subset of properties in an object.
|
|
892
|
+
// `_.expectTypes` isn't used here because `.include` should work with
|
|
893
|
+
// objects with a custom `@@toStringTag`.
|
|
894
|
+
if (val !== Object(val)) {
|
|
895
|
+
throw new AssertionError(
|
|
896
|
+
flagMsg + 'object tested must be an array, a map, an object,'
|
|
897
|
+
+ ' a set, a string, or a weakset, but ' + objType + ' given',
|
|
898
|
+
undefined,
|
|
899
|
+
ssfi
|
|
900
|
+
);
|
|
901
|
+
}
|
|
864
902
|
|
|
865
|
-
|
|
903
|
+
var props = Object.keys(val)
|
|
904
|
+
, firstErr = null
|
|
905
|
+
, numErrs = 0;
|
|
906
|
+
|
|
907
|
+
props.forEach(function (prop) {
|
|
908
|
+
var propAssertion = new Assertion(obj);
|
|
909
|
+
_.transferFlags(this, propAssertion, true);
|
|
910
|
+
flag(propAssertion, 'lockSsfi', true);
|
|
911
|
+
|
|
912
|
+
if (!negate || props.length === 1) {
|
|
913
|
+
propAssertion.property(prop, val[prop]);
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
try {
|
|
918
|
+
propAssertion.property(prop, val[prop]);
|
|
919
|
+
} catch (err) {
|
|
920
|
+
if (!_.checkError.compatibleConstructor(err, AssertionError)) {
|
|
921
|
+
throw err;
|
|
922
|
+
}
|
|
923
|
+
if (firstErr === null) firstErr = err;
|
|
924
|
+
numErrs++;
|
|
925
|
+
}
|
|
926
|
+
}, this);
|
|
927
|
+
|
|
928
|
+
// When validating .not.include with multiple properties, we only want
|
|
929
|
+
// to throw an assertion error if all of the properties are included,
|
|
930
|
+
// in which case we throw the first property assertion error that we
|
|
931
|
+
// encountered.
|
|
932
|
+
if (negate && props.length > 1 && numErrs === props.length) {
|
|
933
|
+
throw firstErr;
|
|
934
|
+
}
|
|
935
|
+
return;
|
|
866
936
|
}
|
|
867
937
|
|
|
868
|
-
// Assert inclusion in
|
|
938
|
+
// Assert inclusion in collection or substring in a string.
|
|
869
939
|
this.assert(
|
|
870
|
-
|
|
871
|
-
: isDeepIncluded(obj, val)
|
|
940
|
+
included
|
|
872
941
|
, 'expected #{this} to ' + descriptor + 'include ' + _.inspect(val)
|
|
873
942
|
, 'expected #{this} to not ' + descriptor + 'include ' + _.inspect(val));
|
|
874
943
|
}
|
|
@@ -1385,7 +1454,7 @@ module.exports = function (chai, _) {
|
|
|
1385
1454
|
/**
|
|
1386
1455
|
* ### .above(n[, msg])
|
|
1387
1456
|
*
|
|
1388
|
-
* Asserts that the target is a number greater than the given number `n
|
|
1457
|
+
* Asserts that the target is a number or a date greater than the given number or date `n` respectively.
|
|
1389
1458
|
* However, it's often best to assert that the target is equal to its expected
|
|
1390
1459
|
* value.
|
|
1391
1460
|
*
|
|
@@ -1430,21 +1499,29 @@ module.exports = function (chai, _) {
|
|
|
1430
1499
|
var obj = flag(this, 'object')
|
|
1431
1500
|
, doLength = flag(this, 'doLength')
|
|
1432
1501
|
, flagMsg = flag(this, 'message')
|
|
1433
|
-
,
|
|
1502
|
+
, msgPrefix = ((flagMsg) ? flagMsg + ': ' : '')
|
|
1503
|
+
, ssfi = flag(this, 'ssfi')
|
|
1504
|
+
, objType = _.type(obj).toLowerCase()
|
|
1505
|
+
, nType = _.type(n).toLowerCase()
|
|
1506
|
+
, shouldThrow = true;
|
|
1434
1507
|
|
|
1435
1508
|
if (doLength) {
|
|
1436
1509
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
if (!doLength && (objType === 'date' && nType !== 'date')) {
|
|
1513
|
+
errorMessage = msgPrefix + 'the argument to above must be a date';
|
|
1514
|
+
} else if (nType !== 'number' && (doLength || objType === 'number')) {
|
|
1515
|
+
errorMessage = msgPrefix + 'the argument to above must be a number';
|
|
1516
|
+
} else if (!doLength && (objType !== 'date' && objType !== 'number')) {
|
|
1517
|
+
var printObj = (objType === 'string') ? "'" + obj + "'" : obj;
|
|
1518
|
+
errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date';
|
|
1437
1519
|
} else {
|
|
1438
|
-
|
|
1520
|
+
shouldThrow = false;
|
|
1439
1521
|
}
|
|
1440
1522
|
|
|
1441
|
-
if (
|
|
1442
|
-
|
|
1443
|
-
throw new AssertionError(
|
|
1444
|
-
flagMsg + 'the argument to above must be a number',
|
|
1445
|
-
undefined,
|
|
1446
|
-
ssfi
|
|
1447
|
-
);
|
|
1523
|
+
if (shouldThrow) {
|
|
1524
|
+
throw new AssertionError(errorMessage, undefined, ssfi);
|
|
1448
1525
|
}
|
|
1449
1526
|
|
|
1450
1527
|
if (doLength) {
|
|
@@ -1459,8 +1536,9 @@ module.exports = function (chai, _) {
|
|
|
1459
1536
|
} else {
|
|
1460
1537
|
this.assert(
|
|
1461
1538
|
obj > n
|
|
1462
|
-
, 'expected #{this} to be above '
|
|
1463
|
-
, 'expected #{this} to be at most '
|
|
1539
|
+
, 'expected #{this} to be above #{exp}'
|
|
1540
|
+
, 'expected #{this} to be at most #{exp}'
|
|
1541
|
+
, n
|
|
1464
1542
|
);
|
|
1465
1543
|
}
|
|
1466
1544
|
}
|
|
@@ -1472,8 +1550,8 @@ module.exports = function (chai, _) {
|
|
|
1472
1550
|
/**
|
|
1473
1551
|
* ### .least(n[, msg])
|
|
1474
1552
|
*
|
|
1475
|
-
* Asserts that the target is a number greater than or equal to the given
|
|
1476
|
-
* number `n
|
|
1553
|
+
* Asserts that the target is a number or a date greater than or equal to the given
|
|
1554
|
+
* number or date `n` respectively. However, it's often best to assert that the target is equal to
|
|
1477
1555
|
* its expected value.
|
|
1478
1556
|
*
|
|
1479
1557
|
* expect(2).to.equal(2); // Recommended
|
|
@@ -1517,21 +1595,29 @@ module.exports = function (chai, _) {
|
|
|
1517
1595
|
var obj = flag(this, 'object')
|
|
1518
1596
|
, doLength = flag(this, 'doLength')
|
|
1519
1597
|
, flagMsg = flag(this, 'message')
|
|
1520
|
-
,
|
|
1598
|
+
, msgPrefix = ((flagMsg) ? flagMsg + ': ' : '')
|
|
1599
|
+
, ssfi = flag(this, 'ssfi')
|
|
1600
|
+
, objType = _.type(obj).toLowerCase()
|
|
1601
|
+
, nType = _.type(n).toLowerCase()
|
|
1602
|
+
, shouldThrow = true;
|
|
1521
1603
|
|
|
1522
1604
|
if (doLength) {
|
|
1523
1605
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
if (!doLength && (objType === 'date' && nType !== 'date')) {
|
|
1609
|
+
errorMessage = msgPrefix + 'the argument to least must be a date';
|
|
1610
|
+
} else if (nType !== 'number' && (doLength || objType === 'number')) {
|
|
1611
|
+
errorMessage = msgPrefix + 'the argument to least must be a number';
|
|
1612
|
+
} else if (!doLength && (objType !== 'date' && objType !== 'number')) {
|
|
1613
|
+
var printObj = (objType === 'string') ? "'" + obj + "'" : obj;
|
|
1614
|
+
errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date';
|
|
1524
1615
|
} else {
|
|
1525
|
-
|
|
1616
|
+
shouldThrow = false;
|
|
1526
1617
|
}
|
|
1527
1618
|
|
|
1528
|
-
if (
|
|
1529
|
-
|
|
1530
|
-
throw new AssertionError(
|
|
1531
|
-
flagMsg + 'the argument to least must be a number',
|
|
1532
|
-
undefined,
|
|
1533
|
-
ssfi
|
|
1534
|
-
);
|
|
1619
|
+
if (shouldThrow) {
|
|
1620
|
+
throw new AssertionError(errorMessage, undefined, ssfi);
|
|
1535
1621
|
}
|
|
1536
1622
|
|
|
1537
1623
|
if (doLength) {
|
|
@@ -1546,8 +1632,9 @@ module.exports = function (chai, _) {
|
|
|
1546
1632
|
} else {
|
|
1547
1633
|
this.assert(
|
|
1548
1634
|
obj >= n
|
|
1549
|
-
, 'expected #{this} to be at least '
|
|
1550
|
-
, 'expected #{this} to be below '
|
|
1635
|
+
, 'expected #{this} to be at least #{exp}'
|
|
1636
|
+
, 'expected #{this} to be below #{exp}'
|
|
1637
|
+
, n
|
|
1551
1638
|
);
|
|
1552
1639
|
}
|
|
1553
1640
|
}
|
|
@@ -1558,7 +1645,7 @@ module.exports = function (chai, _) {
|
|
|
1558
1645
|
/**
|
|
1559
1646
|
* ### .below(n[, msg])
|
|
1560
1647
|
*
|
|
1561
|
-
* Asserts that the target is a number less than the given number `n
|
|
1648
|
+
* Asserts that the target is a number or a date less than the given number or date `n` respectively.
|
|
1562
1649
|
* However, it's often best to assert that the target is equal to its expected
|
|
1563
1650
|
* value.
|
|
1564
1651
|
*
|
|
@@ -1603,21 +1690,29 @@ module.exports = function (chai, _) {
|
|
|
1603
1690
|
var obj = flag(this, 'object')
|
|
1604
1691
|
, doLength = flag(this, 'doLength')
|
|
1605
1692
|
, flagMsg = flag(this, 'message')
|
|
1606
|
-
,
|
|
1693
|
+
, msgPrefix = ((flagMsg) ? flagMsg + ': ' : '')
|
|
1694
|
+
, ssfi = flag(this, 'ssfi')
|
|
1695
|
+
, objType = _.type(obj).toLowerCase()
|
|
1696
|
+
, nType = _.type(n).toLowerCase()
|
|
1697
|
+
, shouldThrow = true;
|
|
1607
1698
|
|
|
1608
1699
|
if (doLength) {
|
|
1609
1700
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
if (!doLength && (objType === 'date' && nType !== 'date')) {
|
|
1704
|
+
errorMessage = msgPrefix + 'the argument to below must be a date';
|
|
1705
|
+
} else if (nType !== 'number' && (doLength || objType === 'number')) {
|
|
1706
|
+
errorMessage = msgPrefix + 'the argument to below must be a number';
|
|
1707
|
+
} else if (!doLength && (objType !== 'date' && objType !== 'number')) {
|
|
1708
|
+
var printObj = (objType === 'string') ? "'" + obj + "'" : obj;
|
|
1709
|
+
errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date';
|
|
1610
1710
|
} else {
|
|
1611
|
-
|
|
1711
|
+
shouldThrow = false;
|
|
1612
1712
|
}
|
|
1613
1713
|
|
|
1614
|
-
if (
|
|
1615
|
-
|
|
1616
|
-
throw new AssertionError(
|
|
1617
|
-
flagMsg + 'the argument to below must be a number',
|
|
1618
|
-
undefined,
|
|
1619
|
-
ssfi
|
|
1620
|
-
);
|
|
1714
|
+
if (shouldThrow) {
|
|
1715
|
+
throw new AssertionError(errorMessage, undefined, ssfi);
|
|
1621
1716
|
}
|
|
1622
1717
|
|
|
1623
1718
|
if (doLength) {
|
|
@@ -1632,8 +1727,9 @@ module.exports = function (chai, _) {
|
|
|
1632
1727
|
} else {
|
|
1633
1728
|
this.assert(
|
|
1634
1729
|
obj < n
|
|
1635
|
-
, 'expected #{this} to be below '
|
|
1636
|
-
, 'expected #{this} to be at least '
|
|
1730
|
+
, 'expected #{this} to be below #{exp}'
|
|
1731
|
+
, 'expected #{this} to be at least #{exp}'
|
|
1732
|
+
, n
|
|
1637
1733
|
);
|
|
1638
1734
|
}
|
|
1639
1735
|
}
|
|
@@ -1645,8 +1741,8 @@ module.exports = function (chai, _) {
|
|
|
1645
1741
|
/**
|
|
1646
1742
|
* ### .most(n[, msg])
|
|
1647
1743
|
*
|
|
1648
|
-
* Asserts that the target is a number less than or equal to the given number
|
|
1649
|
-
* `n
|
|
1744
|
+
* Asserts that the target is a number or a date less than or equal to the given number
|
|
1745
|
+
* or date `n` respectively. However, it's often best to assert that the target is equal to its
|
|
1650
1746
|
* expected value.
|
|
1651
1747
|
*
|
|
1652
1748
|
* expect(1).to.equal(1); // Recommended
|
|
@@ -1689,21 +1785,29 @@ module.exports = function (chai, _) {
|
|
|
1689
1785
|
var obj = flag(this, 'object')
|
|
1690
1786
|
, doLength = flag(this, 'doLength')
|
|
1691
1787
|
, flagMsg = flag(this, 'message')
|
|
1692
|
-
,
|
|
1788
|
+
, msgPrefix = ((flagMsg) ? flagMsg + ': ' : '')
|
|
1789
|
+
, ssfi = flag(this, 'ssfi')
|
|
1790
|
+
, objType = _.type(obj).toLowerCase()
|
|
1791
|
+
, nType = _.type(n).toLowerCase()
|
|
1792
|
+
, shouldThrow = true;
|
|
1693
1793
|
|
|
1694
1794
|
if (doLength) {
|
|
1695
1795
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
if (!doLength && (objType === 'date' && nType !== 'date')) {
|
|
1799
|
+
errorMessage = msgPrefix + 'the argument to most must be a date';
|
|
1800
|
+
} else if (nType !== 'number' && (doLength || objType === 'number')) {
|
|
1801
|
+
errorMessage = msgPrefix + 'the argument to most must be a number';
|
|
1802
|
+
} else if (!doLength && (objType !== 'date' && objType !== 'number')) {
|
|
1803
|
+
var printObj = (objType === 'string') ? "'" + obj + "'" : obj;
|
|
1804
|
+
errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date';
|
|
1696
1805
|
} else {
|
|
1697
|
-
|
|
1806
|
+
shouldThrow = false;
|
|
1698
1807
|
}
|
|
1699
1808
|
|
|
1700
|
-
if (
|
|
1701
|
-
|
|
1702
|
-
throw new AssertionError(
|
|
1703
|
-
flagMsg + 'the argument to most must be a number',
|
|
1704
|
-
undefined,
|
|
1705
|
-
ssfi
|
|
1706
|
-
);
|
|
1809
|
+
if (shouldThrow) {
|
|
1810
|
+
throw new AssertionError(errorMessage, undefined, ssfi);
|
|
1707
1811
|
}
|
|
1708
1812
|
|
|
1709
1813
|
if (doLength) {
|
|
@@ -1718,8 +1822,9 @@ module.exports = function (chai, _) {
|
|
|
1718
1822
|
} else {
|
|
1719
1823
|
this.assert(
|
|
1720
1824
|
obj <= n
|
|
1721
|
-
, 'expected #{this} to be at most '
|
|
1722
|
-
, 'expected #{this} to be above '
|
|
1825
|
+
, 'expected #{this} to be at most #{exp}'
|
|
1826
|
+
, 'expected #{this} to be above #{exp}'
|
|
1827
|
+
, n
|
|
1723
1828
|
);
|
|
1724
1829
|
}
|
|
1725
1830
|
}
|
|
@@ -1730,8 +1835,8 @@ module.exports = function (chai, _) {
|
|
|
1730
1835
|
/**
|
|
1731
1836
|
* ### .within(start, finish[, msg])
|
|
1732
1837
|
*
|
|
1733
|
-
* Asserts that the target is a number greater than or equal to the given
|
|
1734
|
-
* number `start`, and less than or equal to the given number `finish
|
|
1838
|
+
* Asserts that the target is a number or a date greater than or equal to the given
|
|
1839
|
+
* number or date `start`, and less than or equal to the given number or date `finish` respectively.
|
|
1735
1840
|
* However, it's often best to assert that the target is equal to its expected
|
|
1736
1841
|
* value.
|
|
1737
1842
|
*
|
|
@@ -1773,24 +1878,35 @@ module.exports = function (chai, _) {
|
|
|
1773
1878
|
Assertion.addMethod('within', function (start, finish, msg) {
|
|
1774
1879
|
if (msg) flag(this, 'message', msg);
|
|
1775
1880
|
var obj = flag(this, 'object')
|
|
1776
|
-
, range = start + '..' + finish
|
|
1777
1881
|
, doLength = flag(this, 'doLength')
|
|
1778
1882
|
, flagMsg = flag(this, 'message')
|
|
1779
|
-
,
|
|
1883
|
+
, msgPrefix = ((flagMsg) ? flagMsg + ': ' : '')
|
|
1884
|
+
, ssfi = flag(this, 'ssfi')
|
|
1885
|
+
, objType = _.type(obj).toLowerCase()
|
|
1886
|
+
, startType = _.type(start).toLowerCase()
|
|
1887
|
+
, finishType = _.type(finish).toLowerCase()
|
|
1888
|
+
, shouldThrow = true
|
|
1889
|
+
, range = (startType === 'date' && finishType === 'date')
|
|
1890
|
+
? start.toUTCString() + '..' + finish.toUTCString()
|
|
1891
|
+
: start + '..' + finish;
|
|
1780
1892
|
|
|
1781
1893
|
if (doLength) {
|
|
1782
1894
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
if (!doLength && (objType === 'date' && (startType !== 'date' || finishType !== 'date'))) {
|
|
1898
|
+
errorMessage = msgPrefix + 'the arguments to within must be dates';
|
|
1899
|
+
} else if ((startType !== 'number' || finishType !== 'number') && (doLength || objType === 'number')) {
|
|
1900
|
+
errorMessage = msgPrefix + 'the arguments to within must be numbers';
|
|
1901
|
+
} else if (!doLength && (objType !== 'date' && objType !== 'number')) {
|
|
1902
|
+
var printObj = (objType === 'string') ? "'" + obj + "'" : obj;
|
|
1903
|
+
errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date';
|
|
1783
1904
|
} else {
|
|
1784
|
-
|
|
1905
|
+
shouldThrow = false;
|
|
1785
1906
|
}
|
|
1786
1907
|
|
|
1787
|
-
if (
|
|
1788
|
-
|
|
1789
|
-
throw new AssertionError(
|
|
1790
|
-
flagMsg + 'the arguments to within must be numbers',
|
|
1791
|
-
undefined,
|
|
1792
|
-
ssfi
|
|
1793
|
-
);
|
|
1908
|
+
if (shouldThrow) {
|
|
1909
|
+
throw new AssertionError(errorMessage, undefined, ssfi);
|
|
1794
1910
|
}
|
|
1795
1911
|
|
|
1796
1912
|
if (doLength) {
|
|
@@ -1854,28 +1970,25 @@ module.exports = function (chai, _) {
|
|
|
1854
1970
|
var target = flag(this, 'object')
|
|
1855
1971
|
var ssfi = flag(this, 'ssfi');
|
|
1856
1972
|
var flagMsg = flag(this, 'message');
|
|
1857
|
-
var validInstanceOfTarget = constructor === Object(constructor) && (
|
|
1858
|
-
typeof constructor === 'function' ||
|
|
1859
|
-
(typeof Symbol !== 'undefined' &&
|
|
1860
|
-
typeof Symbol.hasInstance !== 'undefined' &&
|
|
1861
|
-
Symbol.hasInstance in constructor)
|
|
1862
|
-
);
|
|
1863
1973
|
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
flagMsg
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1974
|
+
try {
|
|
1975
|
+
var isInstanceOf = target instanceof constructor;
|
|
1976
|
+
} catch (err) {
|
|
1977
|
+
if (err instanceof TypeError) {
|
|
1978
|
+
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
1979
|
+
throw new AssertionError(
|
|
1980
|
+
flagMsg + 'The instanceof assertion needs a constructor but '
|
|
1981
|
+
+ _.type(constructor) + ' was given.',
|
|
1982
|
+
undefined,
|
|
1983
|
+
ssfi
|
|
1984
|
+
);
|
|
1985
|
+
}
|
|
1986
|
+
throw err;
|
|
1872
1987
|
}
|
|
1873
1988
|
|
|
1874
|
-
var isInstanceOf = target instanceof constructor
|
|
1875
|
-
|
|
1876
1989
|
var name = _.getName(constructor);
|
|
1877
1990
|
if (name === null) {
|
|
1878
|
-
|
|
1991
|
+
name = 'an unnamed constructor';
|
|
1879
1992
|
}
|
|
1880
1993
|
|
|
1881
1994
|
this.assert(
|
|
@@ -2005,6 +2118,7 @@ module.exports = function (chai, _) {
|
|
|
2005
2118
|
var isNested = flag(this, 'nested')
|
|
2006
2119
|
, isOwn = flag(this, 'own')
|
|
2007
2120
|
, flagMsg = flag(this, 'message')
|
|
2121
|
+
, obj = flag(this, 'object')
|
|
2008
2122
|
, ssfi = flag(this, 'ssfi');
|
|
2009
2123
|
|
|
2010
2124
|
if (isNested && isOwn) {
|
|
@@ -2016,9 +2130,17 @@ module.exports = function (chai, _) {
|
|
|
2016
2130
|
);
|
|
2017
2131
|
}
|
|
2018
2132
|
|
|
2133
|
+
if (obj === null || obj === undefined) {
|
|
2134
|
+
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
2135
|
+
throw new AssertionError(
|
|
2136
|
+
flagMsg + 'Target cannot be null or undefined.',
|
|
2137
|
+
undefined,
|
|
2138
|
+
ssfi
|
|
2139
|
+
);
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2019
2142
|
var isDeep = flag(this, 'deep')
|
|
2020
2143
|
, negate = flag(this, 'negate')
|
|
2021
|
-
, obj = flag(this, 'object')
|
|
2022
2144
|
, pathInfo = isNested ? _.getPathInfo(obj, name) : null
|
|
2023
2145
|
, value = isNested ? pathInfo.value : obj[name];
|
|
2024
2146
|
|
|
@@ -5645,10 +5767,10 @@ module.exports = function (chai, util) {
|
|
|
5645
5767
|
* You can also provide a single object instead of a `keys` array and its keys
|
|
5646
5768
|
* will be used as the expected set of keys.
|
|
5647
5769
|
*
|
|
5648
|
-
* assert.
|
|
5649
|
-
* assert.
|
|
5650
|
-
* assert.
|
|
5651
|
-
* assert.
|
|
5770
|
+
* assert.hasAnyKeys({foo: 1, bar: 2, baz: 3}, ['foo', 'iDontExist', 'baz']);
|
|
5771
|
+
* assert.hasAnyKeys({foo: 1, bar: 2, baz: 3}, {foo: 30, iDontExist: 99, baz: 1337});
|
|
5772
|
+
* assert.hasAnyKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}, 'key']);
|
|
5773
|
+
* assert.hasAnyKeys(new Set([{foo: 'bar'}, 'anotherKey']), [{foo: 'bar'}, 'anotherKey']);
|
|
5652
5774
|
*
|
|
5653
5775
|
* @name hasAnyKeys
|
|
5654
5776
|
* @param {Mixed} object
|
|
@@ -7636,7 +7758,7 @@ var transferFlags = require('./transferFlags');
|
|
|
7636
7758
|
*/
|
|
7637
7759
|
|
|
7638
7760
|
module.exports = function addProperty(ctx, name, getter) {
|
|
7639
|
-
getter = getter === undefined ?
|
|
7761
|
+
getter = getter === undefined ? function () {} : getter;
|
|
7640
7762
|
|
|
7641
7763
|
Object.defineProperty(ctx, name,
|
|
7642
7764
|
{ get: function propertyGetter() {
|
|
@@ -7720,8 +7842,6 @@ module.exports = function compareByInspect(a, b) {
|
|
|
7720
7842
|
*
|
|
7721
7843
|
* @param {Mixed} obj constructed Assertion
|
|
7722
7844
|
* @param {Array} type A list of allowed types for this assertion
|
|
7723
|
-
* @param {Function} ssfi starting point for removing implementation frames from
|
|
7724
|
-
* stack trace of AssertionError
|
|
7725
7845
|
* @namespace Utils
|
|
7726
7846
|
* @name expectTypes
|
|
7727
7847
|
* @api public
|
|
@@ -7731,8 +7851,9 @@ var AssertionError = require('assertion-error');
|
|
|
7731
7851
|
var flag = require('./flag');
|
|
7732
7852
|
var type = require('type-detect');
|
|
7733
7853
|
|
|
7734
|
-
module.exports = function expectTypes(obj, types
|
|
7854
|
+
module.exports = function expectTypes(obj, types) {
|
|
7735
7855
|
var flagMsg = flag(obj, 'message');
|
|
7856
|
+
var ssfi = flag(obj, 'ssfi');
|
|
7736
7857
|
|
|
7737
7858
|
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
7738
7859
|
|
|
@@ -7740,7 +7861,7 @@ module.exports = function expectTypes(obj, types, ssfi) {
|
|
|
7740
7861
|
types = types.map(function (t) { return t.toLowerCase(); });
|
|
7741
7862
|
types.sort();
|
|
7742
7863
|
|
|
7743
|
-
// Transforms ['lorem', 'ipsum'] into 'a
|
|
7864
|
+
// Transforms ['lorem', 'ipsum'] into 'a lorem, or an ipsum'
|
|
7744
7865
|
var str = types.map(function (t, index) {
|
|
7745
7866
|
var art = ~[ 'a', 'e', 'i', 'o', 'u' ].indexOf(t.charAt(0)) ? 'an' : 'a';
|
|
7746
7867
|
var or = types.length > 1 && index === types.length - 1 ? 'or ' : '';
|
|
@@ -7758,7 +7879,7 @@ module.exports = function expectTypes(obj, types, ssfi) {
|
|
|
7758
7879
|
}
|
|
7759
7880
|
};
|
|
7760
7881
|
|
|
7761
|
-
},{"./flag":15,"assertion-error":33,"type-detect":
|
|
7882
|
+
},{"./flag":15,"assertion-error":33,"type-detect":38}],15:[function(require,module,exports){
|
|
7762
7883
|
/*!
|
|
7763
7884
|
* Chai - flag utility
|
|
7764
7885
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8168,7 +8289,7 @@ exports.isProxyEnabled = require('./isProxyEnabled');
|
|
|
8168
8289
|
|
|
8169
8290
|
exports.isNaN = require('./isNaN');
|
|
8170
8291
|
|
|
8171
|
-
},{"./addChainableMethod":9,"./addLengthGuard":10,"./addMethod":11,"./addProperty":12,"./compareByInspect":13,"./expectTypes":14,"./flag":15,"./getActual":16,"./getMessage":18,"./getOwnEnumerableProperties":19,"./getOwnEnumerablePropertySymbols":20,"./inspect":23,"./isNaN":24,"./isProxyEnabled":25,"./objDisplay":26,"./overwriteChainableMethod":27,"./overwriteMethod":28,"./overwriteProperty":29,"./proxify":30,"./test":31,"./transferFlags":32,"check-error":34,"deep-eql":35,"get-func-name":
|
|
8292
|
+
},{"./addChainableMethod":9,"./addLengthGuard":10,"./addMethod":11,"./addProperty":12,"./compareByInspect":13,"./expectTypes":14,"./flag":15,"./getActual":16,"./getMessage":18,"./getOwnEnumerableProperties":19,"./getOwnEnumerablePropertySymbols":20,"./inspect":23,"./isNaN":24,"./isProxyEnabled":25,"./objDisplay":26,"./overwriteChainableMethod":27,"./overwriteMethod":28,"./overwriteProperty":29,"./proxify":30,"./test":31,"./transferFlags":32,"check-error":34,"deep-eql":35,"get-func-name":36,"pathval":37,"type-detect":38}],23:[function(require,module,exports){
|
|
8172
8293
|
// This is (almost) directly from Node.js utils
|
|
8173
8294
|
// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js
|
|
8174
8295
|
|
|
@@ -8257,7 +8378,7 @@ function formatValue(ctx, value, recurseTimes) {
|
|
|
8257
8378
|
var container = document.createElementNS(ns, '_');
|
|
8258
8379
|
|
|
8259
8380
|
container.appendChild(value.cloneNode(false));
|
|
8260
|
-
html = container.innerHTML
|
|
8381
|
+
var html = container.innerHTML
|
|
8261
8382
|
.replace('><', '>' + value.innerHTML + '<');
|
|
8262
8383
|
container.innerHTML = '';
|
|
8263
8384
|
return html;
|
|
@@ -8553,7 +8674,7 @@ function objectToString(o) {
|
|
|
8553
8674
|
return Object.prototype.toString.call(o);
|
|
8554
8675
|
}
|
|
8555
8676
|
|
|
8556
|
-
},{"../config":4,"./getEnumerableProperties":17,"./getProperties":21,"get-func-name":
|
|
8677
|
+
},{"../config":4,"./getEnumerableProperties":17,"./getProperties":21,"get-func-name":36}],24:[function(require,module,exports){
|
|
8557
8678
|
/*!
|
|
8558
8679
|
* Chai - isNaN utility
|
|
8559
8680
|
* Copyright(c) 2012-2015 Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
|
|
@@ -9416,57 +9537,33 @@ module.exports = {
|
|
|
9416
9537
|
|
|
9417
9538
|
},{}],35:[function(require,module,exports){
|
|
9418
9539
|
'use strict';
|
|
9419
|
-
/* globals Symbol:
|
|
9540
|
+
/* globals Symbol: false, Uint8Array: false, WeakMap: false */
|
|
9420
9541
|
/*!
|
|
9421
9542
|
* deep-eql
|
|
9422
9543
|
* Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
|
|
9423
9544
|
* MIT Licensed
|
|
9424
9545
|
*/
|
|
9425
9546
|
|
|
9426
|
-
/*!
|
|
9427
|
-
* Module dependencies
|
|
9428
|
-
*/
|
|
9429
|
-
|
|
9430
9547
|
var type = require('type-detect');
|
|
9431
9548
|
function FakeMap() {
|
|
9432
|
-
this.
|
|
9549
|
+
this._key = 'chai/deep-eql__' + Math.random() + Date.now();
|
|
9433
9550
|
}
|
|
9551
|
+
|
|
9434
9552
|
FakeMap.prototype = {
|
|
9435
|
-
clear: function clearMap() {
|
|
9436
|
-
this.keys = [];
|
|
9437
|
-
this.values = [];
|
|
9438
|
-
return this;
|
|
9439
|
-
},
|
|
9440
|
-
set: function setMap(key, value) {
|
|
9441
|
-
var index = this.keys.indexOf(key);
|
|
9442
|
-
if (index >= 0) {
|
|
9443
|
-
this.values[index] = value;
|
|
9444
|
-
} else {
|
|
9445
|
-
this.keys.push(key);
|
|
9446
|
-
this.values.push(value);
|
|
9447
|
-
}
|
|
9448
|
-
return this;
|
|
9449
|
-
},
|
|
9450
9553
|
get: function getMap(key) {
|
|
9451
|
-
return
|
|
9554
|
+
return key[this._key];
|
|
9452
9555
|
},
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
9556
|
+
set: function setMap(key, value) {
|
|
9557
|
+
if (!Object.isFrozen(key)) {
|
|
9558
|
+
Object.defineProperty(key, this._key, {
|
|
9559
|
+
value: value,
|
|
9560
|
+
configurable: true,
|
|
9561
|
+
});
|
|
9458
9562
|
}
|
|
9459
|
-
return this;
|
|
9460
9563
|
},
|
|
9461
9564
|
};
|
|
9462
9565
|
|
|
9463
|
-
var MemoizeMap =
|
|
9464
|
-
if (typeof WeakMap === 'function') {
|
|
9465
|
-
MemoizeMap = WeakMap;
|
|
9466
|
-
} else {
|
|
9467
|
-
MemoizeMap = FakeMap;
|
|
9468
|
-
}
|
|
9469
|
-
|
|
9566
|
+
var MemoizeMap = typeof WeakMap === 'function' ? WeakMap : FakeMap;
|
|
9470
9567
|
/*!
|
|
9471
9568
|
* Check to see if the MemoizeMap has recorded a result of the two operands
|
|
9472
9569
|
*
|
|
@@ -9895,380 +9992,7 @@ function isPrimitive(value) {
|
|
|
9895
9992
|
return value === null || typeof value !== 'object';
|
|
9896
9993
|
}
|
|
9897
9994
|
|
|
9898
|
-
},{"type-detect":
|
|
9899
|
-
'use strict';
|
|
9900
|
-
/* !
|
|
9901
|
-
* type-detect
|
|
9902
|
-
* Copyright(c) 2013 jake luer <jake@alogicalparadox.com>
|
|
9903
|
-
* MIT Licensed
|
|
9904
|
-
*/
|
|
9905
|
-
var getPrototypeOfExists = typeof Object.getPrototypeOf === 'function';
|
|
9906
|
-
var promiseExists = typeof Promise === 'function';
|
|
9907
|
-
var globalObject = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : self; // eslint-disable-line
|
|
9908
|
-
var isDom = 'location' in globalObject && 'document' in globalObject;
|
|
9909
|
-
var htmlElementExists = typeof HTMLElement !== 'undefined';
|
|
9910
|
-
var isArrayExists = typeof Array.isArray === 'function';
|
|
9911
|
-
var symbolExists = typeof Symbol !== 'undefined';
|
|
9912
|
-
var mapExists = typeof Map !== 'undefined';
|
|
9913
|
-
var setExists = typeof Set !== 'undefined';
|
|
9914
|
-
var weakMapExists = typeof WeakMap !== 'undefined';
|
|
9915
|
-
var weakSetExists = typeof WeakSet !== 'undefined';
|
|
9916
|
-
var dataViewExists = typeof DataView !== 'undefined';
|
|
9917
|
-
var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== 'undefined';
|
|
9918
|
-
var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== 'undefined';
|
|
9919
|
-
var setEntriesExists = setExists && typeof Set.prototype.entries === 'function';
|
|
9920
|
-
var mapEntriesExists = mapExists && typeof Map.prototype.entries === 'function';
|
|
9921
|
-
var setIteratorPrototype = getPrototypeOfExists && setEntriesExists && Object.getPrototypeOf(new Set().entries());
|
|
9922
|
-
var mapIteratorPrototype = getPrototypeOfExists && mapEntriesExists && Object.getPrototypeOf(new Map().entries());
|
|
9923
|
-
var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function';
|
|
9924
|
-
var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
|
|
9925
|
-
var stringIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function';
|
|
9926
|
-
var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(''[Symbol.iterator]());
|
|
9927
|
-
var toStringLeftSliceLength = 8;
|
|
9928
|
-
var toStringRightSliceLength = -1;
|
|
9929
|
-
/**
|
|
9930
|
-
* ### typeOf (obj)
|
|
9931
|
-
*
|
|
9932
|
-
* Uses `Object.prototype.toString` to determine the type of an object,
|
|
9933
|
-
* normalising behaviour across engine versions & well optimised.
|
|
9934
|
-
*
|
|
9935
|
-
* @param {Mixed} object
|
|
9936
|
-
* @return {String} object type
|
|
9937
|
-
* @api public
|
|
9938
|
-
*/
|
|
9939
|
-
module.exports = function typeDetect(obj) {
|
|
9940
|
-
/* ! Speed optimisation
|
|
9941
|
-
* Pre:
|
|
9942
|
-
* string literal x 3,039,035 ops/sec ±1.62% (78 runs sampled)
|
|
9943
|
-
* boolean literal x 1,424,138 ops/sec ±4.54% (75 runs sampled)
|
|
9944
|
-
* number literal x 1,653,153 ops/sec ±1.91% (82 runs sampled)
|
|
9945
|
-
* undefined x 9,978,660 ops/sec ±1.92% (75 runs sampled)
|
|
9946
|
-
* function x 2,556,769 ops/sec ±1.73% (77 runs sampled)
|
|
9947
|
-
* Post:
|
|
9948
|
-
* string literal x 38,564,796 ops/sec ±1.15% (79 runs sampled)
|
|
9949
|
-
* boolean literal x 31,148,940 ops/sec ±1.10% (79 runs sampled)
|
|
9950
|
-
* number literal x 32,679,330 ops/sec ±1.90% (78 runs sampled)
|
|
9951
|
-
* undefined x 32,363,368 ops/sec ±1.07% (82 runs sampled)
|
|
9952
|
-
* function x 31,296,870 ops/sec ±0.96% (83 runs sampled)
|
|
9953
|
-
*/
|
|
9954
|
-
var typeofObj = typeof obj;
|
|
9955
|
-
if (typeofObj !== 'object') {
|
|
9956
|
-
return typeofObj;
|
|
9957
|
-
}
|
|
9958
|
-
|
|
9959
|
-
/* ! Speed optimisation
|
|
9960
|
-
* Pre:
|
|
9961
|
-
* null x 28,645,765 ops/sec ±1.17% (82 runs sampled)
|
|
9962
|
-
* Post:
|
|
9963
|
-
* null x 36,428,962 ops/sec ±1.37% (84 runs sampled)
|
|
9964
|
-
*/
|
|
9965
|
-
if (obj === null) {
|
|
9966
|
-
return 'null';
|
|
9967
|
-
}
|
|
9968
|
-
|
|
9969
|
-
/* ! Spec Conformance
|
|
9970
|
-
* Test: `Object.prototype.toString.call(window)``
|
|
9971
|
-
* - Node === "[object global]"
|
|
9972
|
-
* - Chrome === "[object global]"
|
|
9973
|
-
* - Firefox === "[object Window]"
|
|
9974
|
-
* - PhantomJS === "[object Window]"
|
|
9975
|
-
* - Safari === "[object Window]"
|
|
9976
|
-
* - IE 11 === "[object Window]"
|
|
9977
|
-
* - IE Edge === "[object Window]"
|
|
9978
|
-
* Test: `Object.prototype.toString.call(this)``
|
|
9979
|
-
* - Chrome Worker === "[object global]"
|
|
9980
|
-
* - Firefox Worker === "[object DedicatedWorkerGlobalScope]"
|
|
9981
|
-
* - Safari Worker === "[object DedicatedWorkerGlobalScope]"
|
|
9982
|
-
* - IE 11 Worker === "[object WorkerGlobalScope]"
|
|
9983
|
-
* - IE Edge Worker === "[object WorkerGlobalScope]"
|
|
9984
|
-
*/
|
|
9985
|
-
if (obj === globalObject) {
|
|
9986
|
-
return 'global';
|
|
9987
|
-
}
|
|
9988
|
-
|
|
9989
|
-
/* ! Speed optimisation
|
|
9990
|
-
* Pre:
|
|
9991
|
-
* array literal x 2,888,352 ops/sec ±0.67% (82 runs sampled)
|
|
9992
|
-
* Post:
|
|
9993
|
-
* array literal x 22,479,650 ops/sec ±0.96% (81 runs sampled)
|
|
9994
|
-
*/
|
|
9995
|
-
if (isArrayExists && Array.isArray(obj)) {
|
|
9996
|
-
return 'Array';
|
|
9997
|
-
}
|
|
9998
|
-
|
|
9999
|
-
if (isDom) {
|
|
10000
|
-
/* ! Spec Conformance
|
|
10001
|
-
* (https://html.spec.whatwg.org/multipage/browsers.html#location)
|
|
10002
|
-
* WhatWG HTML$7.7.3 - The `Location` interface
|
|
10003
|
-
* Test: `Object.prototype.toString.call(window.location)``
|
|
10004
|
-
* - IE <=11 === "[object Object]"
|
|
10005
|
-
* - IE Edge <=13 === "[object Object]"
|
|
10006
|
-
*/
|
|
10007
|
-
if (obj === globalObject.location) {
|
|
10008
|
-
return 'Location';
|
|
10009
|
-
}
|
|
10010
|
-
|
|
10011
|
-
/* ! Spec Conformance
|
|
10012
|
-
* (https://html.spec.whatwg.org/#document)
|
|
10013
|
-
* WhatWG HTML$3.1.1 - The `Document` object
|
|
10014
|
-
* Note: Most browsers currently adher to the W3C DOM Level 2 spec
|
|
10015
|
-
* (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268)
|
|
10016
|
-
* which suggests that browsers should use HTMLTableCellElement for
|
|
10017
|
-
* both TD and TH elements. WhatWG separates these.
|
|
10018
|
-
* WhatWG HTML states:
|
|
10019
|
-
* > For historical reasons, Window objects must also have a
|
|
10020
|
-
* > writable, configurable, non-enumerable property named
|
|
10021
|
-
* > HTMLDocument whose value is the Document interface object.
|
|
10022
|
-
* Test: `Object.prototype.toString.call(document)``
|
|
10023
|
-
* - Chrome === "[object HTMLDocument]"
|
|
10024
|
-
* - Firefox === "[object HTMLDocument]"
|
|
10025
|
-
* - Safari === "[object HTMLDocument]"
|
|
10026
|
-
* - IE <=10 === "[object Document]"
|
|
10027
|
-
* - IE 11 === "[object HTMLDocument]"
|
|
10028
|
-
* - IE Edge <=13 === "[object HTMLDocument]"
|
|
10029
|
-
*/
|
|
10030
|
-
if (obj === globalObject.document) {
|
|
10031
|
-
return 'Document';
|
|
10032
|
-
}
|
|
10033
|
-
|
|
10034
|
-
/* ! Spec Conformance
|
|
10035
|
-
* (https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray)
|
|
10036
|
-
* WhatWG HTML$8.6.1.5 - Plugins - Interface MimeTypeArray
|
|
10037
|
-
* Test: `Object.prototype.toString.call(navigator.mimeTypes)``
|
|
10038
|
-
* - IE <=10 === "[object MSMimeTypesCollection]"
|
|
10039
|
-
*/
|
|
10040
|
-
if (obj === (globalObject.navigator || {}).mimeTypes) {
|
|
10041
|
-
return 'MimeTypeArray';
|
|
10042
|
-
}
|
|
10043
|
-
|
|
10044
|
-
/* ! Spec Conformance
|
|
10045
|
-
* (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
|
|
10046
|
-
* WhatWG HTML$8.6.1.5 - Plugins - Interface PluginArray
|
|
10047
|
-
* Test: `Object.prototype.toString.call(navigator.plugins)``
|
|
10048
|
-
* - IE <=10 === "[object MSPluginsCollection]"
|
|
10049
|
-
*/
|
|
10050
|
-
if (obj === (globalObject.navigator || {}).plugins) {
|
|
10051
|
-
return 'PluginArray';
|
|
10052
|
-
}
|
|
10053
|
-
|
|
10054
|
-
/* ! Spec Conformance
|
|
10055
|
-
* (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
|
|
10056
|
-
* WhatWG HTML$4.4.4 - The `blockquote` element - Interface `HTMLQuoteElement`
|
|
10057
|
-
* Test: `Object.prototype.toString.call(document.createElement('blockquote'))``
|
|
10058
|
-
* - IE <=10 === "[object HTMLBlockElement]"
|
|
10059
|
-
*/
|
|
10060
|
-
if (htmlElementExists && obj instanceof HTMLElement && obj.tagName === 'BLOCKQUOTE') {
|
|
10061
|
-
return 'HTMLQuoteElement';
|
|
10062
|
-
}
|
|
10063
|
-
|
|
10064
|
-
/* ! Spec Conformance
|
|
10065
|
-
* (https://html.spec.whatwg.org/#htmltabledatacellelement)
|
|
10066
|
-
* WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableDataCellElement`
|
|
10067
|
-
* Note: Most browsers currently adher to the W3C DOM Level 2 spec
|
|
10068
|
-
* (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
|
|
10069
|
-
* which suggests that browsers should use HTMLTableCellElement for
|
|
10070
|
-
* both TD and TH elements. WhatWG separates these.
|
|
10071
|
-
* Test: Object.prototype.toString.call(document.createElement('td'))
|
|
10072
|
-
* - Chrome === "[object HTMLTableCellElement]"
|
|
10073
|
-
* - Firefox === "[object HTMLTableCellElement]"
|
|
10074
|
-
* - Safari === "[object HTMLTableCellElement]"
|
|
10075
|
-
*/
|
|
10076
|
-
if (htmlElementExists && obj instanceof HTMLElement && obj.tagName === 'TD') {
|
|
10077
|
-
return 'HTMLTableDataCellElement';
|
|
10078
|
-
}
|
|
10079
|
-
|
|
10080
|
-
/* ! Spec Conformance
|
|
10081
|
-
* (https://html.spec.whatwg.org/#htmltableheadercellelement)
|
|
10082
|
-
* WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableHeaderCellElement`
|
|
10083
|
-
* Note: Most browsers currently adher to the W3C DOM Level 2 spec
|
|
10084
|
-
* (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
|
|
10085
|
-
* which suggests that browsers should use HTMLTableCellElement for
|
|
10086
|
-
* both TD and TH elements. WhatWG separates these.
|
|
10087
|
-
* Test: Object.prototype.toString.call(document.createElement('th'))
|
|
10088
|
-
* - Chrome === "[object HTMLTableCellElement]"
|
|
10089
|
-
* - Firefox === "[object HTMLTableCellElement]"
|
|
10090
|
-
* - Safari === "[object HTMLTableCellElement]"
|
|
10091
|
-
*/
|
|
10092
|
-
if (htmlElementExists && obj instanceof HTMLElement && obj.tagName === 'TH') {
|
|
10093
|
-
return 'HTMLTableHeaderCellElement';
|
|
10094
|
-
}
|
|
10095
|
-
}
|
|
10096
|
-
|
|
10097
|
-
/* ! Speed optimisation
|
|
10098
|
-
* Pre:
|
|
10099
|
-
* Float64Array x 625,644 ops/sec ±1.58% (80 runs sampled)
|
|
10100
|
-
* Float32Array x 1,279,852 ops/sec ±2.91% (77 runs sampled)
|
|
10101
|
-
* Uint32Array x 1,178,185 ops/sec ±1.95% (83 runs sampled)
|
|
10102
|
-
* Uint16Array x 1,008,380 ops/sec ±2.25% (80 runs sampled)
|
|
10103
|
-
* Uint8Array x 1,128,040 ops/sec ±2.11% (81 runs sampled)
|
|
10104
|
-
* Int32Array x 1,170,119 ops/sec ±2.88% (80 runs sampled)
|
|
10105
|
-
* Int16Array x 1,176,348 ops/sec ±5.79% (86 runs sampled)
|
|
10106
|
-
* Int8Array x 1,058,707 ops/sec ±4.94% (77 runs sampled)
|
|
10107
|
-
* Uint8ClampedArray x 1,110,633 ops/sec ±4.20% (80 runs sampled)
|
|
10108
|
-
* Post:
|
|
10109
|
-
* Float64Array x 7,105,671 ops/sec ±13.47% (64 runs sampled)
|
|
10110
|
-
* Float32Array x 5,887,912 ops/sec ±1.46% (82 runs sampled)
|
|
10111
|
-
* Uint32Array x 6,491,661 ops/sec ±1.76% (79 runs sampled)
|
|
10112
|
-
* Uint16Array x 6,559,795 ops/sec ±1.67% (82 runs sampled)
|
|
10113
|
-
* Uint8Array x 6,463,966 ops/sec ±1.43% (85 runs sampled)
|
|
10114
|
-
* Int32Array x 5,641,841 ops/sec ±3.49% (81 runs sampled)
|
|
10115
|
-
* Int16Array x 6,583,511 ops/sec ±1.98% (80 runs sampled)
|
|
10116
|
-
* Int8Array x 6,606,078 ops/sec ±1.74% (81 runs sampled)
|
|
10117
|
-
* Uint8ClampedArray x 6,602,224 ops/sec ±1.77% (83 runs sampled)
|
|
10118
|
-
*/
|
|
10119
|
-
var stringTag = (symbolToStringTagExists && obj[Symbol.toStringTag]);
|
|
10120
|
-
if (typeof stringTag === 'string') {
|
|
10121
|
-
return stringTag;
|
|
10122
|
-
}
|
|
10123
|
-
|
|
10124
|
-
if (getPrototypeOfExists) {
|
|
10125
|
-
var objPrototype = Object.getPrototypeOf(obj);
|
|
10126
|
-
/* ! Speed optimisation
|
|
10127
|
-
* Pre:
|
|
10128
|
-
* regex literal x 1,772,385 ops/sec ±1.85% (77 runs sampled)
|
|
10129
|
-
* regex constructor x 2,143,634 ops/sec ±2.46% (78 runs sampled)
|
|
10130
|
-
* Post:
|
|
10131
|
-
* regex literal x 3,928,009 ops/sec ±0.65% (78 runs sampled)
|
|
10132
|
-
* regex constructor x 3,931,108 ops/sec ±0.58% (84 runs sampled)
|
|
10133
|
-
*/
|
|
10134
|
-
if (objPrototype === RegExp.prototype) {
|
|
10135
|
-
return 'RegExp';
|
|
10136
|
-
}
|
|
10137
|
-
|
|
10138
|
-
/* ! Speed optimisation
|
|
10139
|
-
* Pre:
|
|
10140
|
-
* date x 2,130,074 ops/sec ±4.42% (68 runs sampled)
|
|
10141
|
-
* Post:
|
|
10142
|
-
* date x 3,953,779 ops/sec ±1.35% (77 runs sampled)
|
|
10143
|
-
*/
|
|
10144
|
-
if (objPrototype === Date.prototype) {
|
|
10145
|
-
return 'Date';
|
|
10146
|
-
}
|
|
10147
|
-
|
|
10148
|
-
/* ! Spec Conformance
|
|
10149
|
-
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag)
|
|
10150
|
-
* ES6$25.4.5.4 - Promise.prototype[@@toStringTag] should be "Promise":
|
|
10151
|
-
* Test: `Object.prototype.toString.call(Promise.resolve())``
|
|
10152
|
-
* - Chrome <=47 === "[object Object]"
|
|
10153
|
-
* - Edge <=20 === "[object Object]"
|
|
10154
|
-
* - Firefox 29-Latest === "[object Promise]"
|
|
10155
|
-
* - Safari 7.1-Latest === "[object Promise]"
|
|
10156
|
-
*/
|
|
10157
|
-
if (promiseExists && objPrototype === Promise.prototype) {
|
|
10158
|
-
return 'Promise';
|
|
10159
|
-
}
|
|
10160
|
-
|
|
10161
|
-
/* ! Speed optimisation
|
|
10162
|
-
* Pre:
|
|
10163
|
-
* set x 2,222,186 ops/sec ±1.31% (82 runs sampled)
|
|
10164
|
-
* Post:
|
|
10165
|
-
* set x 4,545,879 ops/sec ±1.13% (83 runs sampled)
|
|
10166
|
-
*/
|
|
10167
|
-
if (setExists && objPrototype === Set.prototype) {
|
|
10168
|
-
return 'Set';
|
|
10169
|
-
}
|
|
10170
|
-
|
|
10171
|
-
/* ! Speed optimisation
|
|
10172
|
-
* Pre:
|
|
10173
|
-
* map x 2,396,842 ops/sec ±1.59% (81 runs sampled)
|
|
10174
|
-
* Post:
|
|
10175
|
-
* map x 4,183,945 ops/sec ±6.59% (82 runs sampled)
|
|
10176
|
-
*/
|
|
10177
|
-
if (mapExists && objPrototype === Map.prototype) {
|
|
10178
|
-
return 'Map';
|
|
10179
|
-
}
|
|
10180
|
-
|
|
10181
|
-
/* ! Speed optimisation
|
|
10182
|
-
* Pre:
|
|
10183
|
-
* weakset x 1,323,220 ops/sec ±2.17% (76 runs sampled)
|
|
10184
|
-
* Post:
|
|
10185
|
-
* weakset x 4,237,510 ops/sec ±2.01% (77 runs sampled)
|
|
10186
|
-
*/
|
|
10187
|
-
if (weakSetExists && objPrototype === WeakSet.prototype) {
|
|
10188
|
-
return 'WeakSet';
|
|
10189
|
-
}
|
|
10190
|
-
|
|
10191
|
-
/* ! Speed optimisation
|
|
10192
|
-
* Pre:
|
|
10193
|
-
* weakmap x 1,500,260 ops/sec ±2.02% (78 runs sampled)
|
|
10194
|
-
* Post:
|
|
10195
|
-
* weakmap x 3,881,384 ops/sec ±1.45% (82 runs sampled)
|
|
10196
|
-
*/
|
|
10197
|
-
if (weakMapExists && objPrototype === WeakMap.prototype) {
|
|
10198
|
-
return 'WeakMap';
|
|
10199
|
-
}
|
|
10200
|
-
|
|
10201
|
-
/* ! Spec Conformance
|
|
10202
|
-
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag)
|
|
10203
|
-
* ES6$24.2.4.21 - DataView.prototype[@@toStringTag] should be "DataView":
|
|
10204
|
-
* Test: `Object.prototype.toString.call(new DataView(new ArrayBuffer(1)))``
|
|
10205
|
-
* - Edge <=13 === "[object Object]"
|
|
10206
|
-
*/
|
|
10207
|
-
if (dataViewExists && objPrototype === DataView.prototype) {
|
|
10208
|
-
return 'DataView';
|
|
10209
|
-
}
|
|
10210
|
-
|
|
10211
|
-
/* ! Spec Conformance
|
|
10212
|
-
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag)
|
|
10213
|
-
* ES6$23.1.5.2.2 - %MapIteratorPrototype%[@@toStringTag] should be "Map Iterator":
|
|
10214
|
-
* Test: `Object.prototype.toString.call(new Map().entries())``
|
|
10215
|
-
* - Edge <=13 === "[object Object]"
|
|
10216
|
-
*/
|
|
10217
|
-
if (mapExists && objPrototype === mapIteratorPrototype) {
|
|
10218
|
-
return 'Map Iterator';
|
|
10219
|
-
}
|
|
10220
|
-
|
|
10221
|
-
/* ! Spec Conformance
|
|
10222
|
-
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag)
|
|
10223
|
-
* ES6$23.2.5.2.2 - %SetIteratorPrototype%[@@toStringTag] should be "Set Iterator":
|
|
10224
|
-
* Test: `Object.prototype.toString.call(new Set().entries())``
|
|
10225
|
-
* - Edge <=13 === "[object Object]"
|
|
10226
|
-
*/
|
|
10227
|
-
if (setExists && objPrototype === setIteratorPrototype) {
|
|
10228
|
-
return 'Set Iterator';
|
|
10229
|
-
}
|
|
10230
|
-
|
|
10231
|
-
/* ! Spec Conformance
|
|
10232
|
-
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag)
|
|
10233
|
-
* ES6$22.1.5.2.2 - %ArrayIteratorPrototype%[@@toStringTag] should be "Array Iterator":
|
|
10234
|
-
* Test: `Object.prototype.toString.call([][Symbol.iterator]())``
|
|
10235
|
-
* - Edge <=13 === "[object Object]"
|
|
10236
|
-
*/
|
|
10237
|
-
if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
|
|
10238
|
-
return 'Array Iterator';
|
|
10239
|
-
}
|
|
10240
|
-
|
|
10241
|
-
/* ! Spec Conformance
|
|
10242
|
-
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag)
|
|
10243
|
-
* ES6$21.1.5.2.2 - %StringIteratorPrototype%[@@toStringTag] should be "String Iterator":
|
|
10244
|
-
* Test: `Object.prototype.toString.call(''[Symbol.iterator]())``
|
|
10245
|
-
* - Edge <=13 === "[object Object]"
|
|
10246
|
-
*/
|
|
10247
|
-
if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
|
|
10248
|
-
return 'String Iterator';
|
|
10249
|
-
}
|
|
10250
|
-
|
|
10251
|
-
/* ! Speed optimisation
|
|
10252
|
-
* Pre:
|
|
10253
|
-
* object from null x 2,424,320 ops/sec ±1.67% (76 runs sampled)
|
|
10254
|
-
* Post:
|
|
10255
|
-
* object from null x 5,838,000 ops/sec ±0.99% (84 runs sampled)
|
|
10256
|
-
*/
|
|
10257
|
-
if (objPrototype === null) {
|
|
10258
|
-
return 'Object';
|
|
10259
|
-
}
|
|
10260
|
-
}
|
|
10261
|
-
|
|
10262
|
-
return Object
|
|
10263
|
-
.prototype
|
|
10264
|
-
.toString
|
|
10265
|
-
.call(obj)
|
|
10266
|
-
.slice(toStringLeftSliceLength, toStringRightSliceLength);
|
|
10267
|
-
};
|
|
10268
|
-
|
|
10269
|
-
module.exports.typeDetect = module.exports;
|
|
10270
|
-
|
|
10271
|
-
},{}],37:[function(require,module,exports){
|
|
9995
|
+
},{"type-detect":38}],36:[function(require,module,exports){
|
|
10272
9996
|
'use strict';
|
|
10273
9997
|
|
|
10274
9998
|
/* !
|
|
@@ -10314,7 +10038,7 @@ function getFuncName(aFunc) {
|
|
|
10314
10038
|
|
|
10315
10039
|
module.exports = getFuncName;
|
|
10316
10040
|
|
|
10317
|
-
},{}],
|
|
10041
|
+
},{}],37:[function(require,module,exports){
|
|
10318
10042
|
'use strict';
|
|
10319
10043
|
|
|
10320
10044
|
/* !
|
|
@@ -10607,7 +10331,7 @@ module.exports = {
|
|
|
10607
10331
|
setPathValue: setPathValue,
|
|
10608
10332
|
};
|
|
10609
10333
|
|
|
10610
|
-
},{}],
|
|
10334
|
+
},{}],38:[function(require,module,exports){
|
|
10611
10335
|
'use strict';
|
|
10612
10336
|
|
|
10613
10337
|
/* !
|
|
@@ -10979,61 +10703,5 @@ module.exports = function typeDetect(obj) {
|
|
|
10979
10703
|
|
|
10980
10704
|
module.exports.typeDetect = module.exports;
|
|
10981
10705
|
|
|
10982
|
-
},{}],40:[function(require,module,exports){
|
|
10983
|
-
module.exports={
|
|
10984
|
-
"author": "Jake Luer <jake@alogicalparadox.com>",
|
|
10985
|
-
"name": "chai",
|
|
10986
|
-
"description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic.",
|
|
10987
|
-
"keywords": [
|
|
10988
|
-
"test",
|
|
10989
|
-
"assertion",
|
|
10990
|
-
"assert",
|
|
10991
|
-
"testing",
|
|
10992
|
-
"chai"
|
|
10993
|
-
],
|
|
10994
|
-
"homepage": "http://chaijs.com",
|
|
10995
|
-
"license": "MIT",
|
|
10996
|
-
"contributors": [
|
|
10997
|
-
"Jake Luer <jake@alogicalparadox.com>",
|
|
10998
|
-
"Domenic Denicola <domenic@domenicdenicola.com> (http://domenicdenicola.com)",
|
|
10999
|
-
"Veselin Todorov <hi@vesln.com>",
|
|
11000
|
-
"John Firebaugh <john.firebaugh@gmail.com>"
|
|
11001
|
-
],
|
|
11002
|
-
"version": "4.0.1",
|
|
11003
|
-
"repository": {
|
|
11004
|
-
"type": "git",
|
|
11005
|
-
"url": "https://github.com/chaijs/chai"
|
|
11006
|
-
},
|
|
11007
|
-
"bugs": {
|
|
11008
|
-
"url": "https://github.com/chaijs/chai/issues"
|
|
11009
|
-
},
|
|
11010
|
-
"main": "./index",
|
|
11011
|
-
"scripts": {
|
|
11012
|
-
"test": "make test"
|
|
11013
|
-
},
|
|
11014
|
-
"engines": {
|
|
11015
|
-
"node": ">=4"
|
|
11016
|
-
},
|
|
11017
|
-
"dependencies": {
|
|
11018
|
-
"assertion-error": "^1.0.1",
|
|
11019
|
-
"check-error": "^1.0.1",
|
|
11020
|
-
"deep-eql": "^2.0.1",
|
|
11021
|
-
"get-func-name": "^2.0.0",
|
|
11022
|
-
"pathval": "^1.0.0",
|
|
11023
|
-
"type-detect": "^4.0.0"
|
|
11024
|
-
},
|
|
11025
|
-
"devDependencies": {
|
|
11026
|
-
"browserify": "^13.0.1",
|
|
11027
|
-
"bump-cli": "^1.1.3",
|
|
11028
|
-
"istanbul": "^0.4.3",
|
|
11029
|
-
"karma": "^1.0.0",
|
|
11030
|
-
"karma-firefox-launcher": "^1.0.0",
|
|
11031
|
-
"karma-mocha": "^1.0.1",
|
|
11032
|
-
"karma-phantomjs-launcher": "^1.0.0",
|
|
11033
|
-
"karma-sauce-launcher": "^1.0.0",
|
|
11034
|
-
"mocha": "^3.0.0"
|
|
11035
|
-
}
|
|
11036
|
-
}
|
|
11037
|
-
|
|
11038
10706
|
},{}]},{},[1])(1)
|
|
11039
10707
|
});
|