Comparing version 0.2.1 to 0.3.0
0.3.0 / 2011-08-20 | ||
================== | ||
* Added assertion for inclusion of an object: `foo.should.include.object({ foo: 'bar' })` | ||
0.2.1 / 2011-05-13 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -36,3 +36,3 @@ | ||
exports.version = '0.2.1'; | ||
exports.version = '0.3.0'; | ||
@@ -439,2 +439,25 @@ /** | ||
/** | ||
* Assert inclusion of object. | ||
* | ||
* @param {Object} obj | ||
* @api public | ||
*/ | ||
object: function(obj){ | ||
this.obj.should.be.a('object'); | ||
var included = true; | ||
for (var key in obj) { | ||
if (obj.hasOwnProperty(key) && !eql(obj[key], this.obj[key])) { | ||
included = false; | ||
break; | ||
} | ||
} | ||
this.assert( | ||
included | ||
, 'expected ' + this.inspect + ' to include ' + i(obj) | ||
, 'expected ' + this.inspect + ' to not include ' + i(obj)); | ||
return this; | ||
}, | ||
/** | ||
* Assert property _name_ exists, with optional _val_. | ||
@@ -624,1 +647,2 @@ * | ||
('below', 'lessThan'); | ||
{ "name": "should" | ||
, "description": "test framework agnostic BDD-style assertions" | ||
, "version": "0.2.1" | ||
, "version": "0.3.0" | ||
, "author": "TJ Holowaychuk <tj@vision-media.ca>" | ||
@@ -5,0 +5,0 @@ , "contributors": [ "Aseem Kishore <aseem.kishore@gmail.com>" ] |
@@ -214,2 +214,11 @@ _should_ is an expressive, readable, test framework agnostic, assertion library for [node](http://nodejs.org). | ||
## object | ||
Assert inclusion of object: | ||
var obj = {foo: 'bar', baz: {baaz: 42}}; | ||
obj.should.include.object({foo: 'bar'}); | ||
obj.should.include.object({baz: {baaz: 42}}); | ||
obj.should.not.include.object({foo: 'baz'}); | ||
## property | ||
@@ -307,2 +316,2 @@ | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@@ -256,3 +256,25 @@ | ||
}, | ||
'test object()': function(){ | ||
var obj = {foo: 'bar', baz: {baaz: 42}, qux: 13}; | ||
obj.should.include.object({foo: 'bar'}); | ||
obj.should.include.object({baz: {baaz: 42}}); | ||
obj.should.include.object({foo: 'bar', qux: 13}); | ||
obj.should.not.include.object({foo: 'baz'}); | ||
obj.should.not.include.object({foo: 'bar', baz: {baaz: -42}}); | ||
err(function(){ | ||
(3).should.include.object({foo: 'bar'}); | ||
}, "expected 3 to be a object"); | ||
err(function(){ | ||
var obj = {foo: 'bar'}; | ||
obj.should.include.object({foo: 'baz'}); | ||
}, "expected { foo: 'bar' } to include { foo: 'baz' }"); | ||
err(function(){ | ||
var obj = {foo: 'bar'}; | ||
obj.should.not.include.object({foo: 'bar'}); | ||
}, "expected { foo: 'bar' } to not include { foo: 'bar' }"); | ||
}, | ||
'test contain()': function(){ | ||
@@ -359,2 +381,2 @@ ['foo', 'bar'].should.contain('foo'); | ||
} | ||
}; | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
170154
1297
316