chai 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chai.js +147 -34
- package/lib/chai/core/assertions.js +49 -17
- package/lib/chai/interface/assert.js +88 -14
- package/lib/chai/utils/addProperty.js +8 -1
- package/lib/chai.js +1 -1
- package/package.json +1 -1
package/chai.js
CHANGED
|
@@ -15,7 +15,7 @@ var used = []
|
|
|
15
15
|
* Chai version
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
exports.version = '3.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
* ### .
|
|
2280
|
+
/**
|
|
2281
|
+
* ### .isAbove(valueToCheck, valueToBeAbove, [message])
|
|
2250
2282
|
*
|
|
2251
|
-
* Asserts
|
|
2283
|
+
* Asserts `valueToCheck` is strictly greater than (>) `valueToBeAbove`
|
|
2252
2284
|
*
|
|
2253
|
-
*
|
|
2254
|
-
* assert.isTrue(teaServed, 'the tea has been served');
|
|
2285
|
+
* assert.isAbove(5, 2, '5 is strictly greater than 2');
|
|
2255
2286
|
*
|
|
2256
|
-
* @name
|
|
2257
|
-
* @param {Mixed}
|
|
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
|
-
* ### .
|
|
2299
|
+
* ### .isAtLeast(valueToCheck, valueToBeAtLeast, [message])
|
|
2268
2300
|
*
|
|
2269
|
-
* Asserts `valueToCheck` is
|
|
2301
|
+
* Asserts `valueToCheck` is greater than or equal to (>=) `valueToBeAtLeast`
|
|
2270
2302
|
*
|
|
2271
|
-
* assert.
|
|
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
|
|
2306
|
+
* @name isAtLeast
|
|
2274
2307
|
* @param {Mixed} valueToCheck
|
|
2275
|
-
* @param {Mixed}
|
|
2308
|
+
* @param {Mixed} valueToBeAtLeast
|
|
2276
2309
|
* @param {String} message
|
|
2277
2310
|
* @api public
|
|
2278
2311
|
*/
|
|
2279
2312
|
|
|
2280
|
-
assert.
|
|
2281
|
-
new Assertion(val, msg).to.be.
|
|
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,7 +3893,11 @@ 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
|
}
|
|
@@ -3792,7 +3905,7 @@ module.exports = function (ctx, name, getter) {
|
|
|
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 <jake@alogicalparadox.com>
|
|
@@ -214,7 +214,7 @@ module.exports = function (chai, _) {
|
|
|
214
214
|
for (var k in val) subset[k] = obj[k];
|
|
215
215
|
expected = _.eql(subset, val);
|
|
216
216
|
} else {
|
|
217
|
-
expected = obj && ~obj.indexOf(val);
|
|
217
|
+
expected = (obj != undefined) && ~obj.indexOf(val);
|
|
218
218
|
}
|
|
219
219
|
this.assert(
|
|
220
220
|
expected
|
|
@@ -392,17 +392,8 @@ module.exports = function (chai, _) {
|
|
|
392
392
|
*/
|
|
393
393
|
|
|
394
394
|
Assertion.addProperty('empty', function () {
|
|
395
|
-
var obj = flag(this, 'object')
|
|
396
|
-
, expected = obj;
|
|
397
|
-
|
|
398
|
-
if (Array.isArray(obj) || 'string' === typeof object) {
|
|
399
|
-
expected = obj.length;
|
|
400
|
-
} else if (typeof obj === 'object') {
|
|
401
|
-
expected = Object.keys(obj).length;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
395
|
this.assert(
|
|
405
|
-
|
|
396
|
+
Object.keys(Object(flag(this, 'object'))).length === 0
|
|
406
397
|
, 'expected #{this} to be empty'
|
|
407
398
|
, 'expected #{this} not to be empty'
|
|
408
399
|
);
|
|
@@ -1438,7 +1429,7 @@ module.exports = function (chai, _) {
|
|
|
1438
1429
|
, result
|
|
1439
1430
|
);
|
|
1440
1431
|
}
|
|
1441
|
-
|
|
1432
|
+
|
|
1442
1433
|
Assertion.addMethod('satisfy', satisfy);
|
|
1443
1434
|
Assertion.addMethod('satisfies', satisfy);
|
|
1444
1435
|
|
|
@@ -1648,7 +1639,7 @@ module.exports = function (chai, _) {
|
|
|
1648
1639
|
/**
|
|
1649
1640
|
* ### .extensible
|
|
1650
1641
|
*
|
|
1651
|
-
* Asserts that the target is extensible (can have new properties added to
|
|
1642
|
+
* Asserts that the target is extensible (can have new properties added to
|
|
1652
1643
|
* it).
|
|
1653
1644
|
*
|
|
1654
1645
|
* var nonExtensibleObject = Object.preventExtensions({});
|
|
@@ -1667,8 +1658,22 @@ module.exports = function (chai, _) {
|
|
|
1667
1658
|
Assertion.addProperty('extensible', function() {
|
|
1668
1659
|
var obj = flag(this, 'object');
|
|
1669
1660
|
|
|
1661
|
+
// In ES5, if the argument to this method is not an object (a primitive), then it will cause a TypeError.
|
|
1662
|
+
// In ES6, a non-object argument will be treated as if it was a non-extensible ordinary object, simply return false.
|
|
1663
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible
|
|
1664
|
+
// The following provides ES6 behavior when a TypeError is thrown under ES5.
|
|
1665
|
+
|
|
1666
|
+
var isExtensible;
|
|
1667
|
+
|
|
1668
|
+
try {
|
|
1669
|
+
isExtensible = Object.isExtensible(obj);
|
|
1670
|
+
} catch (err) {
|
|
1671
|
+
if (err instanceof TypeError) isExtensible = false;
|
|
1672
|
+
else throw err;
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1670
1675
|
this.assert(
|
|
1671
|
-
|
|
1676
|
+
isExtensible
|
|
1672
1677
|
, 'expected #{this} to be extensible'
|
|
1673
1678
|
, 'expected #{this} to not be extensible'
|
|
1674
1679
|
);
|
|
@@ -1694,8 +1699,22 @@ module.exports = function (chai, _) {
|
|
|
1694
1699
|
Assertion.addProperty('sealed', function() {
|
|
1695
1700
|
var obj = flag(this, 'object');
|
|
1696
1701
|
|
|
1702
|
+
// In ES5, if the argument to this method is not an object (a primitive), then it will cause a TypeError.
|
|
1703
|
+
// In ES6, a non-object argument will be treated as if it was a sealed ordinary object, simply return true.
|
|
1704
|
+
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed
|
|
1705
|
+
// The following provides ES6 behavior when a TypeError is thrown under ES5.
|
|
1706
|
+
|
|
1707
|
+
var isSealed;
|
|
1708
|
+
|
|
1709
|
+
try {
|
|
1710
|
+
isSealed = Object.isSealed(obj);
|
|
1711
|
+
} catch (err) {
|
|
1712
|
+
if (err instanceof TypeError) isSealed = true;
|
|
1713
|
+
else throw err;
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1697
1716
|
this.assert(
|
|
1698
|
-
|
|
1717
|
+
isSealed
|
|
1699
1718
|
, 'expected #{this} to be sealed'
|
|
1700
1719
|
, 'expected #{this} to not be sealed'
|
|
1701
1720
|
);
|
|
@@ -1719,11 +1738,24 @@ module.exports = function (chai, _) {
|
|
|
1719
1738
|
Assertion.addProperty('frozen', function() {
|
|
1720
1739
|
var obj = flag(this, 'object');
|
|
1721
1740
|
|
|
1741
|
+
// In ES5, if the argument to this method is not an object (a primitive), then it will cause a TypeError.
|
|
1742
|
+
// In ES6, a non-object argument will be treated as if it was a frozen ordinary object, simply return true.
|
|
1743
|
+
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen
|
|
1744
|
+
// The following provides ES6 behavior when a TypeError is thrown under ES5.
|
|
1745
|
+
|
|
1746
|
+
var isFrozen;
|
|
1747
|
+
|
|
1748
|
+
try {
|
|
1749
|
+
isFrozen = Object.isFrozen(obj);
|
|
1750
|
+
} catch (err) {
|
|
1751
|
+
if (err instanceof TypeError) isFrozen = true;
|
|
1752
|
+
else throw err;
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1722
1755
|
this.assert(
|
|
1723
|
-
|
|
1756
|
+
isFrozen
|
|
1724
1757
|
, 'expected #{this} to be frozen'
|
|
1725
1758
|
, 'expected #{this} to not be frozen'
|
|
1726
1759
|
);
|
|
1727
1760
|
});
|
|
1728
|
-
|
|
1729
1761
|
};
|
|
@@ -225,16 +225,16 @@ module.exports = function (chai, util) {
|
|
|
225
225
|
new Assertion(act, msg).to.not.eql(exp);
|
|
226
226
|
};
|
|
227
227
|
|
|
228
|
-
|
|
229
|
-
* ### .
|
|
228
|
+
/**
|
|
229
|
+
* ### .isAbove(valueToCheck, valueToBeAbove, [message])
|
|
230
230
|
*
|
|
231
|
-
* Asserts
|
|
231
|
+
* Asserts `valueToCheck` is strictly greater than (>) `valueToBeAbove`
|
|
232
232
|
*
|
|
233
|
-
*
|
|
234
|
-
* assert.isTrue(teaServed, 'the tea has been served');
|
|
233
|
+
* assert.isAbove(5, 2, '5 is strictly greater than 2');
|
|
235
234
|
*
|
|
236
|
-
* @name
|
|
237
|
-
* @param {Mixed}
|
|
235
|
+
* @name isAbove
|
|
236
|
+
* @param {Mixed} valueToCheck
|
|
237
|
+
* @param {Mixed} valueToBeAbove
|
|
238
238
|
* @param {String} message
|
|
239
239
|
* @api public
|
|
240
240
|
*/
|
|
@@ -244,21 +244,22 @@ module.exports = function (chai, util) {
|
|
|
244
244
|
};
|
|
245
245
|
|
|
246
246
|
/**
|
|
247
|
-
* ### .
|
|
247
|
+
* ### .isAtLeast(valueToCheck, valueToBeAtLeast, [message])
|
|
248
248
|
*
|
|
249
|
-
* Asserts `valueToCheck` is
|
|
249
|
+
* Asserts `valueToCheck` is greater than or equal to (>=) `valueToBeAtLeast`
|
|
250
250
|
*
|
|
251
|
-
* assert.
|
|
251
|
+
* assert.isAtLeast(5, 2, '5 is greater or equal to 2');
|
|
252
|
+
* assert.isAtLeast(3, 3, '3 is greater or equal to 3');
|
|
252
253
|
*
|
|
253
|
-
* @name
|
|
254
|
+
* @name isAtLeast
|
|
254
255
|
* @param {Mixed} valueToCheck
|
|
255
|
-
* @param {Mixed}
|
|
256
|
+
* @param {Mixed} valueToBeAtLeast
|
|
256
257
|
* @param {String} message
|
|
257
258
|
* @api public
|
|
258
259
|
*/
|
|
259
260
|
|
|
260
|
-
assert.
|
|
261
|
-
new Assertion(val, msg).to.be.
|
|
261
|
+
assert.isAtLeast = function (val, atlst, msg) {
|
|
262
|
+
new Assertion(val, msg).to.be.least(atlst);
|
|
262
263
|
};
|
|
263
264
|
|
|
264
265
|
/**
|
|
@@ -275,10 +276,65 @@ module.exports = function (chai, util) {
|
|
|
275
276
|
* @api public
|
|
276
277
|
*/
|
|
277
278
|
|
|
279
|
+
assert.isBelow = function (val, blw, msg) {
|
|
280
|
+
new Assertion(val, msg).to.be.below(blw);
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* ### .isAtMost(valueToCheck, valueToBeAtMost, [message])
|
|
285
|
+
*
|
|
286
|
+
* Asserts `valueToCheck` is less than or equal to (<=) `valueToBeAtMost`
|
|
287
|
+
*
|
|
288
|
+
* assert.isAtMost(3, 6, '3 is less than or equal to 6');
|
|
289
|
+
* assert.isAtMost(4, 4, '4 is less than or equal to 4');
|
|
290
|
+
*
|
|
291
|
+
* @name isAtMost
|
|
292
|
+
* @param {Mixed} valueToCheck
|
|
293
|
+
* @param {Mixed} valueToBeAtMost
|
|
294
|
+
* @param {String} message
|
|
295
|
+
* @api public
|
|
296
|
+
*/
|
|
297
|
+
|
|
298
|
+
assert.isAtMost = function (val, atmst, msg) {
|
|
299
|
+
new Assertion(val, msg).to.be.most(atmst);
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* ### .isTrue(value, [message])
|
|
304
|
+
*
|
|
305
|
+
* Asserts that `value` is true.
|
|
306
|
+
*
|
|
307
|
+
* var teaServed = true;
|
|
308
|
+
* assert.isTrue(teaServed, 'the tea has been served');
|
|
309
|
+
*
|
|
310
|
+
* @name isTrue
|
|
311
|
+
* @param {Mixed} value
|
|
312
|
+
* @param {String} message
|
|
313
|
+
* @api public
|
|
314
|
+
*/
|
|
315
|
+
|
|
278
316
|
assert.isTrue = function (val, msg) {
|
|
279
317
|
new Assertion(val, msg).is['true'];
|
|
280
318
|
};
|
|
281
319
|
|
|
320
|
+
/**
|
|
321
|
+
* ### .isNotTrue(value, [message])
|
|
322
|
+
*
|
|
323
|
+
* Asserts that `value` is not true.
|
|
324
|
+
*
|
|
325
|
+
* var tea = 'tasty chai';
|
|
326
|
+
* assert.isNotTrue(tea, 'great, time for tea!');
|
|
327
|
+
*
|
|
328
|
+
* @name isNotTrue
|
|
329
|
+
* @param {Mixed} value
|
|
330
|
+
* @param {String} message
|
|
331
|
+
* @api public
|
|
332
|
+
*/
|
|
333
|
+
|
|
334
|
+
assert.isNotTrue = function (val, msg) {
|
|
335
|
+
new Assertion(val, msg).to.not.equal(true);
|
|
336
|
+
};
|
|
337
|
+
|
|
282
338
|
/**
|
|
283
339
|
* ### .isFalse(value, [message])
|
|
284
340
|
*
|
|
@@ -297,6 +353,24 @@ module.exports = function (chai, util) {
|
|
|
297
353
|
new Assertion(val, msg).is['false'];
|
|
298
354
|
};
|
|
299
355
|
|
|
356
|
+
/**
|
|
357
|
+
* ### .isNotFalse(value, [message])
|
|
358
|
+
*
|
|
359
|
+
* Asserts that `value` is not false.
|
|
360
|
+
*
|
|
361
|
+
* var tea = 'tasty chai';
|
|
362
|
+
* assert.isNotFalse(tea, 'great, time for tea!');
|
|
363
|
+
*
|
|
364
|
+
* @name isNotFalse
|
|
365
|
+
* @param {Mixed} value
|
|
366
|
+
* @param {String} message
|
|
367
|
+
* @api public
|
|
368
|
+
*/
|
|
369
|
+
|
|
370
|
+
assert.isNotFalse = function (val, msg) {
|
|
371
|
+
new Assertion(val, msg).to.not.equal(false);
|
|
372
|
+
};
|
|
373
|
+
|
|
300
374
|
/**
|
|
301
375
|
* ### .isNull(value, [message])
|
|
302
376
|
*
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
var config = require('../config');
|
|
8
|
+
var flag = require('./flag');
|
|
9
|
+
|
|
7
10
|
/**
|
|
8
11
|
* ### addProperty (ctx, name, getter)
|
|
9
12
|
*
|
|
@@ -31,7 +34,11 @@
|
|
|
31
34
|
|
|
32
35
|
module.exports = function (ctx, name, getter) {
|
|
33
36
|
Object.defineProperty(ctx, name,
|
|
34
|
-
{ get: function () {
|
|
37
|
+
{ get: function addProperty() {
|
|
38
|
+
var old_ssfi = flag(this, 'ssfi');
|
|
39
|
+
if (old_ssfi && config.includeStack === false)
|
|
40
|
+
flag(this, 'ssfi', addProperty);
|
|
41
|
+
|
|
35
42
|
var result = getter.call(this);
|
|
36
43
|
return result === undefined ? this : result;
|
|
37
44
|
}
|
package/lib/chai.js
CHANGED