Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

should

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

should - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

5

History.md
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 @@ ==================

26

lib/should.js

@@ -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');

2

package.json
{ "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');

}
};
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc