Comparing version 0.6.2 to 0.6.3
0.6.3 / 2012-04-26 | ||
================== | ||
* Added object inclusion support back | ||
0.6.2 / 2012-04-26 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -36,3 +36,3 @@ | ||
exports.version = '0.6.2'; | ||
exports.version = '0.6.3'; | ||
@@ -487,7 +487,15 @@ /** | ||
include: function(obj, desc){ | ||
this.assert( | ||
~this.obj.indexOf(obj) | ||
, 'expected ' + this.inspect + ' to include ' + i(obj) + (desc ? " | " + desc : "") | ||
, 'expected ' + this.inspect + ' to not include ' + i(obj) + (desc ? " | " + desc : "")); | ||
if (obj.constructor == Object){ | ||
var cmp = {}; | ||
for (var key in obj) cmp[key] = this.obj[key]; | ||
this.assert( | ||
eql(cmp, obj) | ||
, 'expected ' + this.inspect + ' to include an object equal to ' + i(obj) + (desc ? " | " + desc : "") | ||
, 'expected ' + this.inspect + ' to not include an object equal to ' + i(obj) + (desc ? " | " + desc : "")); | ||
} else { | ||
this.assert( | ||
~this.obj.indexOf(obj) | ||
, 'expected ' + this.inspect + ' to include ' + i(obj) + (desc ? " | " + desc : "") | ||
, 'expected ' + this.inspect + ' to not include ' + i(obj) + (desc ? " | " + desc : "")); | ||
} | ||
return this; | ||
@@ -494,0 +502,0 @@ }, |
{ "name": "should" | ||
, "description": "test framework agnostic BDD-style assertions" | ||
, "version": "0.6.2" | ||
, "version": "0.6.3" | ||
, "author": "TJ Holowaychuk <tj@vision-media.ca>" | ||
@@ -5,0 +5,0 @@ , "repository": { "type": "git", "url": "git://github.com/visionmedia/should.js.git" } |
@@ -243,3 +243,3 @@ _should_ is an expressive, readable, test framework agnostic, assertion library for [node](http://nodejs.org). | ||
Assert that the given `obj` is present via `indexOf()`, so this works for strings, arrays, or custom objects implementing indexOf: | ||
Assert that the given `obj` is present via `indexOf()`, so this works for strings, arrays, or custom objects implementing indexOf. | ||
@@ -259,2 +259,13 @@ Assert array value: | ||
Assert object includes another object: | ||
var tobi = { name: 'Tobi', age: 1 }; | ||
var jane = { name: 'Jane', age: 5 }; | ||
var user = { name: 'TJ', pet: tobi }; | ||
user.should.include({ pet: tobi }); | ||
user.should.include({ pet: tobi, name: 'TJ' }); | ||
user.should.not.include({ pet: jane }); | ||
user.should.not.include({ name: 'Someone' }); | ||
## includeEql(obj) | ||
@@ -261,0 +272,0 @@ |
@@ -446,2 +446,19 @@ | ||
'test include() with object': function(){ | ||
var tobi = { name: 'Tobi', age: 2 }; | ||
var jane = { name: 'Jane', age: 2 }; | ||
var user = { name: 'TJ', pet: tobi, age: 24 }; | ||
user.should.include({ pet: tobi }); | ||
user.should.include({ pet: tobi, name: 'TJ' }); | ||
user.should.not.include({ pet: tobi, name: 'Someone else' }); | ||
user.should.not.include({ pet: jane }); | ||
user.should.not.include({ pet: jane, name: 'TJ' }); | ||
err(function(){ | ||
user.should.include({ pet: { name: 'Luna' } }); | ||
}, "expected { name: 'TJ', pet: { name: 'Tobi', age: 2 }, age: 24 } to include an object equal to { pet: { name: 'Luna' } }"); | ||
}, | ||
'test includeEql() with array': function(){ | ||
@@ -448,0 +465,0 @@ [['foo'], ['bar']].should.includeEql(['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
50860
1244
379