@@ -14,7 +14,7 @@ var used = [];
14
14
* Chai version
15
15
*/
16
16
17
- exports . version = '4.3.0 ' ;
17
+ exports . version = '4.3.1 ' ;
18
18
19
19
/*!
20
20
* Assertion Error
@@ -405,6 +405,7 @@ module.exports = function (chai, _) {
405
405
* - but
406
406
* - does
407
407
* - still
408
+ * - also
408
409
*
409
410
* @name language chains
410
411
* @namespace BDD
@@ -414,7 +415,7 @@ module.exports = function (chai, _) {
414
415
[ 'to' , 'be' , 'been' , 'is'
415
416
, 'and' , 'has' , 'have' , 'with'
416
417
, 'that' , 'which' , 'at' , 'of'
417
- , 'same' , 'but' , 'does' , 'still' ] . forEach ( function ( chain ) {
418
+ , 'same' , 'but' , 'does' , 'still' , "also" ] . forEach ( function ( chain ) {
418
419
Assertion . addProperty ( chain ) ;
419
420
} ) ;
420
421
@@ -1194,19 +1195,25 @@ module.exports = function (chai, _) {
1194
1195
*
1195
1196
* expect(null, 'nooo why fail??').to.exist;
1196
1197
*
1198
+ * The alias `.exists` can be used interchangeably with `.exist`.
1199
+ *
1197
1200
* @name exist
1201
+ * @alias exists
1198
1202
* @namespace BDD
1199
1203
* @api public
1200
1204
*/
1201
1205
1202
- Assertion . addProperty ( 'exist' , function ( ) {
1206
+ function assertExist ( ) {
1203
1207
var val = flag ( this , 'object' ) ;
1204
1208
this . assert (
1205
1209
val !== null && val !== undefined
1206
1210
, 'expected #{this} to exist'
1207
1211
, 'expected #{this} to not exist'
1208
1212
) ;
1209
- } ) ;
1213
+ }
1214
+
1215
+ Assertion . addProperty ( 'exist' , assertExist ) ;
1216
+ Assertion . addProperty ( 'exists' , assertExist ) ;
1210
1217
1211
1218
/**
1212
1219
* ### .empty
@@ -1606,10 +1613,12 @@ module.exports = function (chai, _) {
1606
1613
* expect(1).to.be.at.least(2, 'nooo why fail??');
1607
1614
* expect(1, 'nooo why fail??').to.be.at.least(2);
1608
1615
*
1609
- * The alias `.gte` can be used interchangeably with `.least`.
1616
+ * The aliases `.gte` and `.greaterThanOrEqual` can be used interchangeably with
1617
+ * `.least`.
1610
1618
*
1611
1619
* @name least
1612
1620
* @alias gte
1621
+ * @alias greaterThanOrEqual
1613
1622
* @param {Number } n
1614
1623
* @param {String } msg _optional_
1615
1624
* @namespace BDD
@@ -1675,6 +1684,7 @@ module.exports = function (chai, _) {
1675
1684
1676
1685
Assertion . addMethod ( 'least' , assertLeast ) ;
1677
1686
Assertion . addMethod ( 'gte' , assertLeast ) ;
1687
+ Assertion . addMethod ( 'greaterThanOrEqual' , assertLeast ) ;
1678
1688
1679
1689
/**
1680
1690
* ### .below(n[, msg])
@@ -1812,10 +1822,12 @@ module.exports = function (chai, _) {
1812
1822
* expect(2).to.be.at.most(1, 'nooo why fail??');
1813
1823
* expect(2, 'nooo why fail??').to.be.at.most(1);
1814
1824
*
1815
- * The alias `.lte` can be used interchangeably with `.most`.
1825
+ * The aliases `.lte` and `.lessThanOrEqual` can be used interchangeably with
1826
+ * `.most`.
1816
1827
*
1817
1828
* @name most
1818
1829
* @alias lte
1830
+ * @alias lessThanOrEqual
1819
1831
* @param {Number } n
1820
1832
* @param {String } msg _optional_
1821
1833
* @namespace BDD
@@ -1881,6 +1893,7 @@ module.exports = function (chai, _) {
1881
1893
1882
1894
Assertion . addMethod ( 'most' , assertMost ) ;
1883
1895
Assertion . addMethod ( 'lte' , assertMost ) ;
1896
+ Assertion . addMethod ( 'lessThanOrEqual' , assertMost ) ;
1884
1897
1885
1898
/**
1886
1899
* ### .within(start, finish[, msg])
@@ -3521,7 +3534,8 @@ module.exports = function (chai, _) {
3521
3534
var expected = flag ( this , 'object' )
3522
3535
, flagMsg = flag ( this , 'message' )
3523
3536
, ssfi = flag ( this , 'ssfi' )
3524
- , contains = flag ( this , 'contains' ) ;
3537
+ , contains = flag ( this , 'contains' )
3538
+ , isDeep = flag ( this , 'deep' ) ;
3525
3539
new Assertion ( list , flagMsg , ssfi , true ) . to . be . an ( 'array' ) ;
3526
3540
3527
3541
if ( contains ) {
@@ -3533,13 +3547,23 @@ module.exports = function (chai, _) {
3533
3547
, expected
3534
3548
) ;
3535
3549
} else {
3536
- this . assert (
3537
- list . indexOf ( expected ) > - 1
3538
- , 'expected #{this} to be one of #{exp}'
3539
- , 'expected #{this} to not be one of #{exp}'
3540
- , list
3541
- , expected
3542
- ) ;
3550
+ if ( isDeep ) {
3551
+ this . assert (
3552
+ list . some ( possibility => _ . eql ( expected , possibility ) )
3553
+ , 'expected #{this} to deeply equal one of #{exp}'
3554
+ , 'expected #{this} to deeply equal one of #{exp}'
3555
+ , list
3556
+ , expected
3557
+ ) ;
3558
+ } else {
3559
+ this . assert (
3560
+ list . indexOf ( expected ) > - 1
3561
+ , 'expected #{this} to be one of #{exp}'
3562
+ , 'expected #{this} to not be one of #{exp}'
3563
+ , list
3564
+ , expected
3565
+ ) ;
3566
+ }
3543
3567
}
3544
3568
}
3545
3569
@@ -6462,7 +6486,7 @@ module.exports = function (chai, util) {
6462
6486
* Asserts that `set1` and `set2` have the same members in the same order.
6463
6487
* Uses a deep equality check.
6464
6488
*
6465
- * assert.sameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { c: 3 } ], 'same deep ordered members');
6489
+ * assert.sameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { c: 3 } ], 'same deep ordered members');
6466
6490
*
6467
6491
* @name sameDeepOrderedMembers
6468
6492
* @param {Array } set1
@@ -6483,8 +6507,8 @@ module.exports = function (chai, util) {
6483
6507
* Asserts that `set1` and `set2` don't have the same members in the same
6484
6508
* order. Uses a deep equality check.
6485
6509
*
6486
- * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { z: 5 } ], 'not same deep ordered members');
6487
- * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 }, { c: 3 } ], 'not same deep ordered members');
6510
+ * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { z: 5 } ], 'not same deep ordered members');
6511
+ * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 }, { c: 3 } ], 'not same deep ordered members');
6488
6512
*
6489
6513
* @name notSameDeepOrderedMembers
6490
6514
* @param {Array } set1
@@ -6904,7 +6928,7 @@ module.exports = function (chai, util) {
6904
6928
}
6905
6929
6906
6930
/**
6907
- * ### .increasesButNotBy(function, object, property, [message])
6931
+ * ### .increasesButNotBy(function, object, property, delta, [message])
6908
6932
*
6909
6933
* Asserts that a function does not increase a numeric object property or function's return value by an amount (delta).
6910
6934
*
@@ -7034,7 +7058,7 @@ module.exports = function (chai, util) {
7034
7058
* var fn = function() { obj.val = 5 };
7035
7059
* assert.doesNotDecreaseBy(fn, obj, 'val', 1);
7036
7060
*
7037
- * @name doesNotDecrease
7061
+ * @name doesNotDecreaseBy
7038
7062
* @param {Function } modifier function
7039
7063
* @param {Object } object or getter function
7040
7064
* @param {String } property name _optional_
@@ -8101,7 +8125,7 @@ module.exports = function getActual(obj, args) {
8101
8125
* inherited or not.
8102
8126
*
8103
8127
* @param {Object } object
8104
- * @returns {! Array }
8128
+ * @returns {Array }
8105
8129
* @namespace Utils
8106
8130
* @name getEnumerableProperties
8107
8131
* @api public
@@ -8298,7 +8322,7 @@ module.exports = function getOwnEnumerablePropertySymbols(obj) {
8298
8322
* inherited or not.
8299
8323
*
8300
8324
* @param {Object } object
8301
- * @returns {! Array }
8325
+ * @returns {Array }
8302
8326
* @namespace Utils
8303
8327
* @name getProperties
8304
8328
* @api public
@@ -10344,13 +10368,20 @@ function parsePath(path) {
10344
10368
var str = path . replace ( / ( [ ^ \\ ] ) \[ / g, '$1.[' ) ;
10345
10369
var parts = str . match ( / ( \\ \. | [ ^ . ] + ?) + / g) ;
10346
10370
return parts . map ( function mapMatches ( value ) {
10371
+ if (
10372
+ value === 'constructor' ||
10373
+ value === '__proto__' ||
10374
+ value === 'prototype'
10375
+ ) {
10376
+ return { } ;
10377
+ }
10347
10378
var regexp = / ^ \[ ( \d + ) \] $ / ;
10348
10379
var mArr = regexp . exec ( value ) ;
10349
10380
var parsed = null ;
10350
10381
if ( mArr ) {
10351
10382
parsed = { i : parseFloat ( mArr [ 1 ] ) } ;
10352
10383
} else {
10353
- parsed = { p : value . replace ( / \\ ( [ . \ [\] ] ) / g, '$1' ) } ;
10384
+ parsed = { p : value . replace ( / \\ ( [ . [ \] ] ) / g, '$1' ) } ;
10354
10385
}
10355
10386
10356
10387
return parsed ;
@@ -10375,7 +10406,7 @@ function parsePath(path) {
10375
10406
function internalGetPathValue ( obj , parsed , pathDepth ) {
10376
10407
var temporaryValue = obj ;
10377
10408
var res = null ;
10378
- pathDepth = ( typeof pathDepth === 'undefined' ? parsed . length : pathDepth ) ;
10409
+ pathDepth = typeof pathDepth === 'undefined' ? parsed . length : pathDepth ;
10379
10410
10380
10411
for ( var i = 0 ; i < pathDepth ; i ++ ) {
10381
10412
var part = parsed [ i ] ;
@@ -10386,7 +10417,7 @@ function internalGetPathValue(obj, parsed, pathDepth) {
10386
10417
temporaryValue = temporaryValue [ part . p ] ;
10387
10418
}
10388
10419
10389
- if ( i === ( pathDepth - 1 ) ) {
10420
+ if ( i === pathDepth - 1 ) {
10390
10421
res = temporaryValue ;
10391
10422
}
10392
10423
}
@@ -10420,7 +10451,7 @@ function internalSetPathValue(obj, val, parsed) {
10420
10451
part = parsed [ i ] ;
10421
10452
10422
10453
// If it's the last part of the path, we set the 'propName' value with the property name
10423
- if ( i === ( pathDepth - 1 ) ) {
10454
+ if ( i === pathDepth - 1 ) {
10424
10455
propName = typeof part . p === 'undefined' ? part . i : part . p ;
10425
10456
// Now we set the property with the name held by 'propName' on object with the desired val
10426
10457
tempObj [ propName ] = val ;
@@ -10457,7 +10488,7 @@ function internalSetPathValue(obj, val, parsed) {
10457
10488
*
10458
10489
* @param {Object } object
10459
10490
* @param {String } path
10460
- * @returns {! Object } info
10491
+ * @returns {Object } info
10461
10492
* @namespace Utils
10462
10493
* @name getPathInfo
10463
10494
* @api public
@@ -10467,7 +10498,10 @@ function getPathInfo(obj, path) {
10467
10498
var parsed = parsePath ( path ) ;
10468
10499
var last = parsed [ parsed . length - 1 ] ;
10469
10500
var info = {
10470
- parent : parsed . length > 1 ? internalGetPathValue ( obj , parsed , parsed . length - 1 ) : obj ,
10501
+ parent :
10502
+ parsed . length > 1 ?
10503
+ internalGetPathValue ( obj , parsed , parsed . length - 1 ) :
10504
+ obj ,
10471
10505
name : last . p || last . i ,
10472
10506
value : internalGetPathValue ( obj , parsed ) ,
10473
10507
} ;
0 commit comments