chai 4.1.2 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +2 -2
- package/README.md +4 -4
- package/chai.js +421 -274
- package/lib/chai/config.js +1 -1
- package/lib/chai/core/assertions.js +168 -93
- package/lib/chai/interface/assert.js +69 -54
- package/lib/chai/interface/expect.js +13 -0
- package/lib/chai/interface/should.js +14 -0
- package/lib/chai/utils/addLengthGuard.js +0 -2
- package/lib/chai/utils/compareByInspect.js +2 -2
- package/lib/chai/utils/getMessage.js +1 -2
- package/lib/chai/utils/getOwnEnumerableProperties.js +1 -1
- 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 +11 -10
- 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.2.0';
|
|
18
18
|
|
|
19
19
|
/*!
|
|
20
20
|
* Assertion Error
|
|
@@ -355,7 +355,7 @@ module.exports = {
|
|
|
355
355
|
* @api public
|
|
356
356
|
*/
|
|
357
357
|
|
|
358
|
-
proxyExcludedKeys: ['then', 'inspect', 'toJSON']
|
|
358
|
+
proxyExcludedKeys: ['then', 'catch', 'inspect', 'toJSON']
|
|
359
359
|
};
|
|
360
360
|
|
|
361
361
|
},{}],5:[function(require,module,exports){
|
|
@@ -394,16 +394,17 @@ module.exports = function (chai, _) {
|
|
|
394
394
|
* - same
|
|
395
395
|
* - but
|
|
396
396
|
* - does
|
|
397
|
+
* - still
|
|
397
398
|
*
|
|
398
399
|
* @name language chains
|
|
399
400
|
* @namespace BDD
|
|
400
401
|
* @api public
|
|
401
402
|
*/
|
|
402
403
|
|
|
403
|
-
[ 'to', 'be', 'been'
|
|
404
|
-
, '
|
|
405
|
-
, '
|
|
406
|
-
, '
|
|
404
|
+
[ 'to', 'be', 'been', 'is'
|
|
405
|
+
, 'and', 'has', 'have', 'with'
|
|
406
|
+
, 'that', 'which', 'at', 'of'
|
|
407
|
+
, 'same', 'but', 'does', 'still' ].forEach(function (chain) {
|
|
407
408
|
Assertion.addProperty(chain);
|
|
408
409
|
});
|
|
409
410
|
|
|
@@ -510,7 +511,8 @@ module.exports = function (chai, _) {
|
|
|
510
511
|
* Object.prototype.b = 2;
|
|
511
512
|
*
|
|
512
513
|
* expect({a: 1}).to.have.own.property('a');
|
|
513
|
-
* expect({a: 1}).to.have.property('b')
|
|
514
|
+
* expect({a: 1}).to.have.property('b');
|
|
515
|
+
* expect({a: 1}).to.not.have.own.property('b');
|
|
514
516
|
*
|
|
515
517
|
* expect({a: 1}).to.own.include({a: 1});
|
|
516
518
|
* expect({a: 1}).to.include({b: 2}).but.not.own.include({b: 2});
|
|
@@ -571,7 +573,6 @@ module.exports = function (chai, _) {
|
|
|
571
573
|
flag(this, 'all', false);
|
|
572
574
|
});
|
|
573
575
|
|
|
574
|
-
|
|
575
576
|
/**
|
|
576
577
|
* ### .all
|
|
577
578
|
*
|
|
@@ -643,7 +644,7 @@ module.exports = function (chai, _) {
|
|
|
643
644
|
* expect(1, 'nooo why fail??').to.be.a('string');
|
|
644
645
|
*
|
|
645
646
|
* `.a` can also be used as a language chain to improve the readability of
|
|
646
|
-
* your assertions.
|
|
647
|
+
* your assertions.
|
|
647
648
|
*
|
|
648
649
|
* expect({b: 2}).to.have.a.property('b');
|
|
649
650
|
*
|
|
@@ -757,7 +758,7 @@ module.exports = function (chai, _) {
|
|
|
757
758
|
*
|
|
758
759
|
* expect('foobar').to.not.include('taco');
|
|
759
760
|
* expect([1, 2, 3]).to.not.include(4);
|
|
760
|
-
*
|
|
761
|
+
*
|
|
761
762
|
* However, it's dangerous to negate `.include` when the target is an object.
|
|
762
763
|
* The problem is that it creates uncertain expectations by asserting that the
|
|
763
764
|
* target object doesn't have all of `val`'s key/value pairs but may or may
|
|
@@ -830,7 +831,7 @@ module.exports = function (chai, _) {
|
|
|
830
831
|
|
|
831
832
|
function include (val, msg) {
|
|
832
833
|
if (msg) flag(this, 'message', msg);
|
|
833
|
-
|
|
834
|
+
|
|
834
835
|
var obj = flag(this, 'object')
|
|
835
836
|
, objType = _.type(obj).toLowerCase()
|
|
836
837
|
, flagMsg = flag(this, 'message')
|
|
@@ -903,17 +904,17 @@ module.exports = function (chai, _) {
|
|
|
903
904
|
var props = Object.keys(val)
|
|
904
905
|
, firstErr = null
|
|
905
906
|
, numErrs = 0;
|
|
906
|
-
|
|
907
|
+
|
|
907
908
|
props.forEach(function (prop) {
|
|
908
909
|
var propAssertion = new Assertion(obj);
|
|
909
910
|
_.transferFlags(this, propAssertion, true);
|
|
910
911
|
flag(propAssertion, 'lockSsfi', true);
|
|
911
|
-
|
|
912
|
+
|
|
912
913
|
if (!negate || props.length === 1) {
|
|
913
914
|
propAssertion.property(prop, val[prop]);
|
|
914
915
|
return;
|
|
915
916
|
}
|
|
916
|
-
|
|
917
|
+
|
|
917
918
|
try {
|
|
918
919
|
propAssertion.property(prop, val[prop]);
|
|
919
920
|
} catch (err) {
|
|
@@ -924,7 +925,7 @@ module.exports = function (chai, _) {
|
|
|
924
925
|
numErrs++;
|
|
925
926
|
}
|
|
926
927
|
}, this);
|
|
927
|
-
|
|
928
|
+
|
|
928
929
|
// When validating .not.include with multiple properties, we only want
|
|
929
930
|
// to throw an assertion error if all of the properties are included,
|
|
930
931
|
// in which case we throw the first property assertion error that we
|
|
@@ -950,9 +951,9 @@ module.exports = function (chai, _) {
|
|
|
950
951
|
/**
|
|
951
952
|
* ### .ok
|
|
952
953
|
*
|
|
953
|
-
* Asserts that the target is
|
|
954
|
-
* often best to assert that the target is strictly (`===`) or
|
|
955
|
-
* its expected value.
|
|
954
|
+
* Asserts that the target is a truthy value (considered `true` in boolean context).
|
|
955
|
+
* However, it's often best to assert that the target is strictly (`===`) or
|
|
956
|
+
* deeply equal to its expected value.
|
|
956
957
|
*
|
|
957
958
|
* expect(1).to.equal(1); // Recommended
|
|
958
959
|
* expect(1).to.be.ok; // Not recommended
|
|
@@ -1336,7 +1337,7 @@ module.exports = function (chai, _) {
|
|
|
1336
1337
|
*
|
|
1337
1338
|
* expect(1).to.equal(1);
|
|
1338
1339
|
* expect('foo').to.equal('foo');
|
|
1339
|
-
*
|
|
1340
|
+
*
|
|
1340
1341
|
* Add `.deep` earlier in the chain to use deep equality instead. See the
|
|
1341
1342
|
* `deep-eql` project page for info on the deep equality algorithm:
|
|
1342
1343
|
* https://github.com/chaijs/deep-eql.
|
|
@@ -1378,7 +1379,10 @@ module.exports = function (chai, _) {
|
|
|
1378
1379
|
if (msg) flag(this, 'message', msg);
|
|
1379
1380
|
var obj = flag(this, 'object');
|
|
1380
1381
|
if (flag(this, 'deep')) {
|
|
1381
|
-
|
|
1382
|
+
var prevLockSsfi = flag(this, 'lockSsfi');
|
|
1383
|
+
flag(this, 'lockSsfi', true);
|
|
1384
|
+
this.eql(val);
|
|
1385
|
+
flag(this, 'lockSsfi', prevLockSsfi);
|
|
1382
1386
|
} else {
|
|
1383
1387
|
this.assert(
|
|
1384
1388
|
val === obj
|
|
@@ -1461,8 +1465,8 @@ module.exports = function (chai, _) {
|
|
|
1461
1465
|
* expect(2).to.equal(2); // Recommended
|
|
1462
1466
|
* expect(2).to.be.above(1); // Not recommended
|
|
1463
1467
|
*
|
|
1464
|
-
* Add `.lengthOf` earlier in the chain to assert that the
|
|
1465
|
-
*
|
|
1468
|
+
* Add `.lengthOf` earlier in the chain to assert that the target's `length`
|
|
1469
|
+
* or `size` is greater than the given number `n`.
|
|
1466
1470
|
*
|
|
1467
1471
|
* expect('foo').to.have.lengthOf(3); // Recommended
|
|
1468
1472
|
* expect('foo').to.have.lengthOf.above(2); // Not recommended
|
|
@@ -1503,12 +1507,13 @@ module.exports = function (chai, _) {
|
|
|
1503
1507
|
, ssfi = flag(this, 'ssfi')
|
|
1504
1508
|
, objType = _.type(obj).toLowerCase()
|
|
1505
1509
|
, nType = _.type(n).toLowerCase()
|
|
1510
|
+
, errorMessage
|
|
1506
1511
|
, shouldThrow = true;
|
|
1507
1512
|
|
|
1508
|
-
if (doLength) {
|
|
1513
|
+
if (doLength && objType !== 'map' && objType !== 'set') {
|
|
1509
1514
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
|
|
1510
1515
|
}
|
|
1511
|
-
|
|
1516
|
+
|
|
1512
1517
|
if (!doLength && (objType === 'date' && nType !== 'date')) {
|
|
1513
1518
|
errorMessage = msgPrefix + 'the argument to above must be a date';
|
|
1514
1519
|
} else if (nType !== 'number' && (doLength || objType === 'number')) {
|
|
@@ -1525,13 +1530,20 @@ module.exports = function (chai, _) {
|
|
|
1525
1530
|
}
|
|
1526
1531
|
|
|
1527
1532
|
if (doLength) {
|
|
1528
|
-
var
|
|
1533
|
+
var descriptor = 'length'
|
|
1534
|
+
, itemsCount;
|
|
1535
|
+
if (objType === 'map' || objType === 'set') {
|
|
1536
|
+
descriptor = 'size';
|
|
1537
|
+
itemsCount = obj.size;
|
|
1538
|
+
} else {
|
|
1539
|
+
itemsCount = obj.length;
|
|
1540
|
+
}
|
|
1529
1541
|
this.assert(
|
|
1530
|
-
|
|
1531
|
-
, 'expected #{this} to have a
|
|
1532
|
-
, 'expected #{this} to not have a
|
|
1542
|
+
itemsCount > n
|
|
1543
|
+
, 'expected #{this} to have a ' + descriptor + ' above #{exp} but got #{act}'
|
|
1544
|
+
, 'expected #{this} to not have a ' + descriptor + ' above #{exp}'
|
|
1533
1545
|
, n
|
|
1534
|
-
,
|
|
1546
|
+
, itemsCount
|
|
1535
1547
|
);
|
|
1536
1548
|
} else {
|
|
1537
1549
|
this.assert(
|
|
@@ -1558,9 +1570,8 @@ module.exports = function (chai, _) {
|
|
|
1558
1570
|
* expect(2).to.be.at.least(1); // Not recommended
|
|
1559
1571
|
* expect(2).to.be.at.least(2); // Not recommended
|
|
1560
1572
|
*
|
|
1561
|
-
* Add `.lengthOf` earlier in the chain to assert that the
|
|
1562
|
-
*
|
|
1563
|
-
* `n`.
|
|
1573
|
+
* Add `.lengthOf` earlier in the chain to assert that the target's `length`
|
|
1574
|
+
* or `size` is greater than or equal to the given number `n`.
|
|
1564
1575
|
*
|
|
1565
1576
|
* expect('foo').to.have.lengthOf(3); // Recommended
|
|
1566
1577
|
* expect('foo').to.have.lengthOf.at.least(2); // Not recommended
|
|
@@ -1599,9 +1610,10 @@ module.exports = function (chai, _) {
|
|
|
1599
1610
|
, ssfi = flag(this, 'ssfi')
|
|
1600
1611
|
, objType = _.type(obj).toLowerCase()
|
|
1601
1612
|
, nType = _.type(n).toLowerCase()
|
|
1613
|
+
, errorMessage
|
|
1602
1614
|
, shouldThrow = true;
|
|
1603
1615
|
|
|
1604
|
-
if (doLength) {
|
|
1616
|
+
if (doLength && objType !== 'map' && objType !== 'set') {
|
|
1605
1617
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
|
|
1606
1618
|
}
|
|
1607
1619
|
|
|
@@ -1621,13 +1633,20 @@ module.exports = function (chai, _) {
|
|
|
1621
1633
|
}
|
|
1622
1634
|
|
|
1623
1635
|
if (doLength) {
|
|
1624
|
-
var
|
|
1636
|
+
var descriptor = 'length'
|
|
1637
|
+
, itemsCount;
|
|
1638
|
+
if (objType === 'map' || objType === 'set') {
|
|
1639
|
+
descriptor = 'size';
|
|
1640
|
+
itemsCount = obj.size;
|
|
1641
|
+
} else {
|
|
1642
|
+
itemsCount = obj.length;
|
|
1643
|
+
}
|
|
1625
1644
|
this.assert(
|
|
1626
|
-
|
|
1627
|
-
, 'expected #{this} to have a
|
|
1628
|
-
, 'expected #{this} to have a
|
|
1645
|
+
itemsCount >= n
|
|
1646
|
+
, 'expected #{this} to have a ' + descriptor + ' at least #{exp} but got #{act}'
|
|
1647
|
+
, 'expected #{this} to have a ' + descriptor + ' below #{exp}'
|
|
1629
1648
|
, n
|
|
1630
|
-
,
|
|
1649
|
+
, itemsCount
|
|
1631
1650
|
);
|
|
1632
1651
|
} else {
|
|
1633
1652
|
this.assert(
|
|
@@ -1652,8 +1671,8 @@ module.exports = function (chai, _) {
|
|
|
1652
1671
|
* expect(1).to.equal(1); // Recommended
|
|
1653
1672
|
* expect(1).to.be.below(2); // Not recommended
|
|
1654
1673
|
*
|
|
1655
|
-
* Add `.lengthOf` earlier in the chain to assert that the
|
|
1656
|
-
*
|
|
1674
|
+
* Add `.lengthOf` earlier in the chain to assert that the target's `length`
|
|
1675
|
+
* or `size` is less than the given number `n`.
|
|
1657
1676
|
*
|
|
1658
1677
|
* expect('foo').to.have.lengthOf(3); // Recommended
|
|
1659
1678
|
* expect('foo').to.have.lengthOf.below(4); // Not recommended
|
|
@@ -1694,9 +1713,10 @@ module.exports = function (chai, _) {
|
|
|
1694
1713
|
, ssfi = flag(this, 'ssfi')
|
|
1695
1714
|
, objType = _.type(obj).toLowerCase()
|
|
1696
1715
|
, nType = _.type(n).toLowerCase()
|
|
1716
|
+
, errorMessage
|
|
1697
1717
|
, shouldThrow = true;
|
|
1698
1718
|
|
|
1699
|
-
if (doLength) {
|
|
1719
|
+
if (doLength && objType !== 'map' && objType !== 'set') {
|
|
1700
1720
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
|
|
1701
1721
|
}
|
|
1702
1722
|
|
|
@@ -1716,13 +1736,20 @@ module.exports = function (chai, _) {
|
|
|
1716
1736
|
}
|
|
1717
1737
|
|
|
1718
1738
|
if (doLength) {
|
|
1719
|
-
var
|
|
1739
|
+
var descriptor = 'length'
|
|
1740
|
+
, itemsCount;
|
|
1741
|
+
if (objType === 'map' || objType === 'set') {
|
|
1742
|
+
descriptor = 'size';
|
|
1743
|
+
itemsCount = obj.size;
|
|
1744
|
+
} else {
|
|
1745
|
+
itemsCount = obj.length;
|
|
1746
|
+
}
|
|
1720
1747
|
this.assert(
|
|
1721
|
-
|
|
1722
|
-
, 'expected #{this} to have a
|
|
1723
|
-
, 'expected #{this} to not have a
|
|
1748
|
+
itemsCount < n
|
|
1749
|
+
, 'expected #{this} to have a ' + descriptor + ' below #{exp} but got #{act}'
|
|
1750
|
+
, 'expected #{this} to not have a ' + descriptor + ' below #{exp}'
|
|
1724
1751
|
, n
|
|
1725
|
-
,
|
|
1752
|
+
, itemsCount
|
|
1726
1753
|
);
|
|
1727
1754
|
} else {
|
|
1728
1755
|
this.assert(
|
|
@@ -1749,8 +1776,8 @@ module.exports = function (chai, _) {
|
|
|
1749
1776
|
* expect(1).to.be.at.most(2); // Not recommended
|
|
1750
1777
|
* expect(1).to.be.at.most(1); // Not recommended
|
|
1751
1778
|
*
|
|
1752
|
-
* Add `.lengthOf` earlier in the chain to assert that the
|
|
1753
|
-
*
|
|
1779
|
+
* Add `.lengthOf` earlier in the chain to assert that the target's `length`
|
|
1780
|
+
* or `size` is less than or equal to the given number `n`.
|
|
1754
1781
|
*
|
|
1755
1782
|
* expect('foo').to.have.lengthOf(3); // Recommended
|
|
1756
1783
|
* expect('foo').to.have.lengthOf.at.most(4); // Not recommended
|
|
@@ -1789,12 +1816,13 @@ module.exports = function (chai, _) {
|
|
|
1789
1816
|
, ssfi = flag(this, 'ssfi')
|
|
1790
1817
|
, objType = _.type(obj).toLowerCase()
|
|
1791
1818
|
, nType = _.type(n).toLowerCase()
|
|
1819
|
+
, errorMessage
|
|
1792
1820
|
, shouldThrow = true;
|
|
1793
1821
|
|
|
1794
|
-
if (doLength) {
|
|
1822
|
+
if (doLength && objType !== 'map' && objType !== 'set') {
|
|
1795
1823
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
|
|
1796
1824
|
}
|
|
1797
|
-
|
|
1825
|
+
|
|
1798
1826
|
if (!doLength && (objType === 'date' && nType !== 'date')) {
|
|
1799
1827
|
errorMessage = msgPrefix + 'the argument to most must be a date';
|
|
1800
1828
|
} else if (nType !== 'number' && (doLength || objType === 'number')) {
|
|
@@ -1811,13 +1839,20 @@ module.exports = function (chai, _) {
|
|
|
1811
1839
|
}
|
|
1812
1840
|
|
|
1813
1841
|
if (doLength) {
|
|
1814
|
-
var
|
|
1842
|
+
var descriptor = 'length'
|
|
1843
|
+
, itemsCount;
|
|
1844
|
+
if (objType === 'map' || objType === 'set') {
|
|
1845
|
+
descriptor = 'size';
|
|
1846
|
+
itemsCount = obj.size;
|
|
1847
|
+
} else {
|
|
1848
|
+
itemsCount = obj.length;
|
|
1849
|
+
}
|
|
1815
1850
|
this.assert(
|
|
1816
|
-
|
|
1817
|
-
, 'expected #{this} to have a
|
|
1818
|
-
, 'expected #{this} to have a
|
|
1851
|
+
itemsCount <= n
|
|
1852
|
+
, 'expected #{this} to have a ' + descriptor + ' at most #{exp} but got #{act}'
|
|
1853
|
+
, 'expected #{this} to have a ' + descriptor + ' above #{exp}'
|
|
1819
1854
|
, n
|
|
1820
|
-
,
|
|
1855
|
+
, itemsCount
|
|
1821
1856
|
);
|
|
1822
1857
|
} else {
|
|
1823
1858
|
this.assert(
|
|
@@ -1845,9 +1880,9 @@ module.exports = function (chai, _) {
|
|
|
1845
1880
|
* expect(2).to.be.within(2, 3); // Not recommended
|
|
1846
1881
|
* expect(2).to.be.within(1, 2); // Not recommended
|
|
1847
1882
|
*
|
|
1848
|
-
* Add `.lengthOf` earlier in the chain to assert that the
|
|
1849
|
-
*
|
|
1850
|
-
*
|
|
1883
|
+
* Add `.lengthOf` earlier in the chain to assert that the target's `length`
|
|
1884
|
+
* or `size` is greater than or equal to the given number `start`, and less
|
|
1885
|
+
* than or equal to the given number `finish`.
|
|
1851
1886
|
*
|
|
1852
1887
|
* expect('foo').to.have.lengthOf(3); // Recommended
|
|
1853
1888
|
* expect('foo').to.have.lengthOf.within(2, 4); // Not recommended
|
|
@@ -1885,12 +1920,13 @@ module.exports = function (chai, _) {
|
|
|
1885
1920
|
, objType = _.type(obj).toLowerCase()
|
|
1886
1921
|
, startType = _.type(start).toLowerCase()
|
|
1887
1922
|
, finishType = _.type(finish).toLowerCase()
|
|
1923
|
+
, errorMessage
|
|
1888
1924
|
, shouldThrow = true
|
|
1889
1925
|
, range = (startType === 'date' && finishType === 'date')
|
|
1890
1926
|
? start.toUTCString() + '..' + finish.toUTCString()
|
|
1891
1927
|
: start + '..' + finish;
|
|
1892
1928
|
|
|
1893
|
-
if (doLength) {
|
|
1929
|
+
if (doLength && objType !== 'map' && objType !== 'set') {
|
|
1894
1930
|
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
|
|
1895
1931
|
}
|
|
1896
1932
|
|
|
@@ -1910,11 +1946,18 @@ module.exports = function (chai, _) {
|
|
|
1910
1946
|
}
|
|
1911
1947
|
|
|
1912
1948
|
if (doLength) {
|
|
1913
|
-
var
|
|
1949
|
+
var descriptor = 'length'
|
|
1950
|
+
, itemsCount;
|
|
1951
|
+
if (objType === 'map' || objType === 'set') {
|
|
1952
|
+
descriptor = 'size';
|
|
1953
|
+
itemsCount = obj.size;
|
|
1954
|
+
} else {
|
|
1955
|
+
itemsCount = obj.length;
|
|
1956
|
+
}
|
|
1914
1957
|
this.assert(
|
|
1915
|
-
|
|
1916
|
-
, 'expected #{this} to have a
|
|
1917
|
-
, 'expected #{this} to not have a
|
|
1958
|
+
itemsCount >= start && itemsCount <= finish
|
|
1959
|
+
, 'expected #{this} to have a ' + descriptor + ' within ' + range
|
|
1960
|
+
, 'expected #{this} to not have a ' + descriptor + ' within ' + range
|
|
1918
1961
|
);
|
|
1919
1962
|
} else {
|
|
1920
1963
|
this.assert(
|
|
@@ -2030,7 +2073,8 @@ module.exports = function (chai, _) {
|
|
|
2030
2073
|
*
|
|
2031
2074
|
* expect({a: 1}).to.have.own.property('a');
|
|
2032
2075
|
* expect({a: 1}).to.have.own.property('a', 1);
|
|
2033
|
-
* expect({a: 1}).to.have.property('b')
|
|
2076
|
+
* expect({a: 1}).to.have.property('b');
|
|
2077
|
+
* expect({a: 1}).to.not.have.own.property('b');
|
|
2034
2078
|
*
|
|
2035
2079
|
* `.deep` and `.own` can be combined.
|
|
2036
2080
|
*
|
|
@@ -2057,7 +2101,7 @@ module.exports = function (chai, _) {
|
|
|
2057
2101
|
* Add `.not` earlier in the chain to negate `.property`.
|
|
2058
2102
|
*
|
|
2059
2103
|
* expect({a: 1}).to.not.have.property('b');
|
|
2060
|
-
*
|
|
2104
|
+
*
|
|
2061
2105
|
* However, it's dangerous to negate `.property` when providing `val`. The
|
|
2062
2106
|
* problem is that it creates uncertain expectations by asserting that the
|
|
2063
2107
|
* target either doesn't have a property with the given key `name`, or that it
|
|
@@ -2095,7 +2139,7 @@ module.exports = function (chai, _) {
|
|
|
2095
2139
|
*
|
|
2096
2140
|
* // Not recommended
|
|
2097
2141
|
* expect({a: 1}).to.have.property('b', undefined, 'nooo why fail??');
|
|
2098
|
-
*
|
|
2142
|
+
*
|
|
2099
2143
|
* The above assertion isn't the same thing as not providing `val`. Instead,
|
|
2100
2144
|
* it's asserting that the target object has a `b` property that's equal to
|
|
2101
2145
|
* `undefined`.
|
|
@@ -2119,10 +2163,30 @@ module.exports = function (chai, _) {
|
|
|
2119
2163
|
, isOwn = flag(this, 'own')
|
|
2120
2164
|
, flagMsg = flag(this, 'message')
|
|
2121
2165
|
, obj = flag(this, 'object')
|
|
2122
|
-
, ssfi = flag(this, 'ssfi')
|
|
2166
|
+
, ssfi = flag(this, 'ssfi')
|
|
2167
|
+
, nameType = typeof name;
|
|
2168
|
+
|
|
2169
|
+
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
2170
|
+
|
|
2171
|
+
if (isNested) {
|
|
2172
|
+
if (nameType !== 'string') {
|
|
2173
|
+
throw new AssertionError(
|
|
2174
|
+
flagMsg + 'the argument to property must be a string when using nested syntax',
|
|
2175
|
+
undefined,
|
|
2176
|
+
ssfi
|
|
2177
|
+
);
|
|
2178
|
+
}
|
|
2179
|
+
} else {
|
|
2180
|
+
if (nameType !== 'string' && nameType !== 'number' && nameType !== 'symbol') {
|
|
2181
|
+
throw new AssertionError(
|
|
2182
|
+
flagMsg + 'the argument to property must be a string, number, or symbol',
|
|
2183
|
+
undefined,
|
|
2184
|
+
ssfi
|
|
2185
|
+
);
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2123
2188
|
|
|
2124
2189
|
if (isNested && isOwn) {
|
|
2125
|
-
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
2126
2190
|
throw new AssertionError(
|
|
2127
2191
|
flagMsg + 'The "nested" and "own" flags cannot be combined.',
|
|
2128
2192
|
undefined,
|
|
@@ -2131,7 +2195,6 @@ module.exports = function (chai, _) {
|
|
|
2131
2195
|
}
|
|
2132
2196
|
|
|
2133
2197
|
if (obj === null || obj === undefined) {
|
|
2134
|
-
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
|
2135
2198
|
throw new AssertionError(
|
|
2136
2199
|
flagMsg + 'Target cannot be null or undefined.',
|
|
2137
2200
|
undefined,
|
|
@@ -2214,7 +2277,7 @@ module.exports = function (chai, _) {
|
|
|
2214
2277
|
* Add `.not` earlier in the chain to negate `.ownPropertyDescriptor`.
|
|
2215
2278
|
*
|
|
2216
2279
|
* expect({a: 1}).to.not.have.ownPropertyDescriptor('b');
|
|
2217
|
-
*
|
|
2280
|
+
*
|
|
2218
2281
|
* However, it's dangerous to negate `.ownPropertyDescriptor` when providing
|
|
2219
2282
|
* a `descriptor`. The problem is that it creates uncertain expectations by
|
|
2220
2283
|
* asserting that the target either doesn't have a property descriptor with
|
|
@@ -2285,7 +2348,7 @@ module.exports = function (chai, _) {
|
|
|
2285
2348
|
* writable: true,
|
|
2286
2349
|
* value: 2,
|
|
2287
2350
|
* });
|
|
2288
|
-
*
|
|
2351
|
+
*
|
|
2289
2352
|
* // Recommended
|
|
2290
2353
|
* expect({a: 1}, 'nooo why fail??').to.have.ownPropertyDescriptor('b');
|
|
2291
2354
|
*
|
|
@@ -2342,11 +2405,13 @@ module.exports = function (chai, _) {
|
|
|
2342
2405
|
/**
|
|
2343
2406
|
* ### .lengthOf(n[, msg])
|
|
2344
2407
|
*
|
|
2345
|
-
* Asserts that the target's `length`
|
|
2408
|
+
* Asserts that the target's `length` or `size` is equal to the given number
|
|
2346
2409
|
* `n`.
|
|
2347
2410
|
*
|
|
2348
2411
|
* expect([1, 2, 3]).to.have.lengthOf(3);
|
|
2349
2412
|
* expect('foo').to.have.lengthOf(3);
|
|
2413
|
+
* expect(new Set([1, 2, 3])).to.have.lengthOf(3);
|
|
2414
|
+
* expect(new Map([['a', 1], ['b', 2], ['c', 3]])).to.have.lengthOf(3);
|
|
2350
2415
|
*
|
|
2351
2416
|
* Add `.not` earlier in the chain to negate `.lengthOf`. However, it's often
|
|
2352
2417
|
* best to assert that the target's `length` property is equal to its expected
|
|
@@ -2402,17 +2467,29 @@ module.exports = function (chai, _) {
|
|
|
2402
2467
|
function assertLength (n, msg) {
|
|
2403
2468
|
if (msg) flag(this, 'message', msg);
|
|
2404
2469
|
var obj = flag(this, 'object')
|
|
2470
|
+
, objType = _.type(obj).toLowerCase()
|
|
2405
2471
|
, flagMsg = flag(this, 'message')
|
|
2406
|
-
, ssfi = flag(this, 'ssfi')
|
|
2407
|
-
|
|
2408
|
-
|
|
2472
|
+
, ssfi = flag(this, 'ssfi')
|
|
2473
|
+
, descriptor = 'length'
|
|
2474
|
+
, itemsCount;
|
|
2475
|
+
|
|
2476
|
+
switch (objType) {
|
|
2477
|
+
case 'map':
|
|
2478
|
+
case 'set':
|
|
2479
|
+
descriptor = 'size';
|
|
2480
|
+
itemsCount = obj.size;
|
|
2481
|
+
break;
|
|
2482
|
+
default:
|
|
2483
|
+
new Assertion(obj, flagMsg, ssfi, true).to.have.property('length');
|
|
2484
|
+
itemsCount = obj.length;
|
|
2485
|
+
}
|
|
2409
2486
|
|
|
2410
2487
|
this.assert(
|
|
2411
|
-
|
|
2412
|
-
, 'expected #{this} to have a
|
|
2413
|
-
, 'expected #{this} to not have a
|
|
2488
|
+
itemsCount == n
|
|
2489
|
+
, 'expected #{this} to have a ' + descriptor + ' of #{exp} but got #{act}'
|
|
2490
|
+
, 'expected #{this} to not have a ' + descriptor + ' of #{act}'
|
|
2414
2491
|
, n
|
|
2415
|
-
,
|
|
2492
|
+
, itemsCount
|
|
2416
2493
|
);
|
|
2417
2494
|
}
|
|
2418
2495
|
|
|
@@ -2474,8 +2551,8 @@ module.exports = function (chai, _) {
|
|
|
2474
2551
|
* message to show when the assertion fails. The message can also be given as
|
|
2475
2552
|
* the second argument to `expect`.
|
|
2476
2553
|
*
|
|
2477
|
-
* expect('foobar').to.have.string(
|
|
2478
|
-
* expect('foobar', 'nooo why fail??').to.have.string(
|
|
2554
|
+
* expect('foobar').to.have.string('taco', 'nooo why fail??');
|
|
2555
|
+
* expect('foobar', 'nooo why fail??').to.have.string('taco');
|
|
2479
2556
|
*
|
|
2480
2557
|
* @name string
|
|
2481
2558
|
* @param {String} str
|
|
@@ -2502,7 +2579,7 @@ module.exports = function (chai, _) {
|
|
|
2502
2579
|
* ### .keys(key1[, key2[, ...]])
|
|
2503
2580
|
*
|
|
2504
2581
|
* Asserts that the target object, array, map, or set has the given keys. Only
|
|
2505
|
-
* the target's own inherited properties are included in the search.
|
|
2582
|
+
* the target's own inherited properties are included in the search.
|
|
2506
2583
|
*
|
|
2507
2584
|
* When the target is an object or array, keys can be provided as one or more
|
|
2508
2585
|
* string arguments, a single array argument, or a single object argument. In
|
|
@@ -2610,6 +2687,7 @@ module.exports = function (chai, _) {
|
|
|
2610
2687
|
, isDeep = flag(this, 'deep')
|
|
2611
2688
|
, str
|
|
2612
2689
|
, deepStr = ''
|
|
2690
|
+
, actual
|
|
2613
2691
|
, ok = true
|
|
2614
2692
|
, flagMsg = flag(this, 'message');
|
|
2615
2693
|
|
|
@@ -2626,7 +2704,6 @@ module.exports = function (chai, _) {
|
|
|
2626
2704
|
if (keysType !== 'Array') {
|
|
2627
2705
|
keys = Array.prototype.slice.call(arguments);
|
|
2628
2706
|
}
|
|
2629
|
-
|
|
2630
2707
|
} else {
|
|
2631
2708
|
actual = _.getOwnEnumerableProperties(obj);
|
|
2632
2709
|
|
|
@@ -2659,8 +2736,7 @@ module.exports = function (chai, _) {
|
|
|
2659
2736
|
var len = keys.length
|
|
2660
2737
|
, any = flag(this, 'any')
|
|
2661
2738
|
, all = flag(this, 'all')
|
|
2662
|
-
, expected = keys
|
|
2663
|
-
, actual;
|
|
2739
|
+
, expected = keys;
|
|
2664
2740
|
|
|
2665
2741
|
if (!any && !all) {
|
|
2666
2742
|
all = true;
|
|
@@ -2737,7 +2813,7 @@ module.exports = function (chai, _) {
|
|
|
2737
2813
|
*
|
|
2738
2814
|
* When no arguments are provided, `.throw` invokes the target function and
|
|
2739
2815
|
* asserts that an error is thrown.
|
|
2740
|
-
*
|
|
2816
|
+
*
|
|
2741
2817
|
* var badFn = function () { throw new TypeError('Illegal salmon!'); };
|
|
2742
2818
|
*
|
|
2743
2819
|
* expect(badFn).to.throw();
|
|
@@ -2789,11 +2865,11 @@ module.exports = function (chai, _) {
|
|
|
2789
2865
|
* expect(badFn).to.throw(err, /salmon/);
|
|
2790
2866
|
*
|
|
2791
2867
|
* Add `.not` earlier in the chain to negate `.throw`.
|
|
2792
|
-
*
|
|
2868
|
+
*
|
|
2793
2869
|
* var goodFn = function () {};
|
|
2794
2870
|
*
|
|
2795
2871
|
* expect(goodFn).to.not.throw();
|
|
2796
|
-
*
|
|
2872
|
+
*
|
|
2797
2873
|
* However, it's dangerous to negate `.throw` when providing any arguments.
|
|
2798
2874
|
* The problem is that it creates uncertain expectations by asserting that the
|
|
2799
2875
|
* target either doesn't throw an error, or that it throws an error but of a
|
|
@@ -3141,7 +3217,7 @@ module.exports = function (chai, _) {
|
|
|
3141
3217
|
* first argument, and asserts that the value returned is truthy.
|
|
3142
3218
|
*
|
|
3143
3219
|
* expect(1).to.satisfy(function(num) {
|
|
3144
|
-
* return num > 0;
|
|
3220
|
+
* return num > 0;
|
|
3145
3221
|
* });
|
|
3146
3222
|
*
|
|
3147
3223
|
* Add `.not` earlier in the chain to negate `.satisfy`.
|
|
@@ -3362,7 +3438,7 @@ module.exports = function (chai, _) {
|
|
|
3362
3438
|
var contains = flag(this, 'contains');
|
|
3363
3439
|
var ordered = flag(this, 'ordered');
|
|
3364
3440
|
|
|
3365
|
-
var subject, failMsg, failNegateMsg
|
|
3441
|
+
var subject, failMsg, failNegateMsg;
|
|
3366
3442
|
|
|
3367
3443
|
if (contains) {
|
|
3368
3444
|
subject = ordered ? 'an ordered superset' : 'a superset';
|
|
@@ -3434,7 +3510,6 @@ module.exports = function (chai, _) {
|
|
|
3434
3510
|
|
|
3435
3511
|
Assertion.addMethod('oneOf', oneOf);
|
|
3436
3512
|
|
|
3437
|
-
|
|
3438
3513
|
/**
|
|
3439
3514
|
* ### .change(subject[, prop[, msg]])
|
|
3440
3515
|
*
|
|
@@ -3610,7 +3685,7 @@ module.exports = function (chai, _) {
|
|
|
3610
3685
|
*
|
|
3611
3686
|
* expect(subtractTwo).to.decrease(myObj, 'val').by(2); // Recommended
|
|
3612
3687
|
* expect(subtractTwo).to.not.increase(myObj, 'val'); // Not recommended
|
|
3613
|
-
*
|
|
3688
|
+
*
|
|
3614
3689
|
* When the subject is expected to stay the same, it's often best to assert
|
|
3615
3690
|
* exactly that.
|
|
3616
3691
|
*
|
|
@@ -3707,7 +3782,7 @@ module.exports = function (chai, _) {
|
|
|
3707
3782
|
*
|
|
3708
3783
|
* When two arguments are provided, `.decrease` asserts that the value of the
|
|
3709
3784
|
* given object `subject`'s `prop` property is lesser after invoking the
|
|
3710
|
-
* target function compared to beforehand.
|
|
3785
|
+
* target function compared to beforehand.
|
|
3711
3786
|
*
|
|
3712
3787
|
* var myObj = {val: 1}
|
|
3713
3788
|
* , subtractTwo = function () { myObj.val -= 2; };
|
|
@@ -3729,7 +3804,7 @@ module.exports = function (chai, _) {
|
|
|
3729
3804
|
*
|
|
3730
3805
|
* expect(addTwo).to.increase(myObj, 'val').by(2); // Recommended
|
|
3731
3806
|
* expect(addTwo).to.not.decrease(myObj, 'val'); // Not recommended
|
|
3732
|
-
*
|
|
3807
|
+
*
|
|
3733
3808
|
* When the subject is expected to stay the same, it's often best to assert
|
|
3734
3809
|
* exactly that.
|
|
3735
3810
|
*
|
|
@@ -4082,7 +4157,7 @@ module.exports = function (chai, _) {
|
|
|
4082
4157
|
var obj = flag(this, 'object');
|
|
4083
4158
|
|
|
4084
4159
|
this.assert(
|
|
4085
|
-
typeof obj ===
|
|
4160
|
+
typeof obj === 'number' && isFinite(obj)
|
|
4086
4161
|
, 'expected #{this} to be a finite number'
|
|
4087
4162
|
, 'expected #{this} to not be a finite number'
|
|
4088
4163
|
);
|
|
@@ -4096,9 +4171,7 @@ module.exports = function (chai, _) {
|
|
|
4096
4171
|
* MIT Licensed
|
|
4097
4172
|
*/
|
|
4098
4173
|
|
|
4099
|
-
|
|
4100
4174
|
module.exports = function (chai, util) {
|
|
4101
|
-
|
|
4102
4175
|
/*!
|
|
4103
4176
|
* Chai dependencies.
|
|
4104
4177
|
*/
|
|
@@ -4135,10 +4208,18 @@ module.exports = function (chai, util) {
|
|
|
4135
4208
|
};
|
|
4136
4209
|
|
|
4137
4210
|
/**
|
|
4211
|
+
* ### .fail([message])
|
|
4138
4212
|
* ### .fail(actual, expected, [message], [operator])
|
|
4139
4213
|
*
|
|
4140
4214
|
* Throw a failure. Node.js `assert` module-compatible.
|
|
4141
4215
|
*
|
|
4216
|
+
* assert.fail();
|
|
4217
|
+
* assert.fail("custom error message");
|
|
4218
|
+
* assert.fail(1, 2);
|
|
4219
|
+
* assert.fail(1, 2, "custom error message");
|
|
4220
|
+
* assert.fail(1, 2, "custom error message", ">");
|
|
4221
|
+
* assert.fail(1, 2, undefined, ">");
|
|
4222
|
+
*
|
|
4142
4223
|
* @name fail
|
|
4143
4224
|
* @param {Mixed} actual
|
|
4144
4225
|
* @param {Mixed} expected
|
|
@@ -4149,6 +4230,13 @@ module.exports = function (chai, util) {
|
|
|
4149
4230
|
*/
|
|
4150
4231
|
|
|
4151
4232
|
assert.fail = function (actual, expected, message, operator) {
|
|
4233
|
+
if (arguments.length < 2) {
|
|
4234
|
+
// Comply with Node's fail([message]) interface
|
|
4235
|
+
|
|
4236
|
+
message = actual;
|
|
4237
|
+
actual = undefined;
|
|
4238
|
+
}
|
|
4239
|
+
|
|
4152
4240
|
message = message || 'assert.fail()';
|
|
4153
4241
|
throw new chai.AssertionError(message, {
|
|
4154
4242
|
actual: actual
|
|
@@ -4998,7 +5086,7 @@ module.exports = function (chai, util) {
|
|
|
4998
5086
|
* an array, the array is searched for an element that's strictly equal to the
|
|
4999
5087
|
* given value. When asserting a subset of properties in an object, the object
|
|
5000
5088
|
* is searched for the given property keys, checking that each one is present
|
|
5001
|
-
* and
|
|
5089
|
+
* and strictly equal to the given property value. For instance:
|
|
5002
5090
|
*
|
|
5003
5091
|
* var obj1 = {a: 1}
|
|
5004
5092
|
* , obj2 = {b: 2};
|
|
@@ -5025,8 +5113,8 @@ module.exports = function (chai, util) {
|
|
|
5025
5113
|
* the absence of a value in an array, a substring in a string, or a subset of
|
|
5026
5114
|
* properties in an object.
|
|
5027
5115
|
*
|
|
5028
|
-
* assert.notInclude([1,2,3], 4,
|
|
5029
|
-
* assert.notInclude('foobar', 'baz',
|
|
5116
|
+
* assert.notInclude([1,2,3], 4, "array doesn't contain value");
|
|
5117
|
+
* assert.notInclude('foobar', 'baz', "string doesn't contain substring");
|
|
5030
5118
|
* assert.notInclude({ foo: 'bar', hello: 'universe' }, { foo: 'baz' }, 'object doesn't contain property');
|
|
5031
5119
|
*
|
|
5032
5120
|
* Strict equality (===) is used. When asserting the absence of a value in an
|
|
@@ -5106,24 +5194,24 @@ module.exports = function (chai, util) {
|
|
|
5106
5194
|
|
|
5107
5195
|
/**
|
|
5108
5196
|
* ### .nestedInclude(haystack, needle, [message])
|
|
5109
|
-
*
|
|
5110
|
-
* Asserts that 'haystack' includes 'needle'.
|
|
5111
|
-
* Can be used to assert the inclusion of a subset of properties in an
|
|
5197
|
+
*
|
|
5198
|
+
* Asserts that 'haystack' includes 'needle'.
|
|
5199
|
+
* Can be used to assert the inclusion of a subset of properties in an
|
|
5112
5200
|
* object.
|
|
5113
|
-
* Enables the use of dot- and bracket-notation for referencing nested
|
|
5201
|
+
* Enables the use of dot- and bracket-notation for referencing nested
|
|
5114
5202
|
* properties.
|
|
5115
5203
|
* '[]' and '.' in property names can be escaped using double backslashes.
|
|
5116
|
-
*
|
|
5204
|
+
*
|
|
5117
5205
|
* assert.nestedInclude({'.a': {'b': 'x'}}, {'\\.a.[b]': 'x'});
|
|
5118
5206
|
* assert.nestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'x'});
|
|
5119
|
-
*
|
|
5207
|
+
*
|
|
5120
5208
|
* @name nestedInclude
|
|
5121
5209
|
* @param {Object} haystack
|
|
5122
5210
|
* @param {Object} needle
|
|
5123
5211
|
* @param {String} message
|
|
5124
5212
|
* @namespace Assert
|
|
5125
|
-
* @api public
|
|
5126
|
-
*/
|
|
5213
|
+
* @api public
|
|
5214
|
+
*/
|
|
5127
5215
|
|
|
5128
5216
|
assert.nestedInclude = function (exp, inc, msg) {
|
|
5129
5217
|
new Assertion(exp, msg, assert.nestedInclude, true).nested.include(inc);
|
|
@@ -5131,24 +5219,24 @@ module.exports = function (chai, util) {
|
|
|
5131
5219
|
|
|
5132
5220
|
/**
|
|
5133
5221
|
* ### .notNestedInclude(haystack, needle, [message])
|
|
5134
|
-
*
|
|
5135
|
-
* Asserts that 'haystack' does not include 'needle'.
|
|
5136
|
-
* Can be used to assert the absence of a subset of properties in an
|
|
5222
|
+
*
|
|
5223
|
+
* Asserts that 'haystack' does not include 'needle'.
|
|
5224
|
+
* Can be used to assert the absence of a subset of properties in an
|
|
5137
5225
|
* object.
|
|
5138
|
-
* Enables the use of dot- and bracket-notation for referencing nested
|
|
5139
|
-
* properties.
|
|
5226
|
+
* Enables the use of dot- and bracket-notation for referencing nested
|
|
5227
|
+
* properties.
|
|
5140
5228
|
* '[]' and '.' in property names can be escaped using double backslashes.
|
|
5141
|
-
*
|
|
5229
|
+
*
|
|
5142
5230
|
* assert.notNestedInclude({'.a': {'b': 'x'}}, {'\\.a.b': 'y'});
|
|
5143
5231
|
* assert.notNestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'y'});
|
|
5144
|
-
*
|
|
5232
|
+
*
|
|
5145
5233
|
* @name notNestedInclude
|
|
5146
5234
|
* @param {Object} haystack
|
|
5147
5235
|
* @param {Object} needle
|
|
5148
5236
|
* @param {String} message
|
|
5149
5237
|
* @namespace Assert
|
|
5150
|
-
* @api public
|
|
5151
|
-
*/
|
|
5238
|
+
* @api public
|
|
5239
|
+
*/
|
|
5152
5240
|
|
|
5153
5241
|
assert.notNestedInclude = function (exp, inc, msg) {
|
|
5154
5242
|
new Assertion(exp, msg, assert.notNestedInclude, true)
|
|
@@ -5157,23 +5245,23 @@ module.exports = function (chai, util) {
|
|
|
5157
5245
|
|
|
5158
5246
|
/**
|
|
5159
5247
|
* ### .deepNestedInclude(haystack, needle, [message])
|
|
5160
|
-
*
|
|
5248
|
+
*
|
|
5161
5249
|
* Asserts that 'haystack' includes 'needle'.
|
|
5162
|
-
* Can be used to assert the inclusion of a subset of properties in an
|
|
5250
|
+
* Can be used to assert the inclusion of a subset of properties in an
|
|
5163
5251
|
* object while checking for deep equality.
|
|
5164
|
-
* Enables the use of dot- and bracket-notation for referencing nested
|
|
5252
|
+
* Enables the use of dot- and bracket-notation for referencing nested
|
|
5165
5253
|
* properties.
|
|
5166
5254
|
* '[]' and '.' in property names can be escaped using double backslashes.
|
|
5167
|
-
*
|
|
5255
|
+
*
|
|
5168
5256
|
* assert.deepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {x: 1}});
|
|
5169
5257
|
* assert.deepNestedInclude({'.a': {'[b]': {x: 1}}}, {'\\.a.\\[b\\]': {x: 1}});
|
|
5170
|
-
*
|
|
5258
|
+
*
|
|
5171
5259
|
* @name deepNestedInclude
|
|
5172
5260
|
* @param {Object} haystack
|
|
5173
5261
|
* @param {Object} needle
|
|
5174
5262
|
* @param {String} message
|
|
5175
5263
|
* @namespace Assert
|
|
5176
|
-
* @api public
|
|
5264
|
+
* @api public
|
|
5177
5265
|
*/
|
|
5178
5266
|
|
|
5179
5267
|
assert.deepNestedInclude = function(exp, inc, msg) {
|
|
@@ -5183,23 +5271,23 @@ module.exports = function (chai, util) {
|
|
|
5183
5271
|
|
|
5184
5272
|
/**
|
|
5185
5273
|
* ### .notDeepNestedInclude(haystack, needle, [message])
|
|
5186
|
-
*
|
|
5274
|
+
*
|
|
5187
5275
|
* Asserts that 'haystack' does not include 'needle'.
|
|
5188
|
-
* Can be used to assert the absence of a subset of properties in an
|
|
5276
|
+
* Can be used to assert the absence of a subset of properties in an
|
|
5189
5277
|
* object while checking for deep equality.
|
|
5190
|
-
* Enables the use of dot- and bracket-notation for referencing nested
|
|
5278
|
+
* Enables the use of dot- and bracket-notation for referencing nested
|
|
5191
5279
|
* properties.
|
|
5192
5280
|
* '[]' and '.' in property names can be escaped using double backslashes.
|
|
5193
|
-
*
|
|
5281
|
+
*
|
|
5194
5282
|
* assert.notDeepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {y: 1}})
|
|
5195
5283
|
* assert.notDeepNestedInclude({'.a': {'[b]': {x: 1}}}, {'\\.a.\\[b\\]': {y: 2}});
|
|
5196
|
-
*
|
|
5284
|
+
*
|
|
5197
5285
|
* @name notDeepNestedInclude
|
|
5198
5286
|
* @param {Object} haystack
|
|
5199
5287
|
* @param {Object} needle
|
|
5200
5288
|
* @param {String} message
|
|
5201
5289
|
* @namespace Assert
|
|
5202
|
-
* @api public
|
|
5290
|
+
* @api public
|
|
5203
5291
|
*/
|
|
5204
5292
|
|
|
5205
5293
|
assert.notDeepNestedInclude = function(exp, inc, msg) {
|
|
@@ -5209,13 +5297,13 @@ module.exports = function (chai, util) {
|
|
|
5209
5297
|
|
|
5210
5298
|
/**
|
|
5211
5299
|
* ### .ownInclude(haystack, needle, [message])
|
|
5212
|
-
*
|
|
5300
|
+
*
|
|
5213
5301
|
* Asserts that 'haystack' includes 'needle'.
|
|
5214
|
-
* Can be used to assert the inclusion of a subset of properties in an
|
|
5302
|
+
* Can be used to assert the inclusion of a subset of properties in an
|
|
5215
5303
|
* object while ignoring inherited properties.
|
|
5216
|
-
*
|
|
5304
|
+
*
|
|
5217
5305
|
* assert.ownInclude({ a: 1 }, { a: 1 });
|
|
5218
|
-
*
|
|
5306
|
+
*
|
|
5219
5307
|
* @name ownInclude
|
|
5220
5308
|
* @param {Object} haystack
|
|
5221
5309
|
* @param {Object} needle
|
|
@@ -5230,15 +5318,15 @@ module.exports = function (chai, util) {
|
|
|
5230
5318
|
|
|
5231
5319
|
/**
|
|
5232
5320
|
* ### .notOwnInclude(haystack, needle, [message])
|
|
5233
|
-
*
|
|
5321
|
+
*
|
|
5234
5322
|
* Asserts that 'haystack' includes 'needle'.
|
|
5235
|
-
* Can be used to assert the absence of a subset of properties in an
|
|
5323
|
+
* Can be used to assert the absence of a subset of properties in an
|
|
5236
5324
|
* object while ignoring inherited properties.
|
|
5237
|
-
*
|
|
5325
|
+
*
|
|
5238
5326
|
* Object.prototype.b = 2;
|
|
5239
|
-
*
|
|
5327
|
+
*
|
|
5240
5328
|
* assert.notOwnInclude({ a: 1 }, { b: 2 });
|
|
5241
|
-
*
|
|
5329
|
+
*
|
|
5242
5330
|
* @name notOwnInclude
|
|
5243
5331
|
* @param {Object} haystack
|
|
5244
5332
|
* @param {Object} needle
|
|
@@ -5253,13 +5341,13 @@ module.exports = function (chai, util) {
|
|
|
5253
5341
|
|
|
5254
5342
|
/**
|
|
5255
5343
|
* ### .deepOwnInclude(haystack, needle, [message])
|
|
5256
|
-
*
|
|
5344
|
+
*
|
|
5257
5345
|
* Asserts that 'haystack' includes 'needle'.
|
|
5258
|
-
* Can be used to assert the inclusion of a subset of properties in an
|
|
5346
|
+
* Can be used to assert the inclusion of a subset of properties in an
|
|
5259
5347
|
* object while ignoring inherited properties and checking for deep equality.
|
|
5260
|
-
*
|
|
5348
|
+
*
|
|
5261
5349
|
* assert.deepOwnInclude({a: {b: 2}}, {a: {b: 2}});
|
|
5262
|
-
*
|
|
5350
|
+
*
|
|
5263
5351
|
* @name deepOwnInclude
|
|
5264
5352
|
* @param {Object} haystack
|
|
5265
5353
|
* @param {Object} needle
|
|
@@ -5275,13 +5363,13 @@ module.exports = function (chai, util) {
|
|
|
5275
5363
|
|
|
5276
5364
|
/**
|
|
5277
5365
|
* ### .notDeepOwnInclude(haystack, needle, [message])
|
|
5278
|
-
*
|
|
5366
|
+
*
|
|
5279
5367
|
* Asserts that 'haystack' includes 'needle'.
|
|
5280
|
-
* Can be used to assert the absence of a subset of properties in an
|
|
5368
|
+
* Can be used to assert the absence of a subset of properties in an
|
|
5281
5369
|
* object while ignoring inherited properties and checking for deep equality.
|
|
5282
|
-
*
|
|
5370
|
+
*
|
|
5283
5371
|
* assert.notDeepOwnInclude({a: {b: 2}}, {a: {c: 3}});
|
|
5284
|
-
*
|
|
5372
|
+
*
|
|
5285
5373
|
* @name notDeepOwnInclude
|
|
5286
5374
|
* @param {Object} haystack
|
|
5287
5375
|
* @param {Object} needle
|
|
@@ -5743,10 +5831,12 @@ module.exports = function (chai, util) {
|
|
|
5743
5831
|
/**
|
|
5744
5832
|
* ### .lengthOf(object, length, [message])
|
|
5745
5833
|
*
|
|
5746
|
-
* Asserts that `object` has a `length`
|
|
5834
|
+
* Asserts that `object` has a `length` or `size` with the expected value.
|
|
5747
5835
|
*
|
|
5748
5836
|
* assert.lengthOf([1,2,3], 3, 'array has length of 3');
|
|
5749
5837
|
* assert.lengthOf('foobar', 6, 'string has length of 6');
|
|
5838
|
+
* assert.lengthOf(new Set([1,2,3]), 3, 'set has size of 3');
|
|
5839
|
+
* assert.lengthOf(new Map([['a',1],['b',2],['c',3]]), 3, 'map has size of 3');
|
|
5750
5840
|
*
|
|
5751
5841
|
* @name lengthOf
|
|
5752
5842
|
* @param {Mixed} object
|
|
@@ -6034,8 +6124,8 @@ module.exports = function (chai, util) {
|
|
|
6034
6124
|
* If `errMsgMatcher` is provided, it also asserts that the error thrown will have a
|
|
6035
6125
|
* message matching `errMsgMatcher`.
|
|
6036
6126
|
*
|
|
6037
|
-
* assert.throws(fn, '
|
|
6038
|
-
* assert.throws(fn, /
|
|
6127
|
+
* assert.throws(fn, 'Error thrown must have this msg');
|
|
6128
|
+
* assert.throws(fn, /Error thrown must have a msg that matches this/);
|
|
6039
6129
|
* assert.throws(fn, ReferenceError);
|
|
6040
6130
|
* assert.throws(fn, errorInstance);
|
|
6041
6131
|
* assert.throws(fn, ReferenceError, 'Error thrown must be a ReferenceError and have this msg');
|
|
@@ -7202,10 +7292,18 @@ module.exports = function (chai, util) {
|
|
|
7202
7292
|
};
|
|
7203
7293
|
|
|
7204
7294
|
/**
|
|
7295
|
+
* ### .fail([message])
|
|
7205
7296
|
* ### .fail(actual, expected, [message], [operator])
|
|
7206
7297
|
*
|
|
7207
7298
|
* Throw a failure.
|
|
7208
7299
|
*
|
|
7300
|
+
* expect.fail();
|
|
7301
|
+
* expect.fail("custom error message");
|
|
7302
|
+
* expect.fail(1, 2);
|
|
7303
|
+
* expect.fail(1, 2, "custom error message");
|
|
7304
|
+
* expect.fail(1, 2, "custom error message", ">");
|
|
7305
|
+
* expect.fail(1, 2, undefined, ">");
|
|
7306
|
+
*
|
|
7209
7307
|
* @name fail
|
|
7210
7308
|
* @param {Mixed} actual
|
|
7211
7309
|
* @param {Mixed} expected
|
|
@@ -7216,6 +7314,11 @@ module.exports = function (chai, util) {
|
|
|
7216
7314
|
*/
|
|
7217
7315
|
|
|
7218
7316
|
chai.expect.fail = function (actual, expected, message, operator) {
|
|
7317
|
+
if (arguments.length < 2) {
|
|
7318
|
+
message = actual;
|
|
7319
|
+
actual = undefined;
|
|
7320
|
+
}
|
|
7321
|
+
|
|
7219
7322
|
message = message || 'expect.fail()';
|
|
7220
7323
|
throw new chai.AssertionError(message, {
|
|
7221
7324
|
actual: actual
|
|
@@ -7270,10 +7373,19 @@ module.exports = function (chai, util) {
|
|
|
7270
7373
|
var should = {};
|
|
7271
7374
|
|
|
7272
7375
|
/**
|
|
7376
|
+
* ### .fail([message])
|
|
7273
7377
|
* ### .fail(actual, expected, [message], [operator])
|
|
7274
7378
|
*
|
|
7275
7379
|
* Throw a failure.
|
|
7276
7380
|
*
|
|
7381
|
+
* should.fail();
|
|
7382
|
+
* should.fail("custom error message");
|
|
7383
|
+
* should.fail(1, 2);
|
|
7384
|
+
* should.fail(1, 2, "custom error message");
|
|
7385
|
+
* should.fail(1, 2, "custom error message", ">");
|
|
7386
|
+
* should.fail(1, 2, undefined, ">");
|
|
7387
|
+
*
|
|
7388
|
+
*
|
|
7277
7389
|
* @name fail
|
|
7278
7390
|
* @param {Mixed} actual
|
|
7279
7391
|
* @param {Mixed} expected
|
|
@@ -7284,6 +7396,11 @@ module.exports = function (chai, util) {
|
|
|
7284
7396
|
*/
|
|
7285
7397
|
|
|
7286
7398
|
should.fail = function (actual, expected, message, operator) {
|
|
7399
|
+
if (arguments.length < 2) {
|
|
7400
|
+
message = actual;
|
|
7401
|
+
actual = undefined;
|
|
7402
|
+
}
|
|
7403
|
+
|
|
7287
7404
|
message = message || 'should.fail()';
|
|
7288
7405
|
throw new chai.AssertionError(message, {
|
|
7289
7406
|
actual: actual
|
|
@@ -7586,8 +7703,6 @@ module.exports = function addChainableMethod(ctx, name, method, chainingBehavior
|
|
|
7586
7703
|
};
|
|
7587
7704
|
|
|
7588
7705
|
},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":30,"./transferFlags":32}],10:[function(require,module,exports){
|
|
7589
|
-
var config = require('../config');
|
|
7590
|
-
|
|
7591
7706
|
var fnLengthDesc = Object.getOwnPropertyDescriptor(function () {}, 'length');
|
|
7592
7707
|
|
|
7593
7708
|
/*!
|
|
@@ -7649,7 +7764,7 @@ module.exports = function addLengthGuard (fn, assertionName, isChainable) {
|
|
|
7649
7764
|
return fn;
|
|
7650
7765
|
};
|
|
7651
7766
|
|
|
7652
|
-
},{
|
|
7767
|
+
},{}],11:[function(require,module,exports){
|
|
7653
7768
|
/*!
|
|
7654
7769
|
* Chai - addMethod utility
|
|
7655
7770
|
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -7801,7 +7916,7 @@ module.exports = function addProperty(ctx, name, getter) {
|
|
|
7801
7916
|
*/
|
|
7802
7917
|
|
|
7803
7918
|
/*!
|
|
7804
|
-
* Module
|
|
7919
|
+
* Module dependencies
|
|
7805
7920
|
*/
|
|
7806
7921
|
|
|
7807
7922
|
var inspect = require('./inspect');
|
|
@@ -7816,7 +7931,7 @@ var inspect = require('./inspect');
|
|
|
7816
7931
|
*
|
|
7817
7932
|
* @param {Mixed} first element to compare
|
|
7818
7933
|
* @param {Mixed} second element to compare
|
|
7819
|
-
* @returns {Number} -1 if 'a' should come before 'b'; otherwise 1
|
|
7934
|
+
* @returns {Number} -1 if 'a' should come before 'b'; otherwise 1
|
|
7820
7935
|
* @name compareByInspect
|
|
7821
7936
|
* @namespace Utils
|
|
7822
7937
|
* @api public
|
|
@@ -7972,12 +8087,11 @@ module.exports = function getEnumerableProperties(object) {
|
|
|
7972
8087
|
*/
|
|
7973
8088
|
|
|
7974
8089
|
/*!
|
|
7975
|
-
* Module
|
|
8090
|
+
* Module dependencies
|
|
7976
8091
|
*/
|
|
7977
8092
|
|
|
7978
8093
|
var flag = require('./flag')
|
|
7979
8094
|
, getActual = require('./getActual')
|
|
7980
|
-
, inspect = require('./inspect')
|
|
7981
8095
|
, objDisplay = require('./objDisplay');
|
|
7982
8096
|
|
|
7983
8097
|
/**
|
|
@@ -8017,7 +8131,7 @@ module.exports = function getMessage(obj, args) {
|
|
|
8017
8131
|
return flagMsg ? flagMsg + ': ' + msg : msg;
|
|
8018
8132
|
};
|
|
8019
8133
|
|
|
8020
|
-
},{"./flag":15,"./getActual":16,"./
|
|
8134
|
+
},{"./flag":15,"./getActual":16,"./objDisplay":26}],19:[function(require,module,exports){
|
|
8021
8135
|
/*!
|
|
8022
8136
|
* Chai - getOwnEnumerableProperties utility
|
|
8023
8137
|
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
@@ -8025,7 +8139,7 @@ module.exports = function getMessage(obj, args) {
|
|
|
8025
8139
|
*/
|
|
8026
8140
|
|
|
8027
8141
|
/*!
|
|
8028
|
-
* Module
|
|
8142
|
+
* Module dependencies
|
|
8029
8143
|
*/
|
|
8030
8144
|
|
|
8031
8145
|
var getOwnEnumerablePropertySymbols = require('./getOwnEnumerablePropertySymbols');
|
|
@@ -8397,7 +8511,7 @@ function formatValue(ctx, value, recurseTimes) {
|
|
|
8397
8511
|
|
|
8398
8512
|
var name, nameSuffix;
|
|
8399
8513
|
|
|
8400
|
-
// Some type of object without properties can be
|
|
8514
|
+
// Some type of object without properties can be shortcut.
|
|
8401
8515
|
// In IE, errors have a single `stack` property, or if they are vanilla `Error`,
|
|
8402
8516
|
// a `stack` plus `description` property; ignore those for consistency.
|
|
8403
8517
|
if (keys.length === 0 || (isError(value) && (
|
|
@@ -8488,7 +8602,6 @@ function formatValue(ctx, value, recurseTimes) {
|
|
|
8488
8602
|
return reduceToSingleString(output, base, braces);
|
|
8489
8603
|
}
|
|
8490
8604
|
|
|
8491
|
-
|
|
8492
8605
|
function formatPrimitive(ctx, value) {
|
|
8493
8606
|
switch (typeof value) {
|
|
8494
8607
|
case 'undefined':
|
|
@@ -8518,12 +8631,10 @@ function formatPrimitive(ctx, value) {
|
|
|
8518
8631
|
}
|
|
8519
8632
|
}
|
|
8520
8633
|
|
|
8521
|
-
|
|
8522
8634
|
function formatError(value) {
|
|
8523
8635
|
return '[' + Error.prototype.toString.call(value) + ']';
|
|
8524
8636
|
}
|
|
8525
8637
|
|
|
8526
|
-
|
|
8527
8638
|
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
|
8528
8639
|
var output = [];
|
|
8529
8640
|
for (var i = 0, l = value.length; i < l; ++i) {
|
|
@@ -8626,12 +8737,8 @@ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
|
|
8626
8737
|
return name + ': ' + str;
|
|
8627
8738
|
}
|
|
8628
8739
|
|
|
8629
|
-
|
|
8630
8740
|
function reduceToSingleString(output, base, braces) {
|
|
8631
|
-
var numLinesEst = 0;
|
|
8632
8741
|
var length = output.reduce(function(prev, cur) {
|
|
8633
|
-
numLinesEst++;
|
|
8634
|
-
if (cur.indexOf('\n') >= 0) numLinesEst++;
|
|
8635
8742
|
return prev + cur.length + 1;
|
|
8636
8743
|
}, 0);
|
|
8637
8744
|
|
|
@@ -8723,7 +8830,7 @@ var config = require('../config');
|
|
|
8723
8830
|
*/
|
|
8724
8831
|
|
|
8725
8832
|
module.exports = function isProxyEnabled() {
|
|
8726
|
-
return config.useProxy &&
|
|
8833
|
+
return config.useProxy &&
|
|
8727
8834
|
typeof Proxy !== 'undefined' &&
|
|
8728
8835
|
typeof Reflect !== 'undefined';
|
|
8729
8836
|
};
|
|
@@ -8736,7 +8843,7 @@ module.exports = function isProxyEnabled() {
|
|
|
8736
8843
|
*/
|
|
8737
8844
|
|
|
8738
8845
|
/*!
|
|
8739
|
-
* Module
|
|
8846
|
+
* Module dependencies
|
|
8740
8847
|
*/
|
|
8741
8848
|
|
|
8742
8849
|
var inspect = require('./inspect');
|
|
@@ -8793,7 +8900,7 @@ var transferFlags = require('./transferFlags');
|
|
|
8793
8900
|
/**
|
|
8794
8901
|
* ### .overwriteChainableMethod(ctx, name, method, chainingBehavior)
|
|
8795
8902
|
*
|
|
8796
|
-
*
|
|
8903
|
+
* Overwrites an already existing chainable method
|
|
8797
8904
|
* and provides access to the previous function or
|
|
8798
8905
|
* property. Must return functions to be used for
|
|
8799
8906
|
* name.
|
|
@@ -8867,7 +8974,7 @@ var transferFlags = require('./transferFlags');
|
|
|
8867
8974
|
/**
|
|
8868
8975
|
* ### .overwriteMethod(ctx, name, fn)
|
|
8869
8976
|
*
|
|
8870
|
-
*
|
|
8977
|
+
* Overwrites an already existing method and provides
|
|
8871
8978
|
* access to previous function. Must return function
|
|
8872
8979
|
* to be used for name.
|
|
8873
8980
|
*
|
|
@@ -8960,7 +9067,7 @@ var transferFlags = require('./transferFlags');
|
|
|
8960
9067
|
/**
|
|
8961
9068
|
* ### .overwriteProperty(ctx, name, fn)
|
|
8962
9069
|
*
|
|
8963
|
-
*
|
|
9070
|
+
* Overwrites an already existing property getter and provides
|
|
8964
9071
|
* access to previous value. Must return function to use as getter.
|
|
8965
9072
|
*
|
|
8966
9073
|
* utils.overwriteProperty(chai.Assertion.prototype, 'ok', function (_super) {
|
|
@@ -9060,7 +9167,7 @@ var isProxyEnabled = require('./isProxyEnabled');
|
|
|
9060
9167
|
* the list of existing properties. However, if a nonChainableMethodName is
|
|
9061
9168
|
* provided, then the root cause is instead a failure to invoke a non-chainable
|
|
9062
9169
|
* method prior to reading the non-existent property.
|
|
9063
|
-
*
|
|
9170
|
+
*
|
|
9064
9171
|
* If proxies are unsupported or disabled via the user's Chai config, then
|
|
9065
9172
|
* return object without modification.
|
|
9066
9173
|
*
|
|
@@ -9091,19 +9198,31 @@ module.exports = function proxify(obj, nonChainableMethodName) {
|
|
|
9091
9198
|
nonChainableMethodName + '".');
|
|
9092
9199
|
}
|
|
9093
9200
|
|
|
9094
|
-
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
|
|
9201
|
+
// If the property is reasonably close to an existing Chai property,
|
|
9202
|
+
// suggest that property to the user. Only suggest properties with a
|
|
9203
|
+
// distance less than 4.
|
|
9204
|
+
var suggestion = null;
|
|
9205
|
+
var suggestionDistance = 4;
|
|
9206
|
+
getProperties(target).forEach(function(prop) {
|
|
9207
|
+
if (
|
|
9208
|
+
!Object.prototype.hasOwnProperty(prop) &&
|
|
9209
|
+
builtins.indexOf(prop) === -1
|
|
9210
|
+
) {
|
|
9211
|
+
var dist = stringDistanceCapped(
|
|
9212
|
+
property,
|
|
9213
|
+
prop,
|
|
9214
|
+
suggestionDistance
|
|
9215
|
+
);
|
|
9216
|
+
if (dist < suggestionDistance) {
|
|
9217
|
+
suggestion = prop;
|
|
9218
|
+
suggestionDistance = dist;
|
|
9219
|
+
}
|
|
9220
|
+
}
|
|
9099
9221
|
});
|
|
9100
9222
|
|
|
9101
|
-
if (
|
|
9102
|
-
stringDistance(orderedProperties[0], property) < 4) {
|
|
9103
|
-
// If the property is reasonably close to an existing Chai property,
|
|
9104
|
-
// suggest that property to the user.
|
|
9223
|
+
if (suggestion !== null) {
|
|
9105
9224
|
throw Error('Invalid Chai property: ' + property +
|
|
9106
|
-
'. Did you mean "' +
|
|
9225
|
+
'. Did you mean "' + suggestion + '"?');
|
|
9107
9226
|
} else {
|
|
9108
9227
|
throw Error('Invalid Chai property: ' + property);
|
|
9109
9228
|
}
|
|
@@ -9131,34 +9250,44 @@ module.exports = function proxify(obj, nonChainableMethodName) {
|
|
|
9131
9250
|
};
|
|
9132
9251
|
|
|
9133
9252
|
/**
|
|
9134
|
-
* #
|
|
9135
|
-
* Return the Levenshtein distance between two strings.
|
|
9253
|
+
* # stringDistanceCapped(strA, strB, cap)
|
|
9254
|
+
* Return the Levenshtein distance between two strings, but no more than cap.
|
|
9136
9255
|
* @param {string} strA
|
|
9137
9256
|
* @param {string} strB
|
|
9138
|
-
* @
|
|
9257
|
+
* @param {number} number
|
|
9258
|
+
* @return {number} min(string distance between strA and strB, cap)
|
|
9139
9259
|
* @api private
|
|
9140
9260
|
*/
|
|
9141
9261
|
|
|
9142
|
-
function
|
|
9143
|
-
if (
|
|
9144
|
-
|
|
9145
|
-
// memo[i][j] is the distance between strA.slice(0, i) and
|
|
9146
|
-
// strB.slice(0, j).
|
|
9147
|
-
memo = [];
|
|
9148
|
-
for (var i = 0; i <= strA.length; i++) {
|
|
9149
|
-
memo[i] = [];
|
|
9150
|
-
}
|
|
9262
|
+
function stringDistanceCapped(strA, strB, cap) {
|
|
9263
|
+
if (Math.abs(strA.length - strB.length) >= cap) {
|
|
9264
|
+
return cap;
|
|
9151
9265
|
}
|
|
9152
9266
|
|
|
9153
|
-
|
|
9154
|
-
|
|
9155
|
-
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
|
-
|
|
9159
|
-
|
|
9160
|
-
|
|
9161
|
-
|
|
9267
|
+
var memo = [];
|
|
9268
|
+
// `memo` is a two-dimensional array containing distances.
|
|
9269
|
+
// memo[i][j] is the distance between strA.slice(0, i) and
|
|
9270
|
+
// strB.slice(0, j).
|
|
9271
|
+
for (var i = 0; i <= strA.length; i++) {
|
|
9272
|
+
memo[i] = Array(strB.length + 1).fill(0);
|
|
9273
|
+
memo[i][0] = i;
|
|
9274
|
+
}
|
|
9275
|
+
for (var j = 0; j < strB.length; j++) {
|
|
9276
|
+
memo[0][j] = j;
|
|
9277
|
+
}
|
|
9278
|
+
|
|
9279
|
+
for (var i = 1; i <= strA.length; i++) {
|
|
9280
|
+
var ch = strA.charCodeAt(i - 1);
|
|
9281
|
+
for (var j = 1; j <= strB.length; j++) {
|
|
9282
|
+
if (Math.abs(i - j) >= cap) {
|
|
9283
|
+
memo[i][j] = cap;
|
|
9284
|
+
continue;
|
|
9285
|
+
}
|
|
9286
|
+
memo[i][j] = Math.min(
|
|
9287
|
+
memo[i - 1][j] + 1,
|
|
9288
|
+
memo[i][j - 1] + 1,
|
|
9289
|
+
memo[i - 1][j - 1] +
|
|
9290
|
+
(ch === strB.charCodeAt(j - 1) ? 0 : 1)
|
|
9162
9291
|
);
|
|
9163
9292
|
}
|
|
9164
9293
|
}
|
|
@@ -9174,7 +9303,7 @@ function stringDistance(strA, strB, memo) {
|
|
|
9174
9303
|
*/
|
|
9175
9304
|
|
|
9176
9305
|
/*!
|
|
9177
|
-
* Module
|
|
9306
|
+
* Module dependencies
|
|
9178
9307
|
*/
|
|
9179
9308
|
|
|
9180
9309
|
var flag = require('./flag');
|
|
@@ -9215,7 +9344,7 @@ module.exports = function test(obj, args) {
|
|
|
9215
9344
|
* var newAssertion = new Assertion();
|
|
9216
9345
|
* utils.transferFlags(assertion, newAssertion);
|
|
9217
9346
|
*
|
|
9218
|
-
* var
|
|
9347
|
+
* var anotherAssertion = new Assertion(myObj);
|
|
9219
9348
|
* utils.transferFlags(assertion, anotherAssertion, false);
|
|
9220
9349
|
*
|
|
9221
9350
|
* @param {Assertion} assertion the assertion to transfer the flags from
|
|
@@ -9312,8 +9441,8 @@ function AssertionError (message, _props, ssf) {
|
|
|
9312
9441
|
}
|
|
9313
9442
|
|
|
9314
9443
|
// capture stack trace
|
|
9315
|
-
ssf = ssf ||
|
|
9316
|
-
if (
|
|
9444
|
+
ssf = ssf || AssertionError;
|
|
9445
|
+
if (Error.captureStackTrace) {
|
|
9317
9446
|
Error.captureStackTrace(this, ssf);
|
|
9318
9447
|
} else {
|
|
9319
9448
|
try {
|
|
@@ -9554,7 +9683,7 @@ FakeMap.prototype = {
|
|
|
9554
9683
|
return key[this._key];
|
|
9555
9684
|
},
|
|
9556
9685
|
set: function setMap(key, value) {
|
|
9557
|
-
if (
|
|
9686
|
+
if (Object.isExtensible(key)) {
|
|
9558
9687
|
Object.defineProperty(key, this._key, {
|
|
9559
9688
|
value: value,
|
|
9560
9689
|
configurable: true,
|
|
@@ -10332,7 +10461,11 @@ module.exports = {
|
|
|
10332
10461
|
};
|
|
10333
10462
|
|
|
10334
10463
|
},{}],38:[function(require,module,exports){
|
|
10335
|
-
|
|
10464
|
+
(function (global, factory) {
|
|
10465
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
10466
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
10467
|
+
(global.typeDetect = factory());
|
|
10468
|
+
}(this, (function () { 'use strict';
|
|
10336
10469
|
|
|
10337
10470
|
/* !
|
|
10338
10471
|
* type-detect
|
|
@@ -10340,8 +10473,10 @@ module.exports = {
|
|
|
10340
10473
|
* MIT Licensed
|
|
10341
10474
|
*/
|
|
10342
10475
|
var promiseExists = typeof Promise === 'function';
|
|
10343
|
-
|
|
10344
|
-
|
|
10476
|
+
|
|
10477
|
+
/* eslint-disable no-undef */
|
|
10478
|
+
var globalObject = typeof self === 'object' ? self : global; // eslint-disable-line id-blacklist
|
|
10479
|
+
|
|
10345
10480
|
var symbolExists = typeof Symbol !== 'undefined';
|
|
10346
10481
|
var mapExists = typeof Map !== 'undefined';
|
|
10347
10482
|
var setExists = typeof Set !== 'undefined';
|
|
@@ -10370,7 +10505,7 @@ var toStringRightSliceLength = -1;
|
|
|
10370
10505
|
* @return {String} object type
|
|
10371
10506
|
* @api public
|
|
10372
10507
|
*/
|
|
10373
|
-
|
|
10508
|
+
function typeDetect(obj) {
|
|
10374
10509
|
/* ! Speed optimisation
|
|
10375
10510
|
* Pre:
|
|
10376
10511
|
* string literal x 3,039,035 ops/sec ±1.62% (78 runs sampled)
|
|
@@ -10433,7 +10568,9 @@ module.exports = function typeDetect(obj) {
|
|
|
10433
10568
|
return 'Array';
|
|
10434
10569
|
}
|
|
10435
10570
|
|
|
10436
|
-
|
|
10571
|
+
// Not caching existence of `window` and related properties due to potential
|
|
10572
|
+
// for `window` to be unset before tests in quasi-browser environments.
|
|
10573
|
+
if (typeof window === 'object' && window !== null) {
|
|
10437
10574
|
/* ! Spec Conformance
|
|
10438
10575
|
* (https://html.spec.whatwg.org/multipage/browsers.html#location)
|
|
10439
10576
|
* WhatWG HTML$7.7.3 - The `Location` interface
|
|
@@ -10441,7 +10578,7 @@ module.exports = function typeDetect(obj) {
|
|
|
10441
10578
|
* - IE <=11 === "[object Object]"
|
|
10442
10579
|
* - IE Edge <=13 === "[object Object]"
|
|
10443
10580
|
*/
|
|
10444
|
-
if (obj ===
|
|
10581
|
+
if (typeof window.location === 'object' && obj === window.location) {
|
|
10445
10582
|
return 'Location';
|
|
10446
10583
|
}
|
|
10447
10584
|
|
|
@@ -10464,70 +10601,78 @@ module.exports = function typeDetect(obj) {
|
|
|
10464
10601
|
* - IE 11 === "[object HTMLDocument]"
|
|
10465
10602
|
* - IE Edge <=13 === "[object HTMLDocument]"
|
|
10466
10603
|
*/
|
|
10467
|
-
if (obj ===
|
|
10604
|
+
if (typeof window.document === 'object' && obj === window.document) {
|
|
10468
10605
|
return 'Document';
|
|
10469
10606
|
}
|
|
10470
10607
|
|
|
10471
|
-
|
|
10472
|
-
|
|
10473
|
-
|
|
10474
|
-
|
|
10475
|
-
|
|
10476
|
-
|
|
10477
|
-
|
|
10478
|
-
|
|
10479
|
-
|
|
10608
|
+
if (typeof window.navigator === 'object') {
|
|
10609
|
+
/* ! Spec Conformance
|
|
10610
|
+
* (https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray)
|
|
10611
|
+
* WhatWG HTML$8.6.1.5 - Plugins - Interface MimeTypeArray
|
|
10612
|
+
* Test: `Object.prototype.toString.call(navigator.mimeTypes)``
|
|
10613
|
+
* - IE <=10 === "[object MSMimeTypesCollection]"
|
|
10614
|
+
*/
|
|
10615
|
+
if (typeof window.navigator.mimeTypes === 'object' &&
|
|
10616
|
+
obj === window.navigator.mimeTypes) {
|
|
10617
|
+
return 'MimeTypeArray';
|
|
10618
|
+
}
|
|
10480
10619
|
|
|
10481
|
-
|
|
10482
|
-
|
|
10483
|
-
|
|
10484
|
-
|
|
10485
|
-
|
|
10486
|
-
|
|
10487
|
-
|
|
10488
|
-
|
|
10620
|
+
/* ! Spec Conformance
|
|
10621
|
+
* (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
|
|
10622
|
+
* WhatWG HTML$8.6.1.5 - Plugins - Interface PluginArray
|
|
10623
|
+
* Test: `Object.prototype.toString.call(navigator.plugins)``
|
|
10624
|
+
* - IE <=10 === "[object MSPluginsCollection]"
|
|
10625
|
+
*/
|
|
10626
|
+
if (typeof window.navigator.plugins === 'object' &&
|
|
10627
|
+
obj === window.navigator.plugins) {
|
|
10628
|
+
return 'PluginArray';
|
|
10629
|
+
}
|
|
10489
10630
|
}
|
|
10490
10631
|
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
|
|
10495
|
-
|
|
10496
|
-
|
|
10497
|
-
|
|
10498
|
-
|
|
10499
|
-
|
|
10632
|
+
if ((typeof window.HTMLElement === 'function' ||
|
|
10633
|
+
typeof window.HTMLElement === 'object') &&
|
|
10634
|
+
obj instanceof window.HTMLElement) {
|
|
10635
|
+
/* ! Spec Conformance
|
|
10636
|
+
* (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
|
|
10637
|
+
* WhatWG HTML$4.4.4 - The `blockquote` element - Interface `HTMLQuoteElement`
|
|
10638
|
+
* Test: `Object.prototype.toString.call(document.createElement('blockquote'))``
|
|
10639
|
+
* - IE <=10 === "[object HTMLBlockElement]"
|
|
10640
|
+
*/
|
|
10641
|
+
if (obj.tagName === 'BLOCKQUOTE') {
|
|
10642
|
+
return 'HTMLQuoteElement';
|
|
10643
|
+
}
|
|
10500
10644
|
|
|
10501
|
-
|
|
10502
|
-
|
|
10503
|
-
|
|
10504
|
-
|
|
10505
|
-
|
|
10506
|
-
|
|
10507
|
-
|
|
10508
|
-
|
|
10509
|
-
|
|
10510
|
-
|
|
10511
|
-
|
|
10512
|
-
|
|
10513
|
-
|
|
10514
|
-
|
|
10515
|
-
|
|
10645
|
+
/* ! Spec Conformance
|
|
10646
|
+
* (https://html.spec.whatwg.org/#htmltabledatacellelement)
|
|
10647
|
+
* WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableDataCellElement`
|
|
10648
|
+
* Note: Most browsers currently adher to the W3C DOM Level 2 spec
|
|
10649
|
+
* (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
|
|
10650
|
+
* which suggests that browsers should use HTMLTableCellElement for
|
|
10651
|
+
* both TD and TH elements. WhatWG separates these.
|
|
10652
|
+
* Test: Object.prototype.toString.call(document.createElement('td'))
|
|
10653
|
+
* - Chrome === "[object HTMLTableCellElement]"
|
|
10654
|
+
* - Firefox === "[object HTMLTableCellElement]"
|
|
10655
|
+
* - Safari === "[object HTMLTableCellElement]"
|
|
10656
|
+
*/
|
|
10657
|
+
if (obj.tagName === 'TD') {
|
|
10658
|
+
return 'HTMLTableDataCellElement';
|
|
10659
|
+
}
|
|
10516
10660
|
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
|
|
10520
|
-
|
|
10521
|
-
|
|
10522
|
-
|
|
10523
|
-
|
|
10524
|
-
|
|
10525
|
-
|
|
10526
|
-
|
|
10527
|
-
|
|
10528
|
-
|
|
10529
|
-
|
|
10530
|
-
|
|
10661
|
+
/* ! Spec Conformance
|
|
10662
|
+
* (https://html.spec.whatwg.org/#htmltableheadercellelement)
|
|
10663
|
+
* WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableHeaderCellElement`
|
|
10664
|
+
* Note: Most browsers currently adher to the W3C DOM Level 2 spec
|
|
10665
|
+
* (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
|
|
10666
|
+
* which suggests that browsers should use HTMLTableCellElement for
|
|
10667
|
+
* both TD and TH elements. WhatWG separates these.
|
|
10668
|
+
* Test: Object.prototype.toString.call(document.createElement('th'))
|
|
10669
|
+
* - Chrome === "[object HTMLTableCellElement]"
|
|
10670
|
+
* - Firefox === "[object HTMLTableCellElement]"
|
|
10671
|
+
* - Safari === "[object HTMLTableCellElement]"
|
|
10672
|
+
*/
|
|
10673
|
+
if (obj.tagName === 'TH') {
|
|
10674
|
+
return 'HTMLTableHeaderCellElement';
|
|
10675
|
+
}
|
|
10531
10676
|
}
|
|
10532
10677
|
}
|
|
10533
10678
|
|
|
@@ -10699,9 +10844,11 @@ module.exports = function typeDetect(obj) {
|
|
|
10699
10844
|
.toString
|
|
10700
10845
|
.call(obj)
|
|
10701
10846
|
.slice(toStringLeftSliceLength, toStringRightSliceLength);
|
|
10702
|
-
}
|
|
10847
|
+
}
|
|
10703
10848
|
|
|
10704
|
-
|
|
10849
|
+
return typeDetect;
|
|
10850
|
+
|
|
10851
|
+
})));
|
|
10705
10852
|
|
|
10706
10853
|
},{}]},{},[1])(1)
|
|
10707
|
-
});
|
|
10854
|
+
});
|