@@ -15,7 +15,7 @@ var used = []
15
15
* Chai version
16
16
*/
17
17
18
- exports . version = '3.2 .0' ;
18
+ exports . version = '3.3 .0' ;
19
19
20
20
/*!
21
21
* Assertion Error
@@ -503,7 +503,7 @@ module.exports = function (chai, _) {
503
503
for ( var k in val ) subset [ k ] = obj [ k ] ;
504
504
expected = _ . eql ( subset , val ) ;
505
505
} else {
506
- expected = obj && ~ obj . indexOf ( val ) ;
506
+ expected = ( obj != undefined ) && ~ obj . indexOf ( val ) ;
507
507
}
508
508
this . assert (
509
509
expected
@@ -681,17 +681,8 @@ module.exports = function (chai, _) {
681
681
*/
682
682
683
683
Assertion . addProperty ( 'empty' , function ( ) {
684
- var obj = flag ( this , 'object' )
685
- , expected = obj ;
686
-
687
- if ( Array . isArray ( obj ) || 'string' === typeof object ) {
688
- expected = obj . length ;
689
- } else if ( typeof obj === 'object' ) {
690
- expected = Object . keys ( obj ) . length ;
691
- }
692
-
693
684
this . assert (
694
- ! expected
685
+ Object . keys ( Object ( flag ( this , 'object' ) ) ) . length === 0
695
686
, 'expected #{this} to be empty'
696
687
, 'expected #{this} not to be empty'
697
688
) ;
@@ -1727,7 +1718,7 @@ module.exports = function (chai, _) {
1727
1718
, result
1728
1719
) ;
1729
1720
}
1730
-
1721
+
1731
1722
Assertion . addMethod ( 'satisfy' , satisfy ) ;
1732
1723
Assertion . addMethod ( 'satisfies' , satisfy ) ;
1733
1724
@@ -1937,7 +1928,7 @@ module.exports = function (chai, _) {
1937
1928
/**
1938
1929
* ### .extensible
1939
1930
*
1940
- * Asserts that the target is extensible (can have new properties added to
1931
+ * Asserts that the target is extensible (can have new properties added to
1941
1932
* it).
1942
1933
*
1943
1934
* var nonExtensibleObject = Object.preventExtensions({});
@@ -1956,8 +1947,22 @@ module.exports = function (chai, _) {
1956
1947
Assertion . addProperty ( 'extensible' , function ( ) {
1957
1948
var obj = flag ( this , 'object' ) ;
1958
1949
1950
+ // In ES5, if the argument to this method is not an object (a primitive), then it will cause a TypeError.
1951
+ // In ES6, a non-object argument will be treated as if it was a non-extensible ordinary object, simply return false.
1952
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible
1953
+ // The following provides ES6 behavior when a TypeError is thrown under ES5.
1954
+
1955
+ var isExtensible ;
1956
+
1957
+ try {
1958
+ isExtensible = Object . isExtensible ( obj ) ;
1959
+ } catch ( err ) {
1960
+ if ( err instanceof TypeError ) isExtensible = false ;
1961
+ else throw err ;
1962
+ }
1963
+
1959
1964
this . assert (
1960
- Object . isExtensible ( obj )
1965
+ isExtensible
1961
1966
, 'expected #{this} to be extensible'
1962
1967
, 'expected #{this} to not be extensible'
1963
1968
) ;
@@ -1983,8 +1988,22 @@ module.exports = function (chai, _) {
1983
1988
Assertion . addProperty ( 'sealed' , function ( ) {
1984
1989
var obj = flag ( this , 'object' ) ;
1985
1990
1991
+ // In ES5, if the argument to this method is not an object (a primitive), then it will cause a TypeError.
1992
+ // In ES6, a non-object argument will be treated as if it was a sealed ordinary object, simply return true.
1993
+ // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed
1994
+ // The following provides ES6 behavior when a TypeError is thrown under ES5.
1995
+
1996
+ var isSealed ;
1997
+
1998
+ try {
1999
+ isSealed = Object . isSealed ( obj ) ;
2000
+ } catch ( err ) {
2001
+ if ( err instanceof TypeError ) isSealed = true ;
2002
+ else throw err ;
2003
+ }
2004
+
1986
2005
this . assert (
1987
- Object . isSealed ( obj )
2006
+ isSealed
1988
2007
, 'expected #{this} to be sealed'
1989
2008
, 'expected #{this} to not be sealed'
1990
2009
) ;
@@ -2008,13 +2027,26 @@ module.exports = function (chai, _) {
2008
2027
Assertion . addProperty ( 'frozen' , function ( ) {
2009
2028
var obj = flag ( this , 'object' ) ;
2010
2029
2030
+ // In ES5, if the argument to this method is not an object (a primitive), then it will cause a TypeError.
2031
+ // In ES6, a non-object argument will be treated as if it was a frozen ordinary object, simply return true.
2032
+ // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen
2033
+ // The following provides ES6 behavior when a TypeError is thrown under ES5.
2034
+
2035
+ var isFrozen ;
2036
+
2037
+ try {
2038
+ isFrozen = Object . isFrozen ( obj ) ;
2039
+ } catch ( err ) {
2040
+ if ( err instanceof TypeError ) isFrozen = true ;
2041
+ else throw err ;
2042
+ }
2043
+
2011
2044
this . assert (
2012
- Object . isFrozen ( obj )
2045
+ isFrozen
2013
2046
, 'expected #{this} to be frozen'
2014
2047
, 'expected #{this} to not be frozen'
2015
2048
) ;
2016
2049
} ) ;
2017
-
2018
2050
} ;
2019
2051
2020
2052
} , { } ] , 6 :[ function ( require , module , exports ) {
@@ -2245,16 +2277,16 @@ module.exports = function (chai, util) {
2245
2277
new Assertion ( act , msg ) . to . not . eql ( exp ) ;
2246
2278
} ;
2247
2279
2248
- /**
2249
- * ### .isTrue(value , [message])
2280
+ /**
2281
+ * ### .isAbove(valueToCheck, valueToBeAbove , [message])
2250
2282
*
2251
- * Asserts that `value ` is true.
2283
+ * Asserts `valueToCheck ` is strictly greater than (>) `valueToBeAbove`
2252
2284
*
2253
- * var teaServed = true;
2254
- * assert.isTrue(teaServed, 'the tea has been served');
2285
+ * assert.isAbove(5, 2, '5 is strictly greater than 2');
2255
2286
*
2256
- * @name isTrue
2257
- * @param {Mixed } value
2287
+ * @name isAbove
2288
+ * @param {Mixed } valueToCheck
2289
+ * @param {Mixed } valueToBeAbove
2258
2290
* @param {String } message
2259
2291
* @api public
2260
2292
*/
@@ -2264,21 +2296,22 @@ module.exports = function (chai, util) {
2264
2296
} ;
2265
2297
2266
2298
/**
2267
- * ### .isAbove (valueToCheck, valueToBeAbove , [message])
2299
+ * ### .isAtLeast (valueToCheck, valueToBeAtLeast , [message])
2268
2300
*
2269
- * Asserts `valueToCheck` is strictly greater than (> ) `valueToBeAbove `
2301
+ * Asserts `valueToCheck` is greater than or equal to (>= ) `valueToBeAtLeast `
2270
2302
*
2271
- * assert.isAbove(5, 2, '5 is strictly greater than 2');
2303
+ * assert.isAtLeast(5, 2, '5 is greater or equal to 2');
2304
+ * assert.isAtLeast(3, 3, '3 is greater or equal to 3');
2272
2305
*
2273
- * @name isAbove
2306
+ * @name isAtLeast
2274
2307
* @param {Mixed } valueToCheck
2275
- * @param {Mixed } valueToBeAbove
2308
+ * @param {Mixed } valueToBeAtLeast
2276
2309
* @param {String } message
2277
2310
* @api public
2278
2311
*/
2279
2312
2280
- assert . isBelow = function ( val , blw , msg ) {
2281
- new Assertion ( val , msg ) . to . be . below ( blw ) ;
2313
+ assert . isAtLeast = function ( val , atlst , msg ) {
2314
+ new Assertion ( val , msg ) . to . be . least ( atlst ) ;
2282
2315
} ;
2283
2316
2284
2317
/**
@@ -2295,10 +2328,65 @@ module.exports = function (chai, util) {
2295
2328
* @api public
2296
2329
*/
2297
2330
2331
+ assert . isBelow = function ( val , blw , msg ) {
2332
+ new Assertion ( val , msg ) . to . be . below ( blw ) ;
2333
+ } ;
2334
+
2335
+ /**
2336
+ * ### .isAtMost(valueToCheck, valueToBeAtMost, [message])
2337
+ *
2338
+ * Asserts `valueToCheck` is less than or equal to (<=) `valueToBeAtMost`
2339
+ *
2340
+ * assert.isAtMost(3, 6, '3 is less than or equal to 6');
2341
+ * assert.isAtMost(4, 4, '4 is less than or equal to 4');
2342
+ *
2343
+ * @name isAtMost
2344
+ * @param {Mixed } valueToCheck
2345
+ * @param {Mixed } valueToBeAtMost
2346
+ * @param {String } message
2347
+ * @api public
2348
+ */
2349
+
2350
+ assert . isAtMost = function ( val , atmst , msg ) {
2351
+ new Assertion ( val , msg ) . to . be . most ( atmst ) ;
2352
+ } ;
2353
+
2354
+ /**
2355
+ * ### .isTrue(value, [message])
2356
+ *
2357
+ * Asserts that `value` is true.
2358
+ *
2359
+ * var teaServed = true;
2360
+ * assert.isTrue(teaServed, 'the tea has been served');
2361
+ *
2362
+ * @name isTrue
2363
+ * @param {Mixed } value
2364
+ * @param {String } message
2365
+ * @api public
2366
+ */
2367
+
2298
2368
assert . isTrue = function ( val , msg ) {
2299
2369
new Assertion ( val , msg ) . is [ 'true' ] ;
2300
2370
} ;
2301
2371
2372
+ /**
2373
+ * ### .isNotTrue(value, [message])
2374
+ *
2375
+ * Asserts that `value` is not true.
2376
+ *
2377
+ * var tea = 'tasty chai';
2378
+ * assert.isNotTrue(tea, 'great, time for tea!');
2379
+ *
2380
+ * @name isNotTrue
2381
+ * @param {Mixed } value
2382
+ * @param {String } message
2383
+ * @api public
2384
+ */
2385
+
2386
+ assert . isNotTrue = function ( val , msg ) {
2387
+ new Assertion ( val , msg ) . to . not . equal ( true ) ;
2388
+ } ;
2389
+
2302
2390
/**
2303
2391
* ### .isFalse(value, [message])
2304
2392
*
@@ -2317,6 +2405,24 @@ module.exports = function (chai, util) {
2317
2405
new Assertion ( val , msg ) . is [ 'false' ] ;
2318
2406
} ;
2319
2407
2408
+ /**
2409
+ * ### .isNotFalse(value, [message])
2410
+ *
2411
+ * Asserts that `value` is not false.
2412
+ *
2413
+ * var tea = 'tasty chai';
2414
+ * assert.isNotFalse(tea, 'great, time for tea!');
2415
+ *
2416
+ * @name isNotFalse
2417
+ * @param {Mixed } value
2418
+ * @param {String } message
2419
+ * @api public
2420
+ */
2421
+
2422
+ assert . isNotFalse = function ( val , msg ) {
2423
+ new Assertion ( val , msg ) . to . not . equal ( false ) ;
2424
+ } ;
2425
+
2320
2426
/**
2321
2427
* ### .isNull(value, [message])
2322
2428
*
@@ -3757,6 +3863,9 @@ module.exports = function (ctx, name, method) {
3757
3863
* MIT Licensed
3758
3864
*/
3759
3865
3866
+ var config = require ( '../config' ) ;
3867
+ var flag = require ( './flag' ) ;
3868
+
3760
3869
/**
3761
3870
* ### addProperty (ctx, name, getter)
3762
3871
*
@@ -3784,15 +3893,19 @@ module.exports = function (ctx, name, method) {
3784
3893
3785
3894
module . exports = function ( ctx , name , getter ) {
3786
3895
Object . defineProperty ( ctx , name ,
3787
- { get : function ( ) {
3896
+ { get : function addProperty ( ) {
3897
+ var old_ssfi = flag ( this , 'ssfi' ) ;
3898
+ if ( old_ssfi && config . includeStack === false )
3899
+ flag ( this , 'ssfi' , addProperty ) ;
3900
+
3788
3901
var result = getter . call ( this ) ;
3789
3902
return result === undefined ? this : result ;
3790
3903
}
3791
3904
, configurable : true
3792
3905
} ) ;
3793
3906
} ;
3794
3907
3795
- } , { } ] , 12 :[ function ( require , module , exports ) {
3908
+ } , { "../config" : 4 , "./flag" : 12 } ] , 12 :[ function ( require , module , exports ) {
3796
3909
/*!
3797
3910
* Chai - flag utility
3798
3911
* Copyright(c) 2012-2014 Jake Luer <[email protected] >
0 commit comments