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.6.0 to 0.6.1

.npmignore

6

History.md
0.6.1 / 2012-04-10
==================
* package: add "repository" section [TooTallNate]
* use valueOf() to get the reference the object [TooTallNate]
0.6.0 / 2012-03-01

@@ -3,0 +9,0 @@ ==================

112

lib/should.js

@@ -21,3 +21,3 @@ /*!

* Expose assert as should.
*
*
* This allows you to do things like below

@@ -36,3 +36,3 @@ * without require()ing the assert module.

exports.version = '0.6.0';
exports.version = '0.6.1';

@@ -46,3 +46,3 @@ /**

*/
exports.exist = function(obj, msg){

@@ -84,3 +84,3 @@ if (null == obj) {

get: function(){
return new Assertion(this);
return new Assertion(Object(this).valueOf());
},

@@ -110,3 +110,3 @@ configurable: true

*/
exports: exports,

@@ -143,7 +143,7 @@

*/
get an() {
return this;
},
/**

@@ -154,7 +154,7 @@ * Dummy getter.

*/
get and() {
return this;
},
/**

@@ -165,3 +165,3 @@ * Dummy getter.

*/
get be() {

@@ -176,7 +176,7 @@ return this;

*/
get have() {
return this;
},
/**

@@ -187,7 +187,7 @@ * Dummy getter.

*/
get with() {
return this;
},
/**

@@ -198,3 +198,3 @@ * Negation modifier.

*/
get not() {

@@ -204,3 +204,3 @@ this.negate = true;

},
/**

@@ -212,3 +212,3 @@ * Get object inspection string.

*/
get inspect() {

@@ -237,3 +237,3 @@ return i(this.obj);

*/
get empty() {

@@ -253,3 +253,3 @@ this.obj.should.have.property('length');

*/
get ok() {

@@ -262,3 +262,3 @@ this.assert(

},
/**

@@ -269,3 +269,3 @@ * Assert true.

*/
get true() {

@@ -278,3 +278,3 @@ this.assert(

},
/**

@@ -285,3 +285,3 @@ * Assert false.

*/
get false() {

@@ -294,5 +294,5 @@ this.assert(

},
/**
* Assert equal.
* Assert equal.
*

@@ -303,3 +303,3 @@ * @param {Mixed} val

*/
eql: function(val, desc){

@@ -313,5 +313,5 @@ this.assert(

},
/**
* Assert strict equal.
* Assert strict equal.
*

@@ -322,3 +322,3 @@ * @param {Mixed} val

*/
equal: function(val, desc){

@@ -332,5 +332,5 @@ this.assert(

},
/**
* Assert within start to finish (inclusive).
* Assert within start to finish (inclusive).
*

@@ -342,3 +342,3 @@ * @param {Number} start

*/
within: function(start, finish, desc){

@@ -352,5 +352,5 @@ var range = start + '..' + finish;

},
/**
* Assert typeof.
* Assert typeof.
*

@@ -361,3 +361,3 @@ * @param {Mixed} type

*/
a: function(type, desc){

@@ -370,5 +370,5 @@ this.assert(

},
/**
* Assert instanceof.
* Assert instanceof.
*

@@ -379,3 +379,3 @@ * @param {Function} constructor

*/
instanceof: function(constructor, desc){

@@ -397,3 +397,3 @@ var name = constructor.name;

*/
above: function(n, desc){

@@ -406,3 +406,3 @@ this.assert(

},
/**

@@ -415,3 +415,3 @@ * Assert numeric value below _n_.

*/
below: function(n, desc){

@@ -424,3 +424,3 @@ this.assert(

},
/**

@@ -433,3 +433,3 @@ * Assert string value matches _regexp_.

*/
match: function(regexp, desc){

@@ -442,3 +442,3 @@ this.assert(

},
/**

@@ -451,3 +451,3 @@ * Assert property "length" exists and has value of _n_.

*/
length: function(n, desc){

@@ -471,3 +471,3 @@ this.obj.should.have.property('length');

*/
property: function(name, val, desc){

@@ -484,3 +484,3 @@ if (this.negate && undefined !== val) {

}
if (undefined !== val) {

@@ -497,3 +497,3 @@ this.assert(

},
/**

@@ -506,3 +506,3 @@ * Assert own property _name_ exists.

*/
ownProperty: function(name, desc){

@@ -532,3 +532,3 @@ this.assert(

},
/**

@@ -566,3 +566,3 @@ * Assert that an object equal to `obj` is present.

},
/**

@@ -575,3 +575,3 @@ * Assert exact keys or inclusion of keys by using

*/
keys: function(keys){

@@ -619,5 +619,5 @@ var str

},
/**
* Assert that header `field` has the given `val`.
* Assert that header `field` has the given `val`.
*

@@ -636,3 +636,3 @@ * @param {String} field

},
/**

@@ -732,3 +732,3 @@ * Assert `.statusCode` of `code`.

};
Assertion.prototype.instanceOf = Assertion.prototype.instanceof;
/**

@@ -735,0 +735,0 @@ * Aliases.

{ "name": "should"
, "description": "test framework agnostic BDD-style assertions"
, "version": "0.6.0"
, "version": "0.6.1"
, "author": "TJ Holowaychuk <tj@vision-media.ca>"
, "repository": { "type": "git", "url": "git://github.com/visionmedia/should.js.git" }
, "contributors": [ "Aseem Kishore <aseem.kishore@gmail.com>" ]
, "devDependencies": {
"mocha": "*"
, "should": "*"
}

@@ -13,2 +13,2 @@ , "keywords": ["test", "bdd", "assert"]

, "engines": { "node": ">= 0.2.0" }
}
}

@@ -310,3 +310,3 @@ _should_ is an expressive, readable, test framework agnostic, assertion library for [node](http://nodejs.org).

As it can often be difficult to assertain exactly where failed assertions are comming from in your tests, an optional description parameter can be passed to several should matchers. The description will follow the failed assertion in the error:
As it can often be difficult to ascertain exactly where failed assertions are coming from in your tests, an optional description parameter can be passed to several should matchers. The description will follow the failed assertion in the error:

@@ -336,3 +336,3 @@ (1).should.eql(0, 'some useful description')

To run the tests for _should_ simple update your git submodules and run:
To run the tests for _should_ simply update your git submodules and run:

@@ -343,3 +343,3 @@ $ make test

Yes, yes it does, with a single getter _should_, and no it wont break your code, because it does this **properly** with a non-enumerable property.
Yes, yes it does, with a single getter _should_, and no it won't break your code, because it does this **properly** with a non-enumerable property.

@@ -346,0 +346,0 @@ ## License

@@ -24,3 +24,3 @@

'test double require': function(){
require('should').should.equal(should);
require('../').should.equal(should);
},

@@ -32,3 +32,3 @@

},
'test true': function(){

@@ -38,3 +38,3 @@ true.should.be.true;

(1).should.not.be.true;
err(function(){

@@ -44,3 +44,3 @@ 'test'.should.be.true;

},
'test ok': function(){

@@ -51,7 +51,7 @@ true.should.be.ok;

(0).should.not.be.ok;
err(function(){
''.should.be.ok;
}, "expected '' to be truthy");
err(function(){

@@ -61,3 +61,3 @@ 'test'.should.not.be.ok;

},
'test false': function(){

@@ -67,3 +67,3 @@ false.should.be.false;

(0).should.not.be.false;
err(function(){

@@ -88,3 +88,3 @@ ''.should.be.false;

},
'test .equal()': function(){

@@ -94,3 +94,3 @@ var foo;

},
'test typeof': function(){

@@ -106,3 +106,3 @@ 'test'.should.be.a('string');

}, "expected 'test' not to be a string | foo");
(5).should.be.a('number');

@@ -118,3 +118,3 @@

},
'test instanceof': function(){

@@ -132,3 +132,16 @@ function Foo(){}

},
'test instanceOf (non-reserved)': function(){
function Foo(){}
new Foo().should.be.an.instanceOf(Foo);
err(function(){
(9).should.an.instanceOf(Foo);
}, "expected 9 to be an instance of Foo");
err(function(){
(9).should.an.instanceOf(Foo, 'foo');
}, "expected 9 to be an instance of Foo | foo");
},
'test within(start, finish)': function(){

@@ -139,7 +152,7 @@ (5).should.be.within(5, 10);

(5).should.not.be.within(1,3);
err(function(){
(5).should.not.be.within(4,6);
}, "expected 5 to not be within 4..6");
err(function(){

@@ -157,3 +170,3 @@ (10).should.be.within(50,100);

},
'test above(n)': function(){

@@ -168,3 +181,3 @@ (5).should.be.above(2);

}, "expected 5 to be above 6");
err(function(){

@@ -177,3 +190,3 @@ (10).should.not.be.above(6);

}, "expected 5 to be above 6 | foo");
err(function(){

@@ -193,3 +206,3 @@ (10).should.not.be.above(6, 'foo');

}, "expected 6 to be below 5");
err(function(){

@@ -202,3 +215,3 @@ (6).should.not.be.below(10);

}, "expected 6 to be below 5 | foo");
err(function(){

@@ -208,11 +221,11 @@ (6).should.not.be.below(10, 'foo');

},
'test match(regexp)': function(){
'foobar'.should.match(/^foo/)
'foobar'.should.not.match(/^bar/)
err(function(){
'foobar'.should.match(/^bar/i)
}, "expected 'foobar' to match /^bar/i");
err(function(){

@@ -225,3 +238,3 @@ 'foobar'.should.not.match(/^foo/i)

}, "expected 'foobar' to match /^bar/i | foo");
err(function(){

@@ -231,3 +244,3 @@ 'foobar'.should.not.match(/^foo/i, 'foo')

},
'test length(n)': function(){

@@ -237,7 +250,7 @@ 'test'.should.have.length(4);

[1,2,3].should.have.length(3);
err(function(){
(4).should.have.length(3);
}, 'expected 4 to have a property \'length\'');
err(function(){

@@ -250,3 +263,3 @@ 'asd'.should.not.have.length(3);

}, "expected 'asd' to have a length of 4 but got 3 | foo");
err(function(){

@@ -257,3 +270,3 @@ 'asd'.should.not.have.length(3, 'foo');

},
'test eql(val)': function(){

@@ -264,3 +277,3 @@ 'test'.should.eql('test');

'4'.should.not.eql(4);
err(function(){

@@ -300,7 +313,7 @@ (4).should.eql(3);

(1).should.equal(1);
err(function(){
(4).should.equal(3);
}, 'expected 4 to equal 3');
err(function(){

@@ -318,3 +331,3 @@ '4'.should.equal(4);

},
'test empty': function(){

@@ -324,11 +337,11 @@ ''.should.be.empty;

({ length: 0 }).should.be.empty;
err(function(){
({}).should.be.empty;
}, 'expected {} to have a property \'length\'');
err(function(){
'asd'.should.be.empty;
}, "expected 'asd' to be empty");
err(function(){

@@ -338,7 +351,7 @@ ''.should.not.be.empty;

},
'test property(name)': function(){
'test'.should.have.property('length');
(4).should.not.have.property('length');
err(function(){

@@ -356,19 +369,19 @@ 'asd'.should.have.property('foo');

},
'test property(name, val)': function(){
'test'.should.have.property('length', 4);
'asd'.should.have.property('constructor', String);
err(function(){
'asd'.should.have.property('length', 4);
}, "expected 'asd' to have a property 'length' of 4, but got 3");
err(function(){
'asd'.should.not.have.property('length', 3);
}, "expected 'asd' to not have a property 'length' of 3");
err(function(){
'asd'.should.not.have.property('foo', 3);
}, "'asd' has no property 'foo'");
err(function(){

@@ -381,11 +394,11 @@ 'asd'.should.have.property('constructor', Number);

}, "expected 'asd' to have a property 'length' of 4, but got 3 | foo");
err(function(){
'asd'.should.not.have.property('length', 3, 'foo');
}, "expected 'asd' to not have a property 'length' of 3 | foo");
err(function(){
'asd'.should.not.have.property('foo', 3, 'foo');
}, "'asd' has no property 'foo' | foo");
err(function(){

@@ -395,3 +408,3 @@ 'asd'.should.have.property('constructor', Number, 'foo');

},
'test ownProperty(name)': function(){

@@ -401,3 +414,3 @@ 'test'.should.have.ownProperty('length');

({ length: 12 }).should.have.ownProperty('length');
err(function(){

@@ -420,7 +433,7 @@ ({ length: 12 }).should.not.have.ownProperty('length');

'foobar'.should.not.include('baz');
err(function(){
'foobar'.should.include('baz');
}, "expected 'foobar' to include 'baz'");
err(function(){

@@ -433,3 +446,3 @@ 'foobar'.should.not.include('bar');

}, "expected 'foobar' to include 'baz' | foo");
err(function(){

@@ -451,3 +464,3 @@ 'foobar'.should.not.include('bar', 'foo');

}, "expected [ 'foo' ] to include 'bar'");
err(function(){

@@ -460,3 +473,3 @@ ['bar', 'foo'].should.not.include('foo');

}, "expected [ 'foo' ] to include 'bar' | foo");
err(function(){

@@ -466,3 +479,3 @@ ['bar', 'foo'].should.not.include('foo', 'foo');

},
'test includeEql() with array': function(){

@@ -477,3 +490,3 @@ [['foo'], ['bar']].should.includeEql(['foo']);

}, "expected [ [ 'foo' ] ] to include an object equal to [ 'bar' ]");
err(function(){

@@ -486,3 +499,3 @@ [['foo']].should.not.includeEql(['foo']);

}, "expected [ [ 'foo' ] ] to include an object equal to [ 'bar' ] | foo");
err(function(){

@@ -492,3 +505,3 @@ [['foo']].should.not.includeEql(['foo'], 'foo');

},
'test keys(array)': function(){

@@ -502,31 +515,31 @@ ({ foo: 1 }).should.have.keys(['foo']);

}, "keys required");
err(function(){
({ foo: 1 }).should.have.keys([]);
}, "keys required");
err(function(){
({ foo: 1 }).should.not.have.keys([]);
}, "keys required");
err(function(){
({ foo: 1 }).should.have.keys(['bar']);
}, "expected { foo: 1 } to have key 'bar'");
err(function(){
({ foo: 1 }).should.have.keys(['bar', 'baz']);
}, "expected { foo: 1 } to have keys 'bar', and 'baz'");
err(function(){
({ foo: 1 }).should.have.keys(['foo', 'bar', 'baz']);
}, "expected { foo: 1 } to have keys 'foo', 'bar', and 'baz'");
err(function(){
({ foo: 1 }).should.not.have.keys(['foo']);
}, "expected { foo: 1 } to not have key 'foo'");
err(function(){
({ foo: 1 }).should.not.have.keys(['foo']);
}, "expected { foo: 1 } to not have key 'foo'");
err(function(){

@@ -536,11 +549,11 @@ ({ foo: 1, bar: 2 }).should.not.have.keys(['foo', 'bar']);

},
'test chaining': function(){
var user = { name: 'tj', pets: ['tobi', 'loki', 'jane', 'bandit'] };
user.should.have.property('pets').with.lengthOf(4);
err(function(){
user.should.have.property('pets').with.lengthOf(5);
}, "expected [ 'tobi', 'loki', 'jane', 'bandit' ] to have a length of 5 but got 4");
user.should.be.a('object').and.have.property('name', 'tj');

@@ -587,2 +600,2 @@ },

}
};
};
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