@@ -15,7 +15,7 @@ var used = []
15
15
* Chai version
16
16
*/
17
17
18
- exports . version = '3.4.2 ' ;
18
+ exports . version = '3.5.0 ' ;
19
19
20
20
/*!
21
21
* Assertion Error
@@ -1914,7 +1914,7 @@ module.exports = function (chai, _) {
1914
1914
* var fn = function() { obj.val += 3 };
1915
1915
* var noChangeFn = function() { return 'foo' + 'bar'; }
1916
1916
* expect(fn).to.change(obj, 'val');
1917
- * expect(noChangFn ).to.not.change(obj, 'val')
1917
+ * expect(noChangeFn ).to.not.change(obj, 'val')
1918
1918
*
1919
1919
* @name change
1920
1920
* @alias changes
@@ -2689,8 +2689,8 @@ module.exports = function (chai, util) {
2689
2689
/**
2690
2690
* ### .isObject(value, [message])
2691
2691
*
2692
- * Asserts that `value` is an object (as revealed by
2693
- * `Object.prototype.toString`).
2692
+ * Asserts that `value` is an object of type 'Object' (as revealed by `Object.prototype.toString`).
2693
+ * _The assertion does not match subclassed objects._
2694
2694
*
2695
2695
* var selection = { name: 'Chai', serve: 'with spices' };
2696
2696
* assert.isObject(selection, 'tea selection is an object');
@@ -2709,7 +2709,7 @@ module.exports = function (chai, util) {
2709
2709
/**
2710
2710
* ### .isNotObject(value, [message])
2711
2711
*
2712
- * Asserts that `value` is _not_ an object.
2712
+ * Asserts that `value` is _not_ an object of type 'Object' (as revealed by `Object.prototype.toString`) .
2713
2713
*
2714
2714
* var selection = 'chai'
2715
2715
* assert.isNotObject(selection, 'tea selection is not an object');
@@ -3454,6 +3454,27 @@ module.exports = function (chai, util) {
3454
3454
new Assertion ( superset , msg ) . to . include . members ( subset ) ;
3455
3455
}
3456
3456
3457
+ /**
3458
+ * ### .includeDeepMembers(superset, subset, [message])
3459
+ *
3460
+ * Asserts that `subset` is included in `superset` - using deep equality checking.
3461
+ * Order is not taken into account.
3462
+ * Duplicates are ignored.
3463
+ *
3464
+ * assert.includeDeepMembers([ {a: 1}, {b: 2}, {c: 3} ], [ {b: 2}, {a: 1}, {b: 2} ], 'include deep members');
3465
+ *
3466
+ * @name includeDeepMembers
3467
+ * @param {Array } superset
3468
+ * @param {Array } subset
3469
+ * @param {String } message
3470
+ * @namespace Assert
3471
+ * @api public
3472
+ */
3473
+
3474
+ assert . includeDeepMembers = function ( superset , subset , msg ) {
3475
+ new Assertion ( superset , msg ) . to . include . deep . members ( subset ) ;
3476
+ }
3477
+
3457
3478
/**
3458
3479
* ### .oneOf(inList, list, [message])
3459
3480
*
@@ -3874,29 +3895,131 @@ module.exports = function (chai, util) {
3874
3895
} , should . fail ) ;
3875
3896
} ;
3876
3897
3898
+ /**
3899
+ * ### .equal(actual, expected, [message])
3900
+ *
3901
+ * Asserts non-strict equality (`==`) of `actual` and `expected`.
3902
+ *
3903
+ * should.equal(3, '3', '== coerces values to strings');
3904
+ *
3905
+ * @name equal
3906
+ * @param {Mixed } actual
3907
+ * @param {Mixed } expected
3908
+ * @param {String } message
3909
+ * @namespace Should
3910
+ * @api public
3911
+ */
3912
+
3877
3913
should . equal = function ( val1 , val2 , msg ) {
3878
3914
new Assertion ( val1 , msg ) . to . equal ( val2 ) ;
3879
3915
} ;
3880
3916
3917
+ /**
3918
+ * ### .throw(function, [constructor/string/regexp], [string/regexp], [message])
3919
+ *
3920
+ * Asserts that `function` will throw an error that is an instance of
3921
+ * `constructor`, or alternately that it will throw an error with message
3922
+ * matching `regexp`.
3923
+ *
3924
+ * should.throw(fn, 'function throws a reference error');
3925
+ * should.throw(fn, /function throws a reference error/);
3926
+ * should.throw(fn, ReferenceError);
3927
+ * should.throw(fn, ReferenceError, 'function throws a reference error');
3928
+ * should.throw(fn, ReferenceError, /function throws a reference error/);
3929
+ *
3930
+ * @name throw
3931
+ * @alias Throw
3932
+ * @param {Function } function
3933
+ * @param {ErrorConstructor } constructor
3934
+ * @param {RegExp } regexp
3935
+ * @param {String } message
3936
+ * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
3937
+ * @namespace Should
3938
+ * @api public
3939
+ */
3940
+
3881
3941
should . Throw = function ( fn , errt , errs , msg ) {
3882
3942
new Assertion ( fn , msg ) . to . Throw ( errt , errs ) ;
3883
3943
} ;
3884
3944
3945
+ /**
3946
+ * ### .exist
3947
+ *
3948
+ * Asserts that the target is neither `null` nor `undefined`.
3949
+ *
3950
+ * var foo = 'hi';
3951
+ *
3952
+ * should.exist(foo, 'foo exists');
3953
+ *
3954
+ * @name exist
3955
+ * @namespace Should
3956
+ * @api public
3957
+ */
3958
+
3885
3959
should . exist = function ( val , msg ) {
3886
3960
new Assertion ( val , msg ) . to . exist ;
3887
3961
}
3888
3962
3889
3963
// negation
3890
3964
should . not = { }
3891
3965
3966
+ /**
3967
+ * ### .not.equal(actual, expected, [message])
3968
+ *
3969
+ * Asserts non-strict inequality (`!=`) of `actual` and `expected`.
3970
+ *
3971
+ * should.not.equal(3, 4, 'these numbers are not equal');
3972
+ *
3973
+ * @name not.equal
3974
+ * @param {Mixed } actual
3975
+ * @param {Mixed } expected
3976
+ * @param {String } message
3977
+ * @namespace Should
3978
+ * @api public
3979
+ */
3980
+
3892
3981
should . not . equal = function ( val1 , val2 , msg ) {
3893
3982
new Assertion ( val1 , msg ) . to . not . equal ( val2 ) ;
3894
3983
} ;
3895
3984
3985
+ /**
3986
+ * ### .throw(function, [constructor/regexp], [message])
3987
+ *
3988
+ * Asserts that `function` will _not_ throw an error that is an instance of
3989
+ * `constructor`, or alternately that it will not throw an error with message
3990
+ * matching `regexp`.
3991
+ *
3992
+ * should.not.throw(fn, Error, 'function does not throw');
3993
+ *
3994
+ * @name not.throw
3995
+ * @alias not.Throw
3996
+ * @param {Function } function
3997
+ * @param {ErrorConstructor } constructor
3998
+ * @param {RegExp } regexp
3999
+ * @param {String } message
4000
+ * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
4001
+ * @namespace Should
4002
+ * @api public
4003
+ */
4004
+
3896
4005
should . not . Throw = function ( fn , errt , errs , msg ) {
3897
4006
new Assertion ( fn , msg ) . to . not . Throw ( errt , errs ) ;
3898
4007
} ;
3899
4008
4009
+ /**
4010
+ * ### .not.exist
4011
+ *
4012
+ * Asserts that the target is neither `null` nor `undefined`.
4013
+ *
4014
+ * var bar = null;
4015
+ *
4016
+ * should.not.exist(bar, 'bar does not exist');
4017
+ *
4018
+ * @name not.exist
4019
+ * @namespace Should
4020
+ * @api public
4021
+ */
4022
+
3900
4023
should . not . exist = function ( val , msg ) {
3901
4024
new Assertion ( val , msg ) . to . not . exist ;
3902
4025
}
@@ -4296,9 +4419,9 @@ module.exports = function (obj, args) {
4296
4419
if ( typeof msg === "function" ) msg = msg ( ) ;
4297
4420
msg = msg || '' ;
4298
4421
msg = msg
4299
- . replace ( / # { this} / g, objDisplay ( val ) )
4300
- . replace ( / # { act} / g, objDisplay ( actual ) )
4301
- . replace ( / # { exp} / g, objDisplay ( expected ) ) ;
4422
+ . replace ( / # \ {t h i s \ }/ g, function ( ) { return objDisplay ( val ) ; } )
4423
+ . replace ( / # \ {a c t \ }/ g, function ( ) { return objDisplay ( actual ) ; } )
4424
+ . replace ( / # \ {e x p \ }/ g, function ( ) { return objDisplay ( expected ) ; } ) ;
4302
4425
4303
4426
return flagMsg ? flagMsg + ': ' + msg : msg ;
4304
4427
} ;
0 commit comments