chai 3.1.0 → 3.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/README.md +11 -0
- package/chai.js +78 -54
- package/lib/chai/core/assertions.js +13 -5
- package/lib/chai/interface/assert.js +62 -46
- package/lib/chai/utils/getProperties.js +2 -2
- package/lib/chai.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,6 +30,17 @@ Chai offers a robust Plugin architecture for extending Chai's assertions and int
|
|
|
30
30
|
- [chaijs / deep-eql](https://github.com/chaijs/deep-eql): Improved deep equality testing for Node.js and the browser.
|
|
31
31
|
- [chaijs / type-detect](https://github.com/chaijs/type-detect): Improved typeof detection for node.js and the browser.
|
|
32
32
|
|
|
33
|
+
### Contributing
|
|
34
|
+
|
|
35
|
+
Thank you very much for considering to contribute!
|
|
36
|
+
|
|
37
|
+
Here are a few issues other contributors frequently ran into when opening pull requests:
|
|
38
|
+
|
|
39
|
+
- Please do not commit changes to the `chai.js` build. We do it once per release.
|
|
40
|
+
- Before pushing your commits, please make sure you [rebase](https://github.com/chaijs/chai/blob/master/CONTRIBUTING.md#pull-requests) them.
|
|
41
|
+
|
|
42
|
+
We also strongly encourage you to read our detailed [contribution guidelines](https://github.com/chaijs/chai/blob/master/CONTRIBUTING.md).
|
|
43
|
+
|
|
33
44
|
### Contributors
|
|
34
45
|
|
|
35
46
|
Please see the full
|
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.2.0';
|
|
19
19
|
|
|
20
20
|
/*!
|
|
21
21
|
* Assertion Error
|
|
@@ -1657,12 +1657,13 @@ module.exports = function (chai, _) {
|
|
|
1657
1657
|
* expect(Klass).itself.to.respondTo('baz');
|
|
1658
1658
|
*
|
|
1659
1659
|
* @name respondTo
|
|
1660
|
+
* @alias respondsTo
|
|
1660
1661
|
* @param {String} method
|
|
1661
1662
|
* @param {String} message _optional_
|
|
1662
1663
|
* @api public
|
|
1663
1664
|
*/
|
|
1664
1665
|
|
|
1665
|
-
|
|
1666
|
+
function respondTo (method, msg) {
|
|
1666
1667
|
if (msg) flag(this, 'message', msg);
|
|
1667
1668
|
var obj = flag(this, 'object')
|
|
1668
1669
|
, itself = flag(this, 'itself')
|
|
@@ -1675,7 +1676,10 @@ module.exports = function (chai, _) {
|
|
|
1675
1676
|
, 'expected #{this} to respond to ' + _.inspect(method)
|
|
1676
1677
|
, 'expected #{this} to not respond to ' + _.inspect(method)
|
|
1677
1678
|
);
|
|
1678
|
-
}
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
Assertion.addMethod('respondTo', respondTo);
|
|
1682
|
+
Assertion.addMethod('respondsTo', respondTo);
|
|
1679
1683
|
|
|
1680
1684
|
/**
|
|
1681
1685
|
* ### .itself
|
|
@@ -1705,12 +1709,13 @@ module.exports = function (chai, _) {
|
|
|
1705
1709
|
* expect(1).to.satisfy(function(num) { return num > 0; });
|
|
1706
1710
|
*
|
|
1707
1711
|
* @name satisfy
|
|
1712
|
+
* @alias satisfies
|
|
1708
1713
|
* @param {Function} matcher
|
|
1709
1714
|
* @param {String} message _optional_
|
|
1710
1715
|
* @api public
|
|
1711
1716
|
*/
|
|
1712
1717
|
|
|
1713
|
-
|
|
1718
|
+
function satisfy (matcher, msg) {
|
|
1714
1719
|
if (msg) flag(this, 'message', msg);
|
|
1715
1720
|
var obj = flag(this, 'object');
|
|
1716
1721
|
var result = matcher(obj);
|
|
@@ -1721,7 +1726,10 @@ module.exports = function (chai, _) {
|
|
|
1721
1726
|
, this.negate ? false : true
|
|
1722
1727
|
, result
|
|
1723
1728
|
);
|
|
1724
|
-
}
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
Assertion.addMethod('satisfy', satisfy);
|
|
1732
|
+
Assertion.addMethod('satisfies', satisfy);
|
|
1725
1733
|
|
|
1726
1734
|
/**
|
|
1727
1735
|
* ### .closeTo(expected, delta)
|
|
@@ -2001,7 +2009,7 @@ module.exports = function (chai, _) {
|
|
|
2001
2009
|
var obj = flag(this, 'object');
|
|
2002
2010
|
|
|
2003
2011
|
this.assert(
|
|
2004
|
-
Object.
|
|
2012
|
+
Object.isFrozen(obj)
|
|
2005
2013
|
, 'expected #{this} to be frozen'
|
|
2006
2014
|
, 'expected #{this} to not be frozen'
|
|
2007
2015
|
);
|
|
@@ -2076,38 +2084,40 @@ module.exports = function (chai, util) {
|
|
|
2076
2084
|
};
|
|
2077
2085
|
|
|
2078
2086
|
/**
|
|
2079
|
-
* ### .
|
|
2087
|
+
* ### .isOk(object, [message])
|
|
2080
2088
|
*
|
|
2081
2089
|
* Asserts that `object` is truthy.
|
|
2082
2090
|
*
|
|
2083
|
-
* assert.
|
|
2084
|
-
* assert.
|
|
2091
|
+
* assert.isOk('everything', 'everything is ok');
|
|
2092
|
+
* assert.isOk(false, 'this will fail');
|
|
2085
2093
|
*
|
|
2086
|
-
* @name
|
|
2094
|
+
* @name isOk
|
|
2095
|
+
* @alias ok
|
|
2087
2096
|
* @param {Mixed} object to test
|
|
2088
2097
|
* @param {String} message
|
|
2089
2098
|
* @api public
|
|
2090
2099
|
*/
|
|
2091
2100
|
|
|
2092
|
-
assert.
|
|
2101
|
+
assert.isOk = function (val, msg) {
|
|
2093
2102
|
new Assertion(val, msg).is.ok;
|
|
2094
2103
|
};
|
|
2095
2104
|
|
|
2096
2105
|
/**
|
|
2097
|
-
* ### .
|
|
2106
|
+
* ### .isNotOk(object, [message])
|
|
2098
2107
|
*
|
|
2099
2108
|
* Asserts that `object` is falsy.
|
|
2100
2109
|
*
|
|
2101
|
-
* assert.
|
|
2102
|
-
* assert.
|
|
2110
|
+
* assert.isNotOk('everything', 'this will fail');
|
|
2111
|
+
* assert.isNotOk(false, 'this will pass');
|
|
2103
2112
|
*
|
|
2104
|
-
* @name
|
|
2113
|
+
* @name isNotOk
|
|
2114
|
+
* @alias notOk
|
|
2105
2115
|
* @param {Mixed} object to test
|
|
2106
2116
|
* @param {String} message
|
|
2107
2117
|
* @api public
|
|
2108
2118
|
*/
|
|
2109
2119
|
|
|
2110
|
-
assert.
|
|
2120
|
+
assert.isNotOk = function (val, msg) {
|
|
2111
2121
|
new Assertion(val, msg).is.not.ok;
|
|
2112
2122
|
};
|
|
2113
2123
|
|
|
@@ -2976,11 +2986,11 @@ module.exports = function (chai, util) {
|
|
|
2976
2986
|
* `constructor`, or alternately that it will throw an error with message
|
|
2977
2987
|
* matching `regexp`.
|
|
2978
2988
|
*
|
|
2979
|
-
* assert.
|
|
2980
|
-
* assert.
|
|
2981
|
-
* assert.
|
|
2982
|
-
* assert.
|
|
2983
|
-
* assert.
|
|
2989
|
+
* assert.throws(fn, 'function throws a reference error');
|
|
2990
|
+
* assert.throws(fn, /function throws a reference error/);
|
|
2991
|
+
* assert.throws(fn, ReferenceError);
|
|
2992
|
+
* assert.throws(fn, ReferenceError, 'function throws a reference error');
|
|
2993
|
+
* assert.throws(fn, ReferenceError, /function throws a reference error/);
|
|
2984
2994
|
*
|
|
2985
2995
|
* @name throws
|
|
2986
2996
|
* @alias throw
|
|
@@ -2993,13 +3003,13 @@ module.exports = function (chai, util) {
|
|
|
2993
3003
|
* @api public
|
|
2994
3004
|
*/
|
|
2995
3005
|
|
|
2996
|
-
assert.
|
|
3006
|
+
assert.throws = function (fn, errt, errs, msg) {
|
|
2997
3007
|
if ('string' === typeof errt || errt instanceof RegExp) {
|
|
2998
3008
|
errs = errt;
|
|
2999
3009
|
errt = null;
|
|
3000
3010
|
}
|
|
3001
3011
|
|
|
3002
|
-
var assertErr = new Assertion(fn, msg).to.
|
|
3012
|
+
var assertErr = new Assertion(fn, msg).to.throw(errt, errs);
|
|
3003
3013
|
return flag(assertErr, 'object');
|
|
3004
3014
|
};
|
|
3005
3015
|
|
|
@@ -3289,7 +3299,7 @@ module.exports = function (chai, util) {
|
|
|
3289
3299
|
* ### .ifError(object)
|
|
3290
3300
|
*
|
|
3291
3301
|
* Asserts if value is not a false value, and throws if it is a true value.
|
|
3292
|
-
* This is added to allow for chai to be a drop-in replacement for Node's
|
|
3302
|
+
* This is added to allow for chai to be a drop-in replacement for Node's
|
|
3293
3303
|
* assert class.
|
|
3294
3304
|
*
|
|
3295
3305
|
* var err = new Error('I am a custom error');
|
|
@@ -3307,24 +3317,25 @@ module.exports = function (chai, util) {
|
|
|
3307
3317
|
};
|
|
3308
3318
|
|
|
3309
3319
|
/**
|
|
3310
|
-
* ### .
|
|
3320
|
+
* ### .isExtensible(object)
|
|
3311
3321
|
*
|
|
3312
3322
|
* Asserts that `object` is extensible (can have new properties added to it).
|
|
3313
3323
|
*
|
|
3314
|
-
* assert.
|
|
3324
|
+
* assert.isExtensible({});
|
|
3315
3325
|
*
|
|
3316
|
-
* @name
|
|
3326
|
+
* @name isExtensible
|
|
3327
|
+
* @alias extensible
|
|
3317
3328
|
* @param {Object} object
|
|
3318
3329
|
* @param {String} message _optional_
|
|
3319
3330
|
* @api public
|
|
3320
3331
|
*/
|
|
3321
3332
|
|
|
3322
|
-
assert.
|
|
3333
|
+
assert.isExtensible = function (obj, msg) {
|
|
3323
3334
|
new Assertion(obj, msg).to.be.extensible;
|
|
3324
3335
|
};
|
|
3325
3336
|
|
|
3326
3337
|
/**
|
|
3327
|
-
* ### .
|
|
3338
|
+
* ### .isNotExtensible(object)
|
|
3328
3339
|
*
|
|
3329
3340
|
* Asserts that `object` is _not_ extensible.
|
|
3330
3341
|
*
|
|
@@ -3332,22 +3343,23 @@ module.exports = function (chai, util) {
|
|
|
3332
3343
|
* var sealedObject = Object.seal({});
|
|
3333
3344
|
* var frozenObject = Object.freese({});
|
|
3334
3345
|
*
|
|
3335
|
-
* assert.
|
|
3336
|
-
* assert.
|
|
3337
|
-
* assert.
|
|
3346
|
+
* assert.isNotExtensible(nonExtensibleObject);
|
|
3347
|
+
* assert.isNotExtensible(sealedObject);
|
|
3348
|
+
* assert.isNotExtensible(frozenObject);
|
|
3338
3349
|
*
|
|
3339
|
-
* @name
|
|
3350
|
+
* @name isNotExtensible
|
|
3351
|
+
* @alias notExtensible
|
|
3340
3352
|
* @param {Object} object
|
|
3341
3353
|
* @param {String} message _optional_
|
|
3342
3354
|
* @api public
|
|
3343
3355
|
*/
|
|
3344
3356
|
|
|
3345
|
-
assert.
|
|
3357
|
+
assert.isNotExtensible = function (obj, msg) {
|
|
3346
3358
|
new Assertion(obj, msg).to.not.be.extensible;
|
|
3347
3359
|
};
|
|
3348
3360
|
|
|
3349
3361
|
/**
|
|
3350
|
-
* ### .
|
|
3362
|
+
* ### .isSealed(object)
|
|
3351
3363
|
*
|
|
3352
3364
|
* Asserts that `object` is sealed (cannot have new properties added to it
|
|
3353
3365
|
* and its existing properties cannot be removed).
|
|
@@ -3355,38 +3367,40 @@ module.exports = function (chai, util) {
|
|
|
3355
3367
|
* var sealedObject = Object.seal({});
|
|
3356
3368
|
* var frozenObject = Object.seal({});
|
|
3357
3369
|
*
|
|
3358
|
-
* assert.
|
|
3359
|
-
* assert.
|
|
3370
|
+
* assert.isSealed(sealedObject);
|
|
3371
|
+
* assert.isSealed(frozenObject);
|
|
3360
3372
|
*
|
|
3361
|
-
* @name
|
|
3373
|
+
* @name isSealed
|
|
3374
|
+
* @alias sealed
|
|
3362
3375
|
* @param {Object} object
|
|
3363
3376
|
* @param {String} message _optional_
|
|
3364
3377
|
* @api public
|
|
3365
3378
|
*/
|
|
3366
3379
|
|
|
3367
|
-
assert.
|
|
3380
|
+
assert.isSealed = function (obj, msg) {
|
|
3368
3381
|
new Assertion(obj, msg).to.be.sealed;
|
|
3369
3382
|
};
|
|
3370
3383
|
|
|
3371
3384
|
/**
|
|
3372
|
-
* ### .
|
|
3385
|
+
* ### .isNotSealed(object)
|
|
3373
3386
|
*
|
|
3374
3387
|
* Asserts that `object` is _not_ sealed.
|
|
3375
3388
|
*
|
|
3376
|
-
* assert.
|
|
3389
|
+
* assert.isNotSealed({});
|
|
3377
3390
|
*
|
|
3378
|
-
* @name
|
|
3391
|
+
* @name isNotSealed
|
|
3392
|
+
* @alias notSealed
|
|
3379
3393
|
* @param {Object} object
|
|
3380
3394
|
* @param {String} message _optional_
|
|
3381
3395
|
* @api public
|
|
3382
3396
|
*/
|
|
3383
3397
|
|
|
3384
|
-
assert.
|
|
3398
|
+
assert.isNotSealed = function (obj, msg) {
|
|
3385
3399
|
new Assertion(obj, msg).to.not.be.sealed;
|
|
3386
3400
|
};
|
|
3387
3401
|
|
|
3388
3402
|
/**
|
|
3389
|
-
* ### .
|
|
3403
|
+
* ### .isFrozen(object)
|
|
3390
3404
|
*
|
|
3391
3405
|
* Asserts that `object` is frozen (cannot have new properties added to it
|
|
3392
3406
|
* and its existing properties cannot be modified).
|
|
@@ -3394,30 +3408,32 @@ module.exports = function (chai, util) {
|
|
|
3394
3408
|
* var frozenObject = Object.freeze({});
|
|
3395
3409
|
* assert.frozen(frozenObject);
|
|
3396
3410
|
*
|
|
3397
|
-
* @name
|
|
3411
|
+
* @name isFrozen
|
|
3412
|
+
* @alias frozen
|
|
3398
3413
|
* @param {Object} object
|
|
3399
3414
|
* @param {String} message _optional_
|
|
3400
3415
|
* @api public
|
|
3401
3416
|
*/
|
|
3402
3417
|
|
|
3403
|
-
assert.
|
|
3418
|
+
assert.isFrozen = function (obj, msg) {
|
|
3404
3419
|
new Assertion(obj, msg).to.be.frozen;
|
|
3405
3420
|
};
|
|
3406
3421
|
|
|
3407
3422
|
/**
|
|
3408
|
-
* ### .
|
|
3423
|
+
* ### .isNotFrozen(object)
|
|
3409
3424
|
*
|
|
3410
3425
|
* Asserts that `object` is _not_ frozen.
|
|
3411
3426
|
*
|
|
3412
|
-
* assert.
|
|
3427
|
+
* assert.isNotFrozen({});
|
|
3413
3428
|
*
|
|
3414
|
-
* @name
|
|
3429
|
+
* @name isNotFrozen
|
|
3430
|
+
* @alias notFrozen
|
|
3415
3431
|
* @param {Object} object
|
|
3416
3432
|
* @param {String} message _optional_
|
|
3417
3433
|
* @api public
|
|
3418
3434
|
*/
|
|
3419
3435
|
|
|
3420
|
-
assert.
|
|
3436
|
+
assert.isNotFrozen = function (obj, msg) {
|
|
3421
3437
|
new Assertion(obj, msg).to.not.be.frozen;
|
|
3422
3438
|
};
|
|
3423
3439
|
|
|
@@ -3429,8 +3445,16 @@ module.exports = function (chai, util) {
|
|
|
3429
3445
|
assert[as] = assert[name];
|
|
3430
3446
|
return alias;
|
|
3431
3447
|
})
|
|
3432
|
-
('
|
|
3433
|
-
('
|
|
3448
|
+
('isOk', 'ok')
|
|
3449
|
+
('isNotOk', 'notOk')
|
|
3450
|
+
('throws', 'throw')
|
|
3451
|
+
('throws', 'Throw')
|
|
3452
|
+
('isExtensible', 'extensible')
|
|
3453
|
+
('isNotExtensible', 'notExtensible')
|
|
3454
|
+
('isSealed', 'sealed')
|
|
3455
|
+
('isNotSealed', 'notSealed')
|
|
3456
|
+
('isFrozen', 'frozen')
|
|
3457
|
+
('isNotFrozen', 'notFrozen');
|
|
3434
3458
|
};
|
|
3435
3459
|
|
|
3436
3460
|
},{}],7:[function(require,module,exports){
|
|
@@ -4099,7 +4123,7 @@ module.exports = function(path, obj) {
|
|
|
4099
4123
|
*/
|
|
4100
4124
|
|
|
4101
4125
|
module.exports = function getProperties(object) {
|
|
4102
|
-
var result = Object.getOwnPropertyNames(
|
|
4126
|
+
var result = Object.getOwnPropertyNames(object);
|
|
4103
4127
|
|
|
4104
4128
|
function addProperty(property) {
|
|
4105
4129
|
if (result.indexOf(property) === -1) {
|
|
@@ -4107,7 +4131,7 @@ module.exports = function getProperties(object) {
|
|
|
4107
4131
|
}
|
|
4108
4132
|
}
|
|
4109
4133
|
|
|
4110
|
-
var proto = Object.getPrototypeOf(
|
|
4134
|
+
var proto = Object.getPrototypeOf(object);
|
|
4111
4135
|
while (proto !== null) {
|
|
4112
4136
|
Object.getOwnPropertyNames(proto).forEach(addProperty);
|
|
4113
4137
|
proto = Object.getPrototypeOf(proto);
|
|
@@ -1368,12 +1368,13 @@ module.exports = function (chai, _) {
|
|
|
1368
1368
|
* expect(Klass).itself.to.respondTo('baz');
|
|
1369
1369
|
*
|
|
1370
1370
|
* @name respondTo
|
|
1371
|
+
* @alias respondsTo
|
|
1371
1372
|
* @param {String} method
|
|
1372
1373
|
* @param {String} message _optional_
|
|
1373
1374
|
* @api public
|
|
1374
1375
|
*/
|
|
1375
1376
|
|
|
1376
|
-
|
|
1377
|
+
function respondTo (method, msg) {
|
|
1377
1378
|
if (msg) flag(this, 'message', msg);
|
|
1378
1379
|
var obj = flag(this, 'object')
|
|
1379
1380
|
, itself = flag(this, 'itself')
|
|
@@ -1386,7 +1387,10 @@ module.exports = function (chai, _) {
|
|
|
1386
1387
|
, 'expected #{this} to respond to ' + _.inspect(method)
|
|
1387
1388
|
, 'expected #{this} to not respond to ' + _.inspect(method)
|
|
1388
1389
|
);
|
|
1389
|
-
}
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
Assertion.addMethod('respondTo', respondTo);
|
|
1393
|
+
Assertion.addMethod('respondsTo', respondTo);
|
|
1390
1394
|
|
|
1391
1395
|
/**
|
|
1392
1396
|
* ### .itself
|
|
@@ -1416,12 +1420,13 @@ module.exports = function (chai, _) {
|
|
|
1416
1420
|
* expect(1).to.satisfy(function(num) { return num > 0; });
|
|
1417
1421
|
*
|
|
1418
1422
|
* @name satisfy
|
|
1423
|
+
* @alias satisfies
|
|
1419
1424
|
* @param {Function} matcher
|
|
1420
1425
|
* @param {String} message _optional_
|
|
1421
1426
|
* @api public
|
|
1422
1427
|
*/
|
|
1423
1428
|
|
|
1424
|
-
|
|
1429
|
+
function satisfy (matcher, msg) {
|
|
1425
1430
|
if (msg) flag(this, 'message', msg);
|
|
1426
1431
|
var obj = flag(this, 'object');
|
|
1427
1432
|
var result = matcher(obj);
|
|
@@ -1432,7 +1437,10 @@ module.exports = function (chai, _) {
|
|
|
1432
1437
|
, this.negate ? false : true
|
|
1433
1438
|
, result
|
|
1434
1439
|
);
|
|
1435
|
-
}
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
Assertion.addMethod('satisfy', satisfy);
|
|
1443
|
+
Assertion.addMethod('satisfies', satisfy);
|
|
1436
1444
|
|
|
1437
1445
|
/**
|
|
1438
1446
|
* ### .closeTo(expected, delta)
|
|
@@ -1712,7 +1720,7 @@ module.exports = function (chai, _) {
|
|
|
1712
1720
|
var obj = flag(this, 'object');
|
|
1713
1721
|
|
|
1714
1722
|
this.assert(
|
|
1715
|
-
Object.
|
|
1723
|
+
Object.isFrozen(obj)
|
|
1716
1724
|
, 'expected #{this} to be frozen'
|
|
1717
1725
|
, 'expected #{this} to not be frozen'
|
|
1718
1726
|
);
|
|
@@ -64,38 +64,40 @@ module.exports = function (chai, util) {
|
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
|
-
* ### .
|
|
67
|
+
* ### .isOk(object, [message])
|
|
68
68
|
*
|
|
69
69
|
* Asserts that `object` is truthy.
|
|
70
70
|
*
|
|
71
|
-
* assert.
|
|
72
|
-
* assert.
|
|
71
|
+
* assert.isOk('everything', 'everything is ok');
|
|
72
|
+
* assert.isOk(false, 'this will fail');
|
|
73
73
|
*
|
|
74
|
-
* @name
|
|
74
|
+
* @name isOk
|
|
75
|
+
* @alias ok
|
|
75
76
|
* @param {Mixed} object to test
|
|
76
77
|
* @param {String} message
|
|
77
78
|
* @api public
|
|
78
79
|
*/
|
|
79
80
|
|
|
80
|
-
assert.
|
|
81
|
+
assert.isOk = function (val, msg) {
|
|
81
82
|
new Assertion(val, msg).is.ok;
|
|
82
83
|
};
|
|
83
84
|
|
|
84
85
|
/**
|
|
85
|
-
* ### .
|
|
86
|
+
* ### .isNotOk(object, [message])
|
|
86
87
|
*
|
|
87
88
|
* Asserts that `object` is falsy.
|
|
88
89
|
*
|
|
89
|
-
* assert.
|
|
90
|
-
* assert.
|
|
90
|
+
* assert.isNotOk('everything', 'this will fail');
|
|
91
|
+
* assert.isNotOk(false, 'this will pass');
|
|
91
92
|
*
|
|
92
|
-
* @name
|
|
93
|
+
* @name isNotOk
|
|
94
|
+
* @alias notOk
|
|
93
95
|
* @param {Mixed} object to test
|
|
94
96
|
* @param {String} message
|
|
95
97
|
* @api public
|
|
96
98
|
*/
|
|
97
99
|
|
|
98
|
-
assert.
|
|
100
|
+
assert.isNotOk = function (val, msg) {
|
|
99
101
|
new Assertion(val, msg).is.not.ok;
|
|
100
102
|
};
|
|
101
103
|
|
|
@@ -964,11 +966,11 @@ module.exports = function (chai, util) {
|
|
|
964
966
|
* `constructor`, or alternately that it will throw an error with message
|
|
965
967
|
* matching `regexp`.
|
|
966
968
|
*
|
|
967
|
-
* assert.
|
|
968
|
-
* assert.
|
|
969
|
-
* assert.
|
|
970
|
-
* assert.
|
|
971
|
-
* assert.
|
|
969
|
+
* assert.throws(fn, 'function throws a reference error');
|
|
970
|
+
* assert.throws(fn, /function throws a reference error/);
|
|
971
|
+
* assert.throws(fn, ReferenceError);
|
|
972
|
+
* assert.throws(fn, ReferenceError, 'function throws a reference error');
|
|
973
|
+
* assert.throws(fn, ReferenceError, /function throws a reference error/);
|
|
972
974
|
*
|
|
973
975
|
* @name throws
|
|
974
976
|
* @alias throw
|
|
@@ -981,13 +983,13 @@ module.exports = function (chai, util) {
|
|
|
981
983
|
* @api public
|
|
982
984
|
*/
|
|
983
985
|
|
|
984
|
-
assert.
|
|
986
|
+
assert.throws = function (fn, errt, errs, msg) {
|
|
985
987
|
if ('string' === typeof errt || errt instanceof RegExp) {
|
|
986
988
|
errs = errt;
|
|
987
989
|
errt = null;
|
|
988
990
|
}
|
|
989
991
|
|
|
990
|
-
var assertErr = new Assertion(fn, msg).to.
|
|
992
|
+
var assertErr = new Assertion(fn, msg).to.throw(errt, errs);
|
|
991
993
|
return flag(assertErr, 'object');
|
|
992
994
|
};
|
|
993
995
|
|
|
@@ -1277,7 +1279,7 @@ module.exports = function (chai, util) {
|
|
|
1277
1279
|
* ### .ifError(object)
|
|
1278
1280
|
*
|
|
1279
1281
|
* Asserts if value is not a false value, and throws if it is a true value.
|
|
1280
|
-
* This is added to allow for chai to be a drop-in replacement for Node's
|
|
1282
|
+
* This is added to allow for chai to be a drop-in replacement for Node's
|
|
1281
1283
|
* assert class.
|
|
1282
1284
|
*
|
|
1283
1285
|
* var err = new Error('I am a custom error');
|
|
@@ -1295,24 +1297,25 @@ module.exports = function (chai, util) {
|
|
|
1295
1297
|
};
|
|
1296
1298
|
|
|
1297
1299
|
/**
|
|
1298
|
-
* ### .
|
|
1300
|
+
* ### .isExtensible(object)
|
|
1299
1301
|
*
|
|
1300
1302
|
* Asserts that `object` is extensible (can have new properties added to it).
|
|
1301
1303
|
*
|
|
1302
|
-
* assert.
|
|
1304
|
+
* assert.isExtensible({});
|
|
1303
1305
|
*
|
|
1304
|
-
* @name
|
|
1306
|
+
* @name isExtensible
|
|
1307
|
+
* @alias extensible
|
|
1305
1308
|
* @param {Object} object
|
|
1306
1309
|
* @param {String} message _optional_
|
|
1307
1310
|
* @api public
|
|
1308
1311
|
*/
|
|
1309
1312
|
|
|
1310
|
-
assert.
|
|
1313
|
+
assert.isExtensible = function (obj, msg) {
|
|
1311
1314
|
new Assertion(obj, msg).to.be.extensible;
|
|
1312
1315
|
};
|
|
1313
1316
|
|
|
1314
1317
|
/**
|
|
1315
|
-
* ### .
|
|
1318
|
+
* ### .isNotExtensible(object)
|
|
1316
1319
|
*
|
|
1317
1320
|
* Asserts that `object` is _not_ extensible.
|
|
1318
1321
|
*
|
|
@@ -1320,22 +1323,23 @@ module.exports = function (chai, util) {
|
|
|
1320
1323
|
* var sealedObject = Object.seal({});
|
|
1321
1324
|
* var frozenObject = Object.freese({});
|
|
1322
1325
|
*
|
|
1323
|
-
* assert.
|
|
1324
|
-
* assert.
|
|
1325
|
-
* assert.
|
|
1326
|
+
* assert.isNotExtensible(nonExtensibleObject);
|
|
1327
|
+
* assert.isNotExtensible(sealedObject);
|
|
1328
|
+
* assert.isNotExtensible(frozenObject);
|
|
1326
1329
|
*
|
|
1327
|
-
* @name
|
|
1330
|
+
* @name isNotExtensible
|
|
1331
|
+
* @alias notExtensible
|
|
1328
1332
|
* @param {Object} object
|
|
1329
1333
|
* @param {String} message _optional_
|
|
1330
1334
|
* @api public
|
|
1331
1335
|
*/
|
|
1332
1336
|
|
|
1333
|
-
assert.
|
|
1337
|
+
assert.isNotExtensible = function (obj, msg) {
|
|
1334
1338
|
new Assertion(obj, msg).to.not.be.extensible;
|
|
1335
1339
|
};
|
|
1336
1340
|
|
|
1337
1341
|
/**
|
|
1338
|
-
* ### .
|
|
1342
|
+
* ### .isSealed(object)
|
|
1339
1343
|
*
|
|
1340
1344
|
* Asserts that `object` is sealed (cannot have new properties added to it
|
|
1341
1345
|
* and its existing properties cannot be removed).
|
|
@@ -1343,38 +1347,40 @@ module.exports = function (chai, util) {
|
|
|
1343
1347
|
* var sealedObject = Object.seal({});
|
|
1344
1348
|
* var frozenObject = Object.seal({});
|
|
1345
1349
|
*
|
|
1346
|
-
* assert.
|
|
1347
|
-
* assert.
|
|
1350
|
+
* assert.isSealed(sealedObject);
|
|
1351
|
+
* assert.isSealed(frozenObject);
|
|
1348
1352
|
*
|
|
1349
|
-
* @name
|
|
1353
|
+
* @name isSealed
|
|
1354
|
+
* @alias sealed
|
|
1350
1355
|
* @param {Object} object
|
|
1351
1356
|
* @param {String} message _optional_
|
|
1352
1357
|
* @api public
|
|
1353
1358
|
*/
|
|
1354
1359
|
|
|
1355
|
-
assert.
|
|
1360
|
+
assert.isSealed = function (obj, msg) {
|
|
1356
1361
|
new Assertion(obj, msg).to.be.sealed;
|
|
1357
1362
|
};
|
|
1358
1363
|
|
|
1359
1364
|
/**
|
|
1360
|
-
* ### .
|
|
1365
|
+
* ### .isNotSealed(object)
|
|
1361
1366
|
*
|
|
1362
1367
|
* Asserts that `object` is _not_ sealed.
|
|
1363
1368
|
*
|
|
1364
|
-
* assert.
|
|
1369
|
+
* assert.isNotSealed({});
|
|
1365
1370
|
*
|
|
1366
|
-
* @name
|
|
1371
|
+
* @name isNotSealed
|
|
1372
|
+
* @alias notSealed
|
|
1367
1373
|
* @param {Object} object
|
|
1368
1374
|
* @param {String} message _optional_
|
|
1369
1375
|
* @api public
|
|
1370
1376
|
*/
|
|
1371
1377
|
|
|
1372
|
-
assert.
|
|
1378
|
+
assert.isNotSealed = function (obj, msg) {
|
|
1373
1379
|
new Assertion(obj, msg).to.not.be.sealed;
|
|
1374
1380
|
};
|
|
1375
1381
|
|
|
1376
1382
|
/**
|
|
1377
|
-
* ### .
|
|
1383
|
+
* ### .isFrozen(object)
|
|
1378
1384
|
*
|
|
1379
1385
|
* Asserts that `object` is frozen (cannot have new properties added to it
|
|
1380
1386
|
* and its existing properties cannot be modified).
|
|
@@ -1382,30 +1388,32 @@ module.exports = function (chai, util) {
|
|
|
1382
1388
|
* var frozenObject = Object.freeze({});
|
|
1383
1389
|
* assert.frozen(frozenObject);
|
|
1384
1390
|
*
|
|
1385
|
-
* @name
|
|
1391
|
+
* @name isFrozen
|
|
1392
|
+
* @alias frozen
|
|
1386
1393
|
* @param {Object} object
|
|
1387
1394
|
* @param {String} message _optional_
|
|
1388
1395
|
* @api public
|
|
1389
1396
|
*/
|
|
1390
1397
|
|
|
1391
|
-
assert.
|
|
1398
|
+
assert.isFrozen = function (obj, msg) {
|
|
1392
1399
|
new Assertion(obj, msg).to.be.frozen;
|
|
1393
1400
|
};
|
|
1394
1401
|
|
|
1395
1402
|
/**
|
|
1396
|
-
* ### .
|
|
1403
|
+
* ### .isNotFrozen(object)
|
|
1397
1404
|
*
|
|
1398
1405
|
* Asserts that `object` is _not_ frozen.
|
|
1399
1406
|
*
|
|
1400
|
-
* assert.
|
|
1407
|
+
* assert.isNotFrozen({});
|
|
1401
1408
|
*
|
|
1402
|
-
* @name
|
|
1409
|
+
* @name isNotFrozen
|
|
1410
|
+
* @alias notFrozen
|
|
1403
1411
|
* @param {Object} object
|
|
1404
1412
|
* @param {String} message _optional_
|
|
1405
1413
|
* @api public
|
|
1406
1414
|
*/
|
|
1407
1415
|
|
|
1408
|
-
assert.
|
|
1416
|
+
assert.isNotFrozen = function (obj, msg) {
|
|
1409
1417
|
new Assertion(obj, msg).to.not.be.frozen;
|
|
1410
1418
|
};
|
|
1411
1419
|
|
|
@@ -1417,6 +1425,14 @@ module.exports = function (chai, util) {
|
|
|
1417
1425
|
assert[as] = assert[name];
|
|
1418
1426
|
return alias;
|
|
1419
1427
|
})
|
|
1420
|
-
('
|
|
1421
|
-
('
|
|
1428
|
+
('isOk', 'ok')
|
|
1429
|
+
('isNotOk', 'notOk')
|
|
1430
|
+
('throws', 'throw')
|
|
1431
|
+
('throws', 'Throw')
|
|
1432
|
+
('isExtensible', 'extensible')
|
|
1433
|
+
('isNotExtensible', 'notExtensible')
|
|
1434
|
+
('isSealed', 'sealed')
|
|
1435
|
+
('isNotSealed', 'notSealed')
|
|
1436
|
+
('isFrozen', 'frozen')
|
|
1437
|
+
('isNotFrozen', 'notFrozen');
|
|
1422
1438
|
};
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
module.exports = function getProperties(object) {
|
|
20
|
-
var result = Object.getOwnPropertyNames(
|
|
20
|
+
var result = Object.getOwnPropertyNames(object);
|
|
21
21
|
|
|
22
22
|
function addProperty(property) {
|
|
23
23
|
if (result.indexOf(property) === -1) {
|
|
@@ -25,7 +25,7 @@ module.exports = function getProperties(object) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
var proto = Object.getPrototypeOf(
|
|
28
|
+
var proto = Object.getPrototypeOf(object);
|
|
29
29
|
while (proto !== null) {
|
|
30
30
|
Object.getOwnPropertyNames(proto).forEach(addProperty);
|
|
31
31
|
proto = Object.getPrototypeOf(proto);
|
package/lib/chai.js
CHANGED