Added node modules
This commit is contained in:
		
							
								
								
									
										3
									
								
								node_modules/should/.gitmodules
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								node_modules/should/.gitmodules
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| [submodule "support/expresso"] | ||||
| 	path = support/expresso | ||||
| 	url = git://github.com/visionmedia/expresso.git | ||||
							
								
								
									
										1
									
								
								node_modules/should/.npmignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								node_modules/should/.npmignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| node_modules | ||||
							
								
								
									
										94
									
								
								node_modules/should/History.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								node_modules/should/History.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,94 @@ | ||||
|  | ||||
| 0.5.1 / 2012-01-13  | ||||
| ================== | ||||
|  | ||||
|   * Added better `.json` | ||||
|   * Added better `.html` | ||||
|  | ||||
| 0.5.0 / 2012-01-12  | ||||
| ================== | ||||
|  | ||||
|   * Added string matching to `.throw()` [serby] | ||||
|   * Added regexp matching to `.throw()` [serby] | ||||
|   * Added `.includeEql()` [RubenVerborgh] | ||||
|   * Added `.should.be.html` | ||||
|   * Added `.should.be.json` | ||||
|   * Added optional description args to most matchers [Mike Swift] | ||||
|  | ||||
| 0.4.2 / 2011-12-17  | ||||
| ================== | ||||
|  | ||||
|   * Fixed .header() for realzzz | ||||
|  | ||||
| 0.4.1 / 2011-12-16  | ||||
| ================== | ||||
|  | ||||
|   * Fixed: chain .header() to retain negation | ||||
|  | ||||
| 0.4.0 / 2011-12-16  | ||||
| ================== | ||||
|  | ||||
|   * Added `.should.throw()` | ||||
|   * Added `.include()` support for strings | ||||
|   * Added `.include()` support for arrays | ||||
|   * Removed `keys()` `.include` modifier support | ||||
|   * Removed `.object()` | ||||
|   * Removed `.string()` | ||||
|   * Removed `.contain()` | ||||
|   * Removed `.respondTo()` rubyism | ||||
|   * expresso -> mocha | ||||
|  | ||||
| 0.3.2 / 2011-10-24  | ||||
| ================== | ||||
|  | ||||
|   * Fixed tests for 0.5.x | ||||
|   * Fixed sys warning | ||||
|  | ||||
| 0.3.1 / 2011-08-22  | ||||
| ================== | ||||
|  | ||||
|   * configurable | ||||
|  | ||||
| 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  | ||||
| ================== | ||||
|  | ||||
|   * Fixed .status(code). Closes #18 | ||||
|  | ||||
| 0.2.0 / 2011-04-17  | ||||
| ================== | ||||
|  | ||||
|   * Added `res.should.have.status(code)` method | ||||
|   * Added `res.should.have.header(field, val)` method | ||||
|  | ||||
| 0.1.0 / 2011-04-06  | ||||
| ================== | ||||
|  | ||||
|   * Added `should.exist(obj)` [aseemk] | ||||
|   * Added `should.not.exist(obj)` [aseemk] | ||||
|  | ||||
| 0.0.4 / 2010-11-24  | ||||
| ================== | ||||
|  | ||||
|   * Added `.ok` to assert truthfulness | ||||
|   * Added `.arguments` | ||||
|   * Fixed double required bug. [thanks dominictarr] | ||||
|  | ||||
| 0.0.3 / 2010-11-19  | ||||
| ================== | ||||
|  | ||||
|   * Added `true` / `false` assertions | ||||
|  | ||||
| 0.0.2 / 2010-11-19  | ||||
| ================== | ||||
|  | ||||
|   * Added chaining support | ||||
|  | ||||
| 0.0.1 / 2010-11-19  | ||||
| ================== | ||||
|  | ||||
|   * Initial release | ||||
							
								
								
									
										6
									
								
								node_modules/should/Makefile
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								node_modules/should/Makefile
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
|  | ||||
| test: | ||||
| 	@./node_modules/.bin/mocha \ | ||||
| 		--ui exports | ||||
|  | ||||
| .PHONY: test | ||||
							
								
								
									
										367
									
								
								node_modules/should/Readme.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										367
									
								
								node_modules/should/Readme.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,367 @@ | ||||
| _should_ is an expressive, readable, test framework agnostic, assertion library for [node](http://nodejs.org). | ||||
|    | ||||
| It extends the Object prototype with a single non-enumerable getter that allows you to express how that object should behave. | ||||
|  | ||||
| _should_ literally extends node's _assert_ module, in fact, it is node's assert module, for example `should.equal(str, 'foo')` will work, just as `assert.equal(str, 'foo')` would, and `should.AssertionError` **is** `assert.AssertionError`, meaning any test framework supporting this constructor will function properly with _should_. | ||||
|  | ||||
| ## Example | ||||
|  | ||||
|     var user = { | ||||
|         name: 'tj' | ||||
|       , pets: ['tobi', 'loki', 'jane', 'bandit'] | ||||
|     }; | ||||
|  | ||||
|     user.should.have.property('name', 'tj'); | ||||
|     user.should.have.property('pets').with.lengthOf(4); | ||||
|      | ||||
|     someAsyncTask(foo, function(err, result){ | ||||
|       should.not.exist(err); | ||||
|       should.exist(result); | ||||
|       result.bar.should.equal(foo); | ||||
|     }); | ||||
|  | ||||
| ## Installation | ||||
|  | ||||
|     $ npm install should | ||||
|  | ||||
| ## assert extras | ||||
|  | ||||
| As mentioned above, _should_ extends node's _assert_. The returned object from `require('should')` is thus similar to the returned object from `require('assert')`, but it has one extra convenience method: | ||||
|  | ||||
|     should.exist('hello') | ||||
|     should.exist([]) | ||||
|     should.exist(null)  // will throw | ||||
|  | ||||
| This is equivalent to `should.ok`, which is equivalent to `assert.ok`, but reads a bit better. It gets better, though: | ||||
|  | ||||
|     should.not.exist(false) | ||||
|     should.not.exist('') | ||||
|     should.not.exist({})    // will throw | ||||
|  | ||||
| We may add more _assert_ extras in the future... ;) | ||||
|  | ||||
| ## chaining assertions | ||||
|  | ||||
| Some assertions can be chained, for example if a property is volatile we can first assert property existence: | ||||
|  | ||||
|     user.should.have.property('pets').with.lengthOf(4) | ||||
|  | ||||
| which is essentially equivalent to below, however the property may not exist: | ||||
|  | ||||
|     user.pets.should.have.lengthOf(4) | ||||
|  | ||||
| our dummy getters such as _and_ also help express chaining: | ||||
|  | ||||
|     user.should.be.a('object').and.have.property('name', 'tj') | ||||
|  | ||||
| ## exist (static) | ||||
|  | ||||
| The returned object from `require('should')` is the same object as `require('assert')`. So you can use `should` just like `assert`: | ||||
|  | ||||
|     should.fail('expected an error!') | ||||
|     should.strictEqual(foo, bar) | ||||
|  | ||||
| In general, using the Object prototype's _should_ is nicer than using these `assert` equivalents, because _should_ gives you access to the expressive and readable language described above: | ||||
|  | ||||
|     foo.should.equal(bar)   // same as should.strictEqual(foo, bar) above | ||||
|  | ||||
| The only exception, though, is when you can't be sure that a particular object exists. In that case, attempting to access the _should_ property may throw a TypeError: | ||||
|  | ||||
|     foo.should.equal(bar)   // throws if foo is null or undefined! | ||||
|  | ||||
| For this case, `require('should')` extends `require('assert')` with an extra convenience method to check whether an object exists: | ||||
|  | ||||
|     should.exist({}) | ||||
|     should.exist([]) | ||||
|     should.exist('') | ||||
|     should.exist(0) | ||||
|     should.exist(null)      // will throw | ||||
|     should.exist(undefined) // will throw | ||||
|  | ||||
| You can also check the negation: | ||||
|  | ||||
|     should.not.exist(undefined) | ||||
|     should.not.exist(null) | ||||
|     should.not.exist('')    // will throw | ||||
|     should.not.exist({})    // will throw | ||||
|  | ||||
| Once you know an object exists, you can safely use the _should_ property on it. | ||||
|  | ||||
| ## ok | ||||
|  | ||||
| Assert truthfulness: | ||||
|  | ||||
|     true.should.be.ok | ||||
|     'yay'.should.be.ok | ||||
|     (1).should.be.ok | ||||
|  | ||||
| or negated: | ||||
|  | ||||
|     false.should.not.be.ok | ||||
|     ''.should.not.be.ok | ||||
|     (0).should.not.be.ok | ||||
|  | ||||
| ## true | ||||
|  | ||||
| Assert === true: | ||||
|  | ||||
|     true.should.be.true | ||||
|     '1'.should.not.be.true | ||||
|  | ||||
| ## false | ||||
|  | ||||
| Assert === false: | ||||
|  | ||||
|      false.should.be.false | ||||
|      (0).should.not.be.false | ||||
|  | ||||
| ## arguments | ||||
|  | ||||
| Assert `Arguments`: | ||||
|  | ||||
|     var args = (function(){ return arguments; })(1,2,3); | ||||
|     args.should.be.arguments; | ||||
|     [].should.not.be.arguments; | ||||
|  | ||||
| ## empty | ||||
|  | ||||
| Asserts that length is 0: | ||||
|  | ||||
|     [].should.be.empty | ||||
|     ''.should.be.empty | ||||
|     ({ length: 0 }).should.be.empty | ||||
|  | ||||
| ## eql | ||||
|  | ||||
| equality: | ||||
|  | ||||
|     ({ foo: 'bar' }).should.eql({ foo: 'bar' }) | ||||
|     [1,2,3].should.eql([1,2,3]) | ||||
|  | ||||
| ## equal | ||||
|  | ||||
| strict equality: | ||||
|  | ||||
|     should.strictEqual(undefined, value) | ||||
|     should.strictEqual(false, value) | ||||
|     (4).should.equal(4) | ||||
|     'test'.should.equal('test') | ||||
|     [1,2,3].should.not.equal([1,2,3]) | ||||
|  | ||||
| ## within | ||||
|  | ||||
| Assert inclusive numeric range: | ||||
|  | ||||
|     user.age.should.be.within(5, 50) | ||||
|  | ||||
| ## a | ||||
|  | ||||
| Assert __typeof__: | ||||
|  | ||||
|     user.should.be.a('object') | ||||
|     'test'.should.be.a('string') | ||||
|  | ||||
| ## instanceof | ||||
|  | ||||
| Assert __instanceof__: | ||||
|  | ||||
|     user.should.be.an.instanceof(User) | ||||
|     [].should.be.an.instanceof(Array) | ||||
|  | ||||
| ## above | ||||
|  | ||||
| Assert numeric value above the given value: | ||||
|  | ||||
|     user.age.should.be.above(5) | ||||
|     user.age.should.not.be.above(100) | ||||
|  | ||||
| ## below | ||||
|  | ||||
| Assert numeric value below the given value: | ||||
|  | ||||
|     user.age.should.be.below(100) | ||||
|     user.age.should.not.be.below(5) | ||||
|  | ||||
| ## match | ||||
|  | ||||
| Assert regexp match: | ||||
|  | ||||
|     username.should.match(/^\w+$/) | ||||
|  | ||||
| ## length | ||||
|  | ||||
| Assert _length_ property exists and has a value of the given number: | ||||
|  | ||||
|     user.pets.should.have.length(5) | ||||
|     user.pets.should.have.a.lengthOf(5) | ||||
|  | ||||
| Aliases: _lengthOf_ | ||||
|  | ||||
| ## property | ||||
|  | ||||
| Assert property exists and has optional value: | ||||
|  | ||||
|     user.should.have.property('name') | ||||
|     user.should.have.property('age', 15) | ||||
|     user.should.not.have.property('rawr') | ||||
|     user.should.not.have.property('age', 0) | ||||
|  | ||||
| ## ownProperty | ||||
|  | ||||
| Assert own property (on the immediate object): | ||||
|  | ||||
|     ({ foo: 'bar' }).should.have.ownProperty('foo') | ||||
|  | ||||
| ## status(code) | ||||
|  | ||||
|  Asserts that `.statusCode` is `code`: | ||||
|  | ||||
|    res.should.have.status(200); | ||||
|  | ||||
| ## header(field[, value]) | ||||
|  | ||||
|  Asserts that a `.headers` object with `field` and optional `value` are present: | ||||
|  | ||||
|      res.should.have.header('content-length'); | ||||
|      res.should.have.header('Content-Length', '123'); | ||||
|      res.should.have.header('content-length', '123'); | ||||
|  | ||||
| ## json | ||||
|  | ||||
|   Assert that Content-Type is "application/json; charset=utf-8" | ||||
|    | ||||
|       res.should.be.json | ||||
|  | ||||
| ## html | ||||
|  | ||||
|   Assert that Content-Type is "text/html; charset=utf-8" | ||||
|    | ||||
|       res.should.be.html | ||||
|  | ||||
| ## include(obj) | ||||
|  | ||||
| Assert that the given `obj` is present via `indexOf()`, so this works for strings, arrays, or custom objects implementing indexOf: | ||||
|  | ||||
| Assert array value: | ||||
|  | ||||
|     [1,2,3].should.include(3) | ||||
|     [1,2,3].should.include(2) | ||||
|     [1,2,3].should.not.include(4) | ||||
|  | ||||
| Assert substring: | ||||
|  | ||||
|     'foo bar baz'.should.include('foo') | ||||
|     'foo bar baz'.should.include('bar') | ||||
|     'foo bar baz'.should.include('baz') | ||||
|     'foo bar baz'.should.not.include('FOO') | ||||
|  | ||||
| ## includeEql(obj) | ||||
|  | ||||
| Assert that an object equal to the given `obj` is present in an Array: | ||||
|  | ||||
|     [[1],[2],[3]].should.includeEql([3]) | ||||
|     [[1],[2],[3]].should.includeEql([2]) | ||||
|     [[1],[2],[3]].should.not.includeEql([4]) | ||||
|  | ||||
| ## throw() | ||||
|  | ||||
| Assert an exception is thrown: | ||||
|  | ||||
| ```js | ||||
| (function(){ | ||||
|   throw new Error('fail'); | ||||
| }).should.throw(); | ||||
| ``` | ||||
|  | ||||
| Assert an exception is not thrown: | ||||
|  | ||||
| ```js | ||||
| (function(){ | ||||
|   | ||||
| }).should.not.throw(); | ||||
| ``` | ||||
| Assert exepection message matches string: | ||||
|  | ||||
| ```js | ||||
| (function(){ | ||||
|   throw new Error('fail'); | ||||
| }).should.throw('fail'); | ||||
| ``` | ||||
|  | ||||
| Assert exepection message matches regexp: | ||||
|  | ||||
| ```js | ||||
| (function(){ | ||||
|   throw new Error('failed to foo'); | ||||
| }).should.throw(/^fail/); | ||||
| ``` | ||||
|  | ||||
| ## keys | ||||
|  | ||||
| Assert own object keys, which must match _exactly_, | ||||
| and will fail if you omit a key or two: | ||||
|  | ||||
|     var obj = { foo: 'bar', baz: 'raz' }; | ||||
|     obj.should.have.keys('foo', 'bar'); | ||||
|     obj.should.have.keys(['foo', 'bar']); | ||||
|  | ||||
| ## Optional Error description | ||||
|  | ||||
| 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: | ||||
|  | ||||
|     (1).should.eql(0, 'some useful description') | ||||
|  | ||||
|     AssertionError: expected 1 to equal 0 | some useful description | ||||
|       at Object.eql (/Users/swift/code/should.js/node_modules/should/lib/should.js:280:10) | ||||
|       ... | ||||
|  | ||||
| The methods that support this optional description are: `eql`, `equal`, `within`, `a`, `instanceof`, `above`, `below`, `match`, `length`, `property`, `ownProperty`, `include`, and `includeEql`. | ||||
|  | ||||
| ## Express example | ||||
|  | ||||
| For example you can use should with the [Expresso TDD Framework](http://github.com/visionmedia/expresso) by simply including it: | ||||
|  | ||||
|     var lib = require('mylib') | ||||
|       , should = require('should'); | ||||
|    | ||||
|     module.exports = { | ||||
|       'test .version': function(){ | ||||
|         lib.version.should.match(/^\d+\.\d+\.\d+$/); | ||||
|       } | ||||
|     }; | ||||
|  | ||||
| ## Running tests | ||||
|  | ||||
| To run the tests for _should_ simple update your git submodules and run: | ||||
|  | ||||
|     $ make test | ||||
|  | ||||
| ## OMG IT EXTENDS OBJECT???!?!@ | ||||
|  | ||||
| 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. | ||||
|  | ||||
| ## License  | ||||
|  | ||||
| (The MIT License) | ||||
|  | ||||
| Copyright (c) 2010-2011 TJ Holowaychuk <tj@vision-media.ca> | ||||
| Copyright (c) 2011 Aseem Kishore <aseem.kishore@gmail.com> | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person obtaining | ||||
| a copy of this software and associated documentation files (the | ||||
| 'Software'), to deal in the Software without restriction, including | ||||
| without limitation the rights to use, copy, modify, merge, publish, | ||||
| distribute, sublicense, and/or sell copies of the Software, and to | ||||
| permit persons to whom the Software is furnished to do so, subject to | ||||
| the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall be | ||||
| included in all copies or substantial portions of the Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||||
| EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||||
| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||||
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||||
| CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||||
| TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||||
| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||||
							
								
								
									
										53
									
								
								node_modules/should/examples/runner.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								node_modules/should/examples/runner.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,53 @@ | ||||
|  | ||||
| /** | ||||
|  * Module dependencies. | ||||
|  */ | ||||
|  | ||||
| var should = require('../'); | ||||
|  | ||||
| function test(name, fn){ | ||||
|   try { | ||||
|     fn(); | ||||
|   } catch (err) { | ||||
|     console.log('    \x1b[31m%s', name); | ||||
|     console.log('    %s\x1b[0m', err.stack); | ||||
|     return; | ||||
|   } | ||||
|   console.log('  √ \x1b[32m%s\x1b[0m', name); | ||||
| } | ||||
|  | ||||
| function Point(x, y) { | ||||
|   this.x = x; | ||||
|   this.y = y; | ||||
|   this.sub = function(other){ | ||||
|     return new Point( | ||||
|         this.x - other.x | ||||
|       , this.y - other.y); | ||||
|   } | ||||
| } | ||||
|  | ||||
| console.log(); | ||||
|  | ||||
| test('new Point(x, y)', function(){ | ||||
|   var point = new Point(50, 100); | ||||
|   point.should.be.an.instanceof(Point); | ||||
|   point.should.have.property('x', 50); | ||||
|   point.should.have.property('y', 100); | ||||
| }); | ||||
|  | ||||
| test('Point#sub()', function(){ | ||||
|   var a = new Point(50, 100) | ||||
|     , b = new Point(20, 50); | ||||
|   a.sub(b).should.be.an.instanceof(Point); | ||||
|   a.sub(b).should.not.equal(a); | ||||
|   a.sub(b).should.not.equal(b); | ||||
|   a.sub(b).should.have.property('x', 30); | ||||
|   a.sub(b).should.have.property('y', 50); | ||||
| }); | ||||
|  | ||||
| test('Point#add()', function(){ | ||||
|   var point = new Point(50, 100); | ||||
|   point.should.respondTo('add'); | ||||
| }); | ||||
|  | ||||
| console.log(); | ||||
							
								
								
									
										2
									
								
								node_modules/should/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								node_modules/should/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
|  | ||||
| module.exports = require('./lib/should'); | ||||
							
								
								
									
										91
									
								
								node_modules/should/lib/eql.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								node_modules/should/lib/eql.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,91 @@ | ||||
|  | ||||
| // Taken from node's assert module, because it sucks | ||||
| // and exposes next to nothing useful. | ||||
|  | ||||
| module.exports = _deepEqual; | ||||
|  | ||||
| function _deepEqual(actual, expected) { | ||||
|   // 7.1. All identical values are equivalent, as determined by ===. | ||||
|   if (actual === expected) { | ||||
|     return true; | ||||
|  | ||||
|   } else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) { | ||||
|     if (actual.length != expected.length) return false; | ||||
|  | ||||
|     for (var i = 0; i < actual.length; i++) { | ||||
|       if (actual[i] !== expected[i]) return false; | ||||
|     } | ||||
|  | ||||
|     return true; | ||||
|  | ||||
|   // 7.2. If the expected value is a Date object, the actual value is | ||||
|   // equivalent if it is also a Date object that refers to the same time. | ||||
|   } else if (actual instanceof Date && expected instanceof Date) { | ||||
|     return actual.getTime() === expected.getTime(); | ||||
|  | ||||
|   // 7.3. Other pairs that do not both pass typeof value == "object", | ||||
|   // equivalence is determined by ==. | ||||
|   } else if (typeof actual != 'object' && typeof expected != 'object') { | ||||
|     return actual === expected; | ||||
|  | ||||
|   // 7.4. For all other Object pairs, including Array objects, equivalence is | ||||
|   // determined by having the same number of owned properties (as verified | ||||
|   // with Object.prototype.hasOwnProperty.call), the same set of keys | ||||
|   // (although not necessarily the same order), equivalent values for every | ||||
|   // corresponding key, and an identical "prototype" property. Note: this | ||||
|   // accounts for both named and indexed properties on Arrays. | ||||
|   } else { | ||||
|     return objEquiv(actual, expected); | ||||
|   } | ||||
| } | ||||
|  | ||||
| function isUndefinedOrNull (value) { | ||||
|   return value === null || value === undefined; | ||||
| } | ||||
|  | ||||
| function isArguments (object) { | ||||
|   return Object.prototype.toString.call(object) == '[object Arguments]'; | ||||
| } | ||||
|  | ||||
| function objEquiv (a, b) { | ||||
|   if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) | ||||
|     return false; | ||||
|   // an identical "prototype" property. | ||||
|   if (a.prototype !== b.prototype) return false; | ||||
|   //~~~I've managed to break Object.keys through screwy arguments passing. | ||||
|   //   Converting to array solves the problem. | ||||
|   if (isArguments(a)) { | ||||
|     if (!isArguments(b)) { | ||||
|       return false; | ||||
|     } | ||||
|     a = pSlice.call(a); | ||||
|     b = pSlice.call(b); | ||||
|     return _deepEqual(a, b); | ||||
|   } | ||||
|   try{ | ||||
|     var ka = Object.keys(a), | ||||
|       kb = Object.keys(b), | ||||
|       key, i; | ||||
|   } catch (e) {//happens when one is a string literal and the other isn't | ||||
|     return false; | ||||
|   } | ||||
|   // having the same number of owned properties (keys incorporates hasOwnProperty) | ||||
|   if (ka.length != kb.length) | ||||
|     return false; | ||||
|   //the same set of keys (although not necessarily the same order), | ||||
|   ka.sort(); | ||||
|   kb.sort(); | ||||
|   //~~~cheap key test | ||||
|   for (i = ka.length - 1; i >= 0; i--) { | ||||
|     if (ka[i] != kb[i]) | ||||
|       return false; | ||||
|   } | ||||
|   //equivalent values for every corresponding key, and | ||||
|   //~~~possibly expensive deep test | ||||
|   for (i = ka.length - 1; i >= 0; i--) { | ||||
|     key = ka[i]; | ||||
|     if (!_deepEqual(a[key], b[key] )) | ||||
|        return false; | ||||
|   } | ||||
|   return true; | ||||
| } | ||||
							
								
								
									
										693
									
								
								node_modules/should/lib/should.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										693
									
								
								node_modules/should/lib/should.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,693 @@ | ||||
| /*! | ||||
|  * Should | ||||
|  * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca> | ||||
|  * MIT Licensed | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * Module dependencies. | ||||
|  */ | ||||
|  | ||||
| var util = require('util') | ||||
|   , http = require('http') | ||||
|   , assert = require('assert') | ||||
|   , AssertionError = assert.AssertionError | ||||
|   , statusCodes = http.STATUS_CODES | ||||
|   , eql = require('./eql') | ||||
|   , i = util.inspect; | ||||
|  | ||||
| /** | ||||
|  * Expose assert as should. | ||||
|  *  | ||||
|  * This allows you to do things like below | ||||
|  * without require()ing the assert module. | ||||
|  * | ||||
|  *    should.equal(foo.bar, undefined); | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| exports = module.exports = assert; | ||||
|  | ||||
| /** | ||||
|  * Library version. | ||||
|  */ | ||||
|  | ||||
| exports.version = '0.5.1'; | ||||
|  | ||||
| /** | ||||
|  * Assert _obj_ exists, with optional message. | ||||
|  * | ||||
|  * @param {Mixed} obj | ||||
|  * @param {String} msg | ||||
|  * @api public | ||||
|  */ | ||||
|   | ||||
| exports.exist = function(obj, msg){ | ||||
|   if (null == obj) { | ||||
|     throw new AssertionError({ | ||||
|         message: msg || ('expected ' + i(obj) + ' to exist') | ||||
|       , stackStartFunction: should.exist | ||||
|     }); | ||||
|   } | ||||
| }; | ||||
|  | ||||
| /** | ||||
|  * Asserts _obj_ does not exist, with optional message. | ||||
|  * | ||||
|  * @param {Mixed} obj | ||||
|  * @param {String} msg | ||||
|  * @api public | ||||
|  */ | ||||
|  | ||||
| exports.not = {}; | ||||
| exports.not.exist = function(obj, msg){ | ||||
|   if (null != obj) { | ||||
|     throw new AssertionError({ | ||||
|         message: msg || ('expected ' + i(obj) + ' to not exist') | ||||
|       , stackStartFunction: should.not.exist | ||||
|     }); | ||||
|   } | ||||
| }; | ||||
|  | ||||
| /** | ||||
|  * Expose api via `Object#should`. | ||||
|  * | ||||
|  * @api public | ||||
|  */ | ||||
|  | ||||
| Object.defineProperty(Object.prototype, 'should', { | ||||
|   set: function(){}, | ||||
|   get: function(){ | ||||
|     return new Assertion(this); | ||||
|   }, | ||||
|   configurable: true | ||||
| }); | ||||
|  | ||||
| /** | ||||
|  * Initialize a new `Assertion` with the given _obj_. | ||||
|  * | ||||
|  * @param {Mixed} obj | ||||
|  * @api private | ||||
|  */ | ||||
|  | ||||
| var Assertion = exports.Assertion = function Assertion(obj) { | ||||
|   this.obj = obj; | ||||
| }; | ||||
|  | ||||
| /** | ||||
|  * Prototype. | ||||
|  */ | ||||
|  | ||||
| Assertion.prototype = { | ||||
|  | ||||
|   /** | ||||
|    * HACK: prevents double require() from failing. | ||||
|    */ | ||||
|    | ||||
|   exports: exports, | ||||
|  | ||||
|   /** | ||||
|    * Assert _expr_ with the given _msg_ and _negatedMsg_. | ||||
|    * | ||||
|    * @param {Boolean} expr | ||||
|    * @param {String} msg | ||||
|    * @param {String} negatedMsg | ||||
|    * @api private | ||||
|    */ | ||||
|  | ||||
|   assert: function(expr, msg, negatedMsg){ | ||||
|     var msg = this.negate ? negatedMsg : msg | ||||
|       , ok = this.negate ? !expr : expr; | ||||
|     if (!ok) { | ||||
|       throw new AssertionError({ | ||||
|           message: msg | ||||
|         , stackStartFunction: this.assert | ||||
|       }); | ||||
|     } | ||||
|   }, | ||||
|  | ||||
|   /** | ||||
|    * Dummy getter. | ||||
|    * | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   get an() { | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Dummy getter. | ||||
|    * | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   get and() { | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Dummy getter. | ||||
|    * | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   get be() { | ||||
|     return this; | ||||
|   }, | ||||
|  | ||||
|   /** | ||||
|    * Dummy getter. | ||||
|    * | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   get have() { | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Dummy getter. | ||||
|    * | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   get with() { | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Negation modifier. | ||||
|    * | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   get not() { | ||||
|     this.negate = true; | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Get object inspection string. | ||||
|    * | ||||
|    * @return {String} | ||||
|    * @api private | ||||
|    */ | ||||
|    | ||||
|   get inspect() { | ||||
|     return i(this.obj); | ||||
|   }, | ||||
|  | ||||
|   /** | ||||
|    * Assert instanceof `Arguments`. | ||||
|    * | ||||
|    * @api public | ||||
|    */ | ||||
|  | ||||
|   get arguments() { | ||||
|     this.assert( | ||||
|         '[object Arguments]' == Object.prototype.toString.call(this.obj) | ||||
|       , 'expected ' + this.inspect + ' to be arguments' | ||||
|       , 'expected ' + this.inspect + ' to not be arguments'); | ||||
|     return this; | ||||
|   }, | ||||
|  | ||||
|   /** | ||||
|    * Assert that an object is empty aka length of 0. | ||||
|    * | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   get empty() { | ||||
|     this.obj.should.have.property('length'); | ||||
|     this.assert( | ||||
|         0 === this.obj.length | ||||
|       , 'expected ' + this.inspect + ' to be empty' | ||||
|       , 'expected ' + this.inspect + ' not to be empty'); | ||||
|     return this; | ||||
|   }, | ||||
|  | ||||
|   /** | ||||
|    * Assert ok. | ||||
|    * | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   get ok() { | ||||
|     this.assert( | ||||
|         this.obj | ||||
|       , 'expected ' + this.inspect + ' to be truthy' | ||||
|       , 'expected ' + this.inspect + ' to be falsey'); | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Assert true. | ||||
|    * | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   get true() { | ||||
|     this.assert( | ||||
|         true === this.obj | ||||
|       , 'expected ' + this.inspect + ' to be true' | ||||
|       , 'expected ' + this.inspect + ' not to be true'); | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Assert false. | ||||
|    * | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   get false() { | ||||
|     this.assert( | ||||
|         false === this.obj | ||||
|       , 'expected ' + this.inspect + ' to be false' | ||||
|       , 'expected ' + this.inspect + ' not to be false'); | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Assert equal.  | ||||
|    * | ||||
|    * @param {Mixed} val | ||||
|    * @param {String} description | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   eql: function(val, desc){ | ||||
|     this.assert( | ||||
|         eql(val, this.obj) | ||||
|       , 'expected ' + this.inspect + ' to equal ' + i(val) + (desc ? " | " + desc : "") | ||||
|       , 'expected ' + this.inspect + ' to not equal ' + i(val) + (desc ? " | " + desc : "")); | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Assert strict equal.  | ||||
|    * | ||||
|    * @param {Mixed} val | ||||
|    * @param {String} description | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   equal: function(val, desc){ | ||||
|     this.assert( | ||||
|         val === this.obj | ||||
|       , 'expected ' + this.inspect + ' to equal ' + i(val) + (desc ? " | " + desc : "") | ||||
|       , 'expected ' + this.inspect + ' to not equal ' + i(val) + (desc ? " | " + desc : "")); | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Assert within start to finish (inclusive).  | ||||
|    * | ||||
|    * @param {Number} start | ||||
|    * @param {Number} finish | ||||
|    * @param {String} description | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   within: function(start, finish, desc){ | ||||
|     var range = start + '..' + finish; | ||||
|     this.assert( | ||||
|         this.obj >= start && this.obj <= finish | ||||
|       , 'expected ' + this.inspect + ' to be within ' + range + (desc ? " | " + desc : "") | ||||
|       , 'expected ' + this.inspect + ' to not be within ' + range + (desc ? " | " + desc : "")); | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Assert typeof.  | ||||
|    * | ||||
|    * @param {Mixed} type | ||||
|    * @param {String} description | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   a: function(type, desc){ | ||||
|     this.assert( | ||||
|         type == typeof this.obj | ||||
|       , 'expected ' + this.inspect + ' to be a ' + type + (desc ? " | " + desc : "") | ||||
|       , 'expected ' + this.inspect + ' not to be a ' + type  + (desc ? " | " + desc : "")); | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Assert instanceof.  | ||||
|    * | ||||
|    * @param {Function} constructor | ||||
|    * @param {String} description | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   instanceof: function(constructor, desc){ | ||||
|     var name = constructor.name; | ||||
|     this.assert( | ||||
|         this.obj instanceof constructor | ||||
|       , 'expected ' + this.inspect + ' to be an instance of ' + name + (desc ? " | " + desc : "") | ||||
|       , 'expected ' + this.inspect + ' not to be an instance of ' + name + (desc ? " | " + desc : "")); | ||||
|     return this; | ||||
|   }, | ||||
|  | ||||
|   /** | ||||
|    * Assert numeric value above _n_. | ||||
|    * | ||||
|    * @param {Number} n | ||||
|    * @param {String} description | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   above: function(n, desc){ | ||||
|     this.assert( | ||||
|         this.obj > n | ||||
|       , 'expected ' + this.inspect + ' to be above ' + n + (desc ? " | " + desc : "") | ||||
|       , 'expected ' + this.inspect + ' to be below ' + n + (desc ? " | " + desc : "")); | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Assert numeric value below _n_. | ||||
|    * | ||||
|    * @param {Number} n | ||||
|    * @param {String} description | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   below: function(n, desc){ | ||||
|     this.assert( | ||||
|         this.obj < n | ||||
|       , 'expected ' + this.inspect + ' to be below ' + n + (desc ? " | " + desc : "") | ||||
|       , 'expected ' + this.inspect + ' to be above ' + n + (desc ? " | " + desc : "")); | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Assert string value matches _regexp_. | ||||
|    * | ||||
|    * @param {RegExp} regexp | ||||
|    * @param {String} description | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   match: function(regexp, desc){ | ||||
|     this.assert( | ||||
|         regexp.exec(this.obj) | ||||
|       , 'expected ' + this.inspect + ' to match ' + regexp + (desc ? " | " + desc : "") | ||||
|       , 'expected ' + this.inspect + ' not to match ' + regexp + (desc ? " | " + desc : "")); | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Assert property "length" exists and has value of _n_. | ||||
|    * | ||||
|    * @param {Number} n | ||||
|    * @param {String} description | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   length: function(n, desc){ | ||||
|     this.obj.should.have.property('length'); | ||||
|     var len = this.obj.length; | ||||
|     this.assert( | ||||
|         n == len | ||||
|       , 'expected ' + this.inspect + ' to have a length of ' + n + ' but got ' + len + (desc ? " | " + desc : "") | ||||
|       , 'expected ' + this.inspect + ' to not have a length of ' + len + (desc ? " | " + desc : "")); | ||||
|     return this; | ||||
|   }, | ||||
|  | ||||
|   /** | ||||
|    * Assert property _name_ exists, with optional _val_. | ||||
|    * | ||||
|    * @param {String} name | ||||
|    * @param {Mixed} val | ||||
|    * @param {String} description | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   property: function(name, val, desc){ | ||||
|     if (this.negate && undefined !== val) { | ||||
|       if (undefined === this.obj[name]) { | ||||
|         throw new Error(this.inspect + ' has no property ' + i(name) + (desc ? " | " + desc : "")); | ||||
|       } | ||||
|     } else { | ||||
|       this.assert( | ||||
|           undefined !== this.obj[name] | ||||
|         , 'expected ' + this.inspect + ' to have a property ' + i(name) + (desc ? " | " + desc : "") | ||||
|         , 'expected ' + this.inspect + ' to not have a property ' + i(name) + (desc ? " | " + desc : "")); | ||||
|     } | ||||
|      | ||||
|     if (undefined !== val) { | ||||
|       this.assert( | ||||
|           val === this.obj[name] | ||||
|         , 'expected ' + this.inspect + ' to have a property ' + i(name) | ||||
|           + ' of ' + i(val) + ', but got ' + i(this.obj[name]) + (desc ? " | " + desc : "") | ||||
|         , 'expected ' + this.inspect + ' to not have a property ' + i(name) + ' of ' + i(val) + (desc ? " | " + desc : "")); | ||||
|     } | ||||
|  | ||||
|     this.obj = this.obj[name]; | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Assert own property _name_ exists. | ||||
|    * | ||||
|    * @param {String} name | ||||
|    * @param {String} description | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   ownProperty: function(name, desc){ | ||||
|     this.assert( | ||||
|         this.obj.hasOwnProperty(name) | ||||
|       , 'expected ' + this.inspect + ' to have own property ' + i(name) + (desc ? " | " + desc : "") | ||||
|       , 'expected ' + this.inspect + ' to not have own property ' + i(name) + (desc ? " | " + desc : "")); | ||||
|     return this; | ||||
|   }, | ||||
|  | ||||
|   /** | ||||
|    * Assert that `obj` is present via `.indexOf()`. | ||||
|    * | ||||
|    * @param {Mixed} obj | ||||
|    * @param {String} description | ||||
|    * @api public | ||||
|    */ | ||||
|  | ||||
|   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 : "")); | ||||
|  | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Assert that an object equal to `obj` is present. | ||||
|    * | ||||
|    * @param {Array} obj | ||||
|    * @param {String} description | ||||
|    * @api public | ||||
|    */ | ||||
|  | ||||
|   includeEql: function(obj, desc){ | ||||
|     this.assert( | ||||
|       this.obj.some(function(item) { return eql(obj, item); }) | ||||
|       , '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 : "")); | ||||
|     return this; | ||||
|   }, | ||||
|  | ||||
|   /** | ||||
|    * Assert that the array contains _obj_. | ||||
|    * | ||||
|    * @param {Mixed} obj | ||||
|    * @api public | ||||
|    */ | ||||
|  | ||||
|   contain: function(obj){ | ||||
|     console.warn('should.contain() is deprecated, use should.include()'); | ||||
|     this.obj.should.be.an.instanceof(Array); | ||||
|     this.assert( | ||||
|         ~this.obj.indexOf(obj) | ||||
|       , 'expected ' + this.inspect + ' to contain ' + i(obj) | ||||
|       , 'expected ' + this.inspect + ' to not contain ' + i(obj)); | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Assert exact keys or inclusion of keys by using | ||||
|    * the `.include` modifier. | ||||
|    * | ||||
|    * @param {Array|String ...} keys | ||||
|    * @api public | ||||
|    */ | ||||
|    | ||||
|   keys: function(keys){ | ||||
|     var str | ||||
|       , ok = true; | ||||
|  | ||||
|     keys = keys instanceof Array | ||||
|       ? keys | ||||
|       : Array.prototype.slice.call(arguments); | ||||
|  | ||||
|     if (!keys.length) throw new Error('keys required'); | ||||
|  | ||||
|     var actual = Object.keys(this.obj) | ||||
|       , len = keys.length; | ||||
|  | ||||
|     // make sure they're all present | ||||
|     ok = keys.every(function(key){ | ||||
|       return ~actual.indexOf(key); | ||||
|     }); | ||||
|  | ||||
|     // matching length | ||||
|     ok = ok && keys.length == actual.length; | ||||
|  | ||||
|     // key string | ||||
|     if (len > 1) { | ||||
|       keys = keys.map(function(key){ | ||||
|         return i(key); | ||||
|       }); | ||||
|       var last = keys.pop(); | ||||
|       str = keys.join(', ') + ', and ' + last; | ||||
|     } else { | ||||
|       str = i(keys[0]); | ||||
|     } | ||||
|  | ||||
|     // message | ||||
|     str = 'have ' + (len > 1 ? 'keys ' : 'key ') + str; | ||||
|  | ||||
|     this.assert( | ||||
|         ok | ||||
|       , 'expected ' + this.inspect + ' to ' + str | ||||
|       , 'expected ' + this.inspect + ' to not ' + str); | ||||
|  | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Assert that header `field` has the given `val`.  | ||||
|    * | ||||
|    * @param {String} field | ||||
|    * @param {String} val | ||||
|    * @return {Assertion} for chaining | ||||
|    * @api public | ||||
|    */ | ||||
|  | ||||
|   header: function(field, val){ | ||||
|     this.obj.should | ||||
|       .have.property('headers').and | ||||
|       .have.property(field.toLowerCase(), val); | ||||
|     return this; | ||||
|   }, | ||||
|    | ||||
|   /** | ||||
|    * Assert `.statusCode` of `code`. | ||||
|    * | ||||
|    * @param {Number} code | ||||
|    * @return {Assertion} for chaining | ||||
|    * @api public | ||||
|    */ | ||||
|  | ||||
|   status:  function(code){ | ||||
|     this.obj.should.have.property('statusCode'); | ||||
|     var status = this.obj.statusCode; | ||||
|  | ||||
|     this.assert( | ||||
|         code == status | ||||
|       , 'expected response code of ' + code + ' ' + i(statusCodes[code]) | ||||
|         + ', but got ' + status + ' ' + i(statusCodes[status]) | ||||
|       , 'expected to not respond with ' + code + ' ' + i(statusCodes[code])); | ||||
|  | ||||
|     return this; | ||||
|   }, | ||||
|  | ||||
|   /** | ||||
|    * Assert that this response has content-type: application/json. | ||||
|    * | ||||
|    * @return {Assertion} for chaining | ||||
|    * @api public | ||||
|    */ | ||||
|  | ||||
|   get json() { | ||||
|     this.obj.should.have.property('headers'); | ||||
|     this.obj.headers.should.have.property('content-type'); | ||||
|     this.obj.headers['content-type'].should.include('application/json'); | ||||
|   }, | ||||
|  | ||||
|   /** | ||||
|    * Assert that this response has content-type: text/html. | ||||
|    * | ||||
|    * @return {Assertion} for chaining | ||||
|    * @api public | ||||
|    */ | ||||
|  | ||||
|   get html() { | ||||
|     this.obj.should.have.property('headers'); | ||||
|     this.obj.headers.should.have.property('content-type'); | ||||
|     this.obj.headers['content-type'].should.include('text/html'); | ||||
|   }, | ||||
|  | ||||
|   /** | ||||
|    * Assert that this function will or will not | ||||
|    * throw an exception. | ||||
|    * | ||||
|    * @return {Assertion} for chaining | ||||
|    * @api public | ||||
|    */ | ||||
|  | ||||
|   throw: function(message){ | ||||
|     var fn = this.obj | ||||
|       , err = {} | ||||
|       , errorInfo = '' | ||||
|       , ok = true; | ||||
|  | ||||
|     try { | ||||
|       fn(); | ||||
|       ok = false; | ||||
|     } catch (e) { | ||||
|       err = e; | ||||
|     } | ||||
|  | ||||
|     if (ok) { | ||||
|       if ('string' == typeof message) { | ||||
|         ok = message == err.message; | ||||
|       } else if (message instanceof RegExp) { | ||||
|         ok = message.test(err.message); | ||||
|       } | ||||
|  | ||||
|       if (message && !ok) { | ||||
|         if ('string' == typeof message) { | ||||
|           errorInfo = " with a message matching '" + message + "', but got '" + err.message + "'"; | ||||
|         } else { | ||||
|           errorInfo = " with a message matching " + message + ", but got '" + err.message + "'"; | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     this.assert( | ||||
|         ok | ||||
|       , 'expected an exception to be thrown' + errorInfo | ||||
|       , 'expected no exception to be thrown, got "' + err.message + '"'); | ||||
|  | ||||
|     return this; | ||||
|   } | ||||
| }; | ||||
|  | ||||
| /** | ||||
|  * Aliases. | ||||
|  */ | ||||
|  | ||||
| (function alias(name, as){ | ||||
|   Assertion.prototype[as] = Assertion.prototype[name]; | ||||
|   return alias; | ||||
| }) | ||||
| ('length', 'lengthOf') | ||||
| ('keys', 'key') | ||||
| ('ownProperty', 'haveOwnProperty') | ||||
| ('above', 'greaterThan') | ||||
| ('below', 'lessThan'); | ||||
|  | ||||
							
								
								
									
										13
									
								
								node_modules/should/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								node_modules/should/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| {   "name": "should" | ||||
|   , "description": "test framework agnostic BDD-style assertions" | ||||
|   , "version": "0.5.1" | ||||
|   , "author": "TJ Holowaychuk <tj@vision-media.ca>" | ||||
|   , "contributors": [ "Aseem Kishore <aseem.kishore@gmail.com>" ] | ||||
|   , "devDependencies": { | ||||
|       "mocha": "*" | ||||
|     , "should": "*" | ||||
|   } | ||||
|   , "keywords": ["test", "bdd", "assert"] | ||||
|   , "main": "./lib/should.js" | ||||
|   , "engines": { "node": ">= 0.2.0" } | ||||
| } | ||||
							
								
								
									
										96
									
								
								node_modules/should/test/exist.test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								node_modules/should/test/exist.test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,96 @@ | ||||
|  | ||||
| /** | ||||
|  * Module dependencies. | ||||
|  */ | ||||
|  | ||||
| var should = require('../'); | ||||
| var util = require('util'); | ||||
|  | ||||
| function err(fn, msg) { | ||||
|   try { | ||||
|     fn(); | ||||
|     should.fail('expected an error'); | ||||
|   } catch (err) { | ||||
|     should.equal(msg, err.message); | ||||
|   } | ||||
| } | ||||
|  | ||||
| function err_should_exist(obj) { | ||||
|   err(function () { | ||||
|     should.exist(obj); | ||||
|   }, 'expected ' + util.inspect(obj) + ' to exist'); | ||||
| } | ||||
|  | ||||
| function err_should_not_exist(obj) { | ||||
|   err(function () { | ||||
|     should.not.exist(obj); | ||||
|   }, 'expected ' + util.inspect(obj) + ' to not exist'); | ||||
| } | ||||
|  | ||||
| module.exports = { | ||||
|    | ||||
|   // static should.exist() pass: | ||||
|    | ||||
|   'test static should.exist() pass w/ bool': function () { | ||||
|     should.exist(false); | ||||
|   }, | ||||
|    | ||||
|   'test static should.exist() pass w/ number': function () { | ||||
|     should.exist(0); | ||||
|   }, | ||||
|    | ||||
|   'test static should.exist() pass w/ string': function () { | ||||
|     should.exist(''); | ||||
|   }, | ||||
|    | ||||
|   'test static should.exist() pass w/ object': function () { | ||||
|     should.exist({}); | ||||
|   }, | ||||
|    | ||||
|   'test static should.exist() pass w/ array': function () { | ||||
|     should.exist([]); | ||||
|   }, | ||||
|    | ||||
|   // static should.exist() fail: | ||||
|    | ||||
|   'test static should.exist() fail w/ null': function () { | ||||
|     err_should_exist(null); | ||||
|   }, | ||||
|    | ||||
|   'test static should.exist() fail w/ undefined': function () { | ||||
|     err_should_exist(undefined); | ||||
|   }, | ||||
|    | ||||
|   // static should.not.exist() pass: | ||||
|    | ||||
|   'test static should.not.exist() pass w/ null': function () { | ||||
|     should.not.exist(null); | ||||
|   }, | ||||
|    | ||||
|   'test static should.not.exist() pass w/ undefined': function () { | ||||
|     should.not.exist(undefined); | ||||
|   }, | ||||
|    | ||||
|   // static should.not.exist() fail: | ||||
|    | ||||
|   'test static should.not.exist() fail w/ bool': function () { | ||||
|     err_should_not_exist(false); | ||||
|   }, | ||||
|    | ||||
|   'test static should.not.exist() fail w/ number': function () { | ||||
|     err_should_not_exist(0); | ||||
|   }, | ||||
|    | ||||
|   'test static should.not.exist() fail w/ string': function () { | ||||
|     err_should_not_exist(''); | ||||
|   }, | ||||
|    | ||||
|   'test static should.not.exist() fail w/ object': function () { | ||||
|     err_should_not_exist({}); | ||||
|   }, | ||||
|    | ||||
|   'test static should.not.exist() fail w/ array': function () { | ||||
|     err_should_not_exist([]); | ||||
|   }, | ||||
|    | ||||
| }; | ||||
							
								
								
									
										534
									
								
								node_modules/should/test/should.test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										534
									
								
								node_modules/should/test/should.test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,534 @@ | ||||
|  | ||||
| /** | ||||
|  * Module dependencies. | ||||
|  */ | ||||
|  | ||||
| var should = require('../'); | ||||
|  | ||||
| function err(fn, msg) { | ||||
|   try { | ||||
|     fn(); | ||||
|     should.fail('expected an error'); | ||||
|   } catch (err) { | ||||
|     should.equal(msg, err.message); | ||||
|   } | ||||
| } | ||||
|  | ||||
| module.exports = { | ||||
|   'test .version': function(){ | ||||
|     should.version.should.match(/^\d+\.\d+\.\d+$/); | ||||
|   }, | ||||
|  | ||||
|   'test double require': function(){ | ||||
|     require('should').should.equal(should); | ||||
|   }, | ||||
|  | ||||
|   'test assertion': function(){ | ||||
|     'test'.should.be.a.string; | ||||
|     should.equal('foo', 'foo'); | ||||
|   }, | ||||
|    | ||||
|   'test true': function(){ | ||||
|     true.should.be.true; | ||||
|     false.should.not.be.true; | ||||
|     (1).should.not.be.true; | ||||
|      | ||||
|     err(function(){ | ||||
|       'test'.should.be.true; | ||||
|     }, "expected 'test' to be true") | ||||
|   }, | ||||
|    | ||||
|   'test ok': function(){ | ||||
|     true.should.be.ok; | ||||
|     false.should.not.be.ok; | ||||
|     (1).should.be.ok; | ||||
|     (0).should.not.be.ok; | ||||
|      | ||||
|     err(function(){ | ||||
|       ''.should.be.ok; | ||||
|     }, "expected '' to be truthy"); | ||||
|      | ||||
|     err(function(){ | ||||
|       'test'.should.not.be.ok; | ||||
|     }, "expected 'test' to be falsey"); | ||||
|   }, | ||||
|    | ||||
|   'test false': function(){ | ||||
|     false.should.be.false; | ||||
|     true.should.not.be.false; | ||||
|     (0).should.not.be.false; | ||||
|      | ||||
|     err(function(){ | ||||
|       ''.should.be.false; | ||||
|     }, "expected '' to be false") | ||||
|   }, | ||||
|    | ||||
|   'test arguments': function(){ | ||||
|     var args = (function(){ return arguments; })(1,2,3); | ||||
|     args.should.be.arguments; | ||||
|     [].should.not.be.arguments; | ||||
|   }, | ||||
|    | ||||
|   'test .equal()': function(){ | ||||
|     var foo; | ||||
|     should.equal(undefined, foo); | ||||
|   }, | ||||
|    | ||||
|   'test typeof': function(){ | ||||
|     'test'.should.be.a('string'); | ||||
|  | ||||
|     err(function(){ | ||||
|       'test'.should.not.be.a('string'); | ||||
|     }, "expected 'test' not to be a string"); | ||||
|  | ||||
|     err(function(){ | ||||
|       'test'.should.not.be.a('string', 'foo'); | ||||
|     }, "expected 'test' not to be a string | foo"); | ||||
|      | ||||
|     (5).should.be.a('number'); | ||||
|  | ||||
|     err(function(){ | ||||
|       (5).should.not.be.a('number'); | ||||
|     }, "expected 5 not to be a number"); | ||||
|  | ||||
|     err(function(){ | ||||
|       (5).should.not.be.a('number', 'foo'); | ||||
|     }, "expected 5 not to be a number | foo"); | ||||
|   }, | ||||
|    | ||||
|   'test instanceof': function(){ | ||||
|     function Foo(){} | ||||
|     new Foo().should.be.an.instanceof(Foo); | ||||
|  | ||||
|     err(function(){ | ||||
|       (3).should.an.instanceof(Foo); | ||||
|     }, "expected 3 to be an instance of Foo"); | ||||
|  | ||||
|     err(function(){ | ||||
|       (3).should.an.instanceof(Foo, 'foo'); | ||||
|     }, "expected 3 to be an instance of Foo | foo"); | ||||
|   }, | ||||
|    | ||||
|   'test within(start, finish)': function(){ | ||||
|     (5).should.be.within(5, 10); | ||||
|     (5).should.be.within(3,6); | ||||
|     (5).should.be.within(3,5); | ||||
|     (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(){ | ||||
|       (10).should.be.within(50,100); | ||||
|     }, "expected 10 to be within 50..100"); | ||||
|  | ||||
|     err(function(){ | ||||
|       (5).should.not.be.within(4,6, 'foo'); | ||||
|     }, "expected 5 to not be within 4..6 | foo"); | ||||
|  | ||||
|     err(function(){ | ||||
|       (10).should.be.within(50,100, 'foo'); | ||||
|     }, "expected 10 to be within 50..100 | foo"); | ||||
|   }, | ||||
|    | ||||
|   'test above(n)': function(){ | ||||
|     (5).should.be.above(2); | ||||
|     (5).should.be.greaterThan(2); | ||||
|     (5).should.not.be.above(5); | ||||
|     (5).should.not.be.above(6); | ||||
|  | ||||
|     err(function(){ | ||||
|       (5).should.be.above(6); | ||||
|     }, "expected 5 to be above 6"); | ||||
|      | ||||
|     err(function(){ | ||||
|       (10).should.not.be.above(6); | ||||
|     }, "expected 10 to be below 6"); | ||||
|  | ||||
|     err(function(){ | ||||
|       (5).should.be.above(6, 'foo'); | ||||
|     }, "expected 5 to be above 6 | foo"); | ||||
|      | ||||
|     err(function(){ | ||||
|       (10).should.not.be.above(6, 'foo'); | ||||
|     }, "expected 10 to be below 6 | foo"); | ||||
|   }, | ||||
|  | ||||
|   'test below(n)': function(){ | ||||
|     (2).should.be.below(5); | ||||
|     (2).should.be.lessThan(5); | ||||
|     (5).should.not.be.below(5); | ||||
|     (6).should.not.be.below(5); | ||||
|  | ||||
|     err(function(){ | ||||
|       (6).should.be.below(5); | ||||
|     }, "expected 6 to be below 5"); | ||||
|      | ||||
|     err(function(){ | ||||
|       (6).should.not.be.below(10); | ||||
|     }, "expected 6 to be above 10"); | ||||
|  | ||||
|     err(function(){ | ||||
|       (6).should.be.below(5, 'foo'); | ||||
|     }, "expected 6 to be below 5 | foo"); | ||||
|      | ||||
|     err(function(){ | ||||
|       (6).should.not.be.below(10, 'foo'); | ||||
|     }, "expected 6 to be above 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(){ | ||||
|       'foobar'.should.not.match(/^foo/i) | ||||
|     }, "expected 'foobar' not to match /^foo/i"); | ||||
|  | ||||
|     err(function(){ | ||||
|       'foobar'.should.match(/^bar/i, 'foo') | ||||
|     }, "expected 'foobar' to match /^bar/i | foo"); | ||||
|      | ||||
|     err(function(){ | ||||
|       'foobar'.should.not.match(/^foo/i, 'foo') | ||||
|     }, "expected 'foobar' not to match /^foo/i | foo"); | ||||
|   }, | ||||
|    | ||||
|   'test length(n)': function(){ | ||||
|     'test'.should.have.length(4); | ||||
|     'test'.should.not.have.length(3); | ||||
|     [1,2,3].should.have.length(3); | ||||
|      | ||||
|     err(function(){ | ||||
|       (4).should.have.length(3); | ||||
|     }, 'expected 4 to have a property \'length\''); | ||||
|      | ||||
|     err(function(){ | ||||
|       'asd'.should.not.have.length(3); | ||||
|     }, "expected 'asd' to not have a length of 3"); | ||||
|  | ||||
|     err(function(){ | ||||
|       'asd'.should.have.length(4, 'foo'); | ||||
|     }, "expected 'asd' to have a length of 4 but got 3 | foo"); | ||||
|      | ||||
|     err(function(){ | ||||
|       'asd'.should.not.have.length(3, 'foo'); | ||||
|     }, "expected 'asd' to not have a length of 3 | foo"); | ||||
|  | ||||
|   }, | ||||
|    | ||||
|   'test eql(val)': function(){ | ||||
|     'test'.should.eql('test'); | ||||
|     ({ foo: 'bar' }).should.eql({ foo: 'bar' }); | ||||
|     (1).should.eql(1); | ||||
|     '4'.should.not.eql(4); | ||||
|      | ||||
|     err(function(){ | ||||
|       (4).should.eql(3); | ||||
|     }, 'expected 4 to equal 3'); | ||||
|  | ||||
|     err(function(){ | ||||
|       (4).should.eql(3, "foo"); | ||||
|     }, 'expected 4 to equal 3 | foo'); | ||||
|  | ||||
|     err(function(){ | ||||
|       (3).should.not.eql(3, "foo"); | ||||
|     }, 'expected 3 to not equal 3 | foo'); | ||||
|   }, | ||||
|  | ||||
|   'test .json': function(){ | ||||
|     var req = { | ||||
|       headers: { | ||||
|         'content-type': 'application/json' | ||||
|       } | ||||
|     }; | ||||
|  | ||||
|     req.should.be.json; | ||||
|  | ||||
|     var req = { | ||||
|       headers: { | ||||
|         'content-type': 'application/json; charset=utf-8' | ||||
|       } | ||||
|     }; | ||||
|  | ||||
|     req.should.be.json; | ||||
|   }, | ||||
|  | ||||
|   'test equal(val)': function(){ | ||||
|     'test'.should.equal('test'); | ||||
|     (1).should.equal(1); | ||||
|      | ||||
|     err(function(){ | ||||
|       (4).should.equal(3); | ||||
|     }, 'expected 4 to equal 3'); | ||||
|      | ||||
|     err(function(){ | ||||
|       '4'.should.equal(4); | ||||
|     }, "expected '4' to equal 4"); | ||||
|  | ||||
|     err(function(){ | ||||
|       (3).should.equal(4, "foo"); | ||||
|     }, "expected 3 to equal 4 | foo"); | ||||
|  | ||||
|     err(function(){ | ||||
|       (4).should.not.equal(4, "foo"); | ||||
|     }, "expected 4 to not equal 4 | foo"); | ||||
|   }, | ||||
|    | ||||
|   'test empty': function(){ | ||||
|     ''.should.be.empty; | ||||
|     [].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(){ | ||||
|       ''.should.not.be.empty; | ||||
|     }, "expected '' not to be empty"); | ||||
|   }, | ||||
|    | ||||
|   'test property(name)': function(){ | ||||
|     'test'.should.have.property('length'); | ||||
|     (4).should.not.have.property('length'); | ||||
|      | ||||
|     err(function(){ | ||||
|       'asd'.should.have.property('foo'); | ||||
|     }, "expected 'asd' to have a property 'foo'"); | ||||
|  | ||||
|     err(function(){ | ||||
|       'asd'.should.have.property('foo', undefined, 'foo'); | ||||
|     }, "expected 'asd' to have a property 'foo' | foo"); | ||||
|  | ||||
|     err(function(){ | ||||
|       'asd'.should.not.have.property('length', undefined, 'foo'); | ||||
|     }, "expected 'asd' to not have a property 'length' | 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(){ | ||||
|       'asd'.should.have.property('constructor', Number); | ||||
|     }, "expected 'asd' to have a property 'constructor' of [Function: Number], but got [Function: String]"); | ||||
|  | ||||
|     err(function(){ | ||||
|       'asd'.should.have.property('length', 4, 'foo'); | ||||
|     }, "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(){ | ||||
|       'asd'.should.have.property('constructor', Number, 'foo'); | ||||
|     }, "expected 'asd' to have a property 'constructor' of [Function: Number], but got [Function: String] | foo"); | ||||
|   }, | ||||
|    | ||||
|   'test ownProperty(name)': function(){ | ||||
|     'test'.should.have.ownProperty('length'); | ||||
|     'test'.should.haveOwnProperty('length'); | ||||
|     ({ length: 12 }).should.have.ownProperty('length'); | ||||
|      | ||||
|     err(function(){ | ||||
|       ({ length: 12 }).should.not.have.ownProperty('length'); | ||||
|     }, "expected { length: 12 } to not have own property 'length'"); | ||||
|  | ||||
|     err(function(){ | ||||
|       ({ length: 12 }).should.not.have.ownProperty('length', 'foo'); | ||||
|     }, "expected { length: 12 } to not have own property 'length' | foo"); | ||||
|  | ||||
|     err(function(){ | ||||
|       ({ length: 12 }).should.have.ownProperty('foo', 'foo'); | ||||
|     }, "expected { length: 12 } to have own property 'foo' | foo"); | ||||
|   }, | ||||
|  | ||||
|   'test include() with string': function(){ | ||||
|     'foobar'.should.include('bar'); | ||||
|     'foobar'.should.include('foo'); | ||||
|     'foobar'.should.not.include('baz'); | ||||
|    | ||||
|     err(function(){ | ||||
|       'foobar'.should.include('baz'); | ||||
|     }, "expected 'foobar' to include 'baz'"); | ||||
|      | ||||
|     err(function(){ | ||||
|       'foobar'.should.not.include('bar'); | ||||
|     }, "expected 'foobar' to not include 'bar'"); | ||||
|  | ||||
|     err(function(){ | ||||
|       'foobar'.should.include('baz', 'foo'); | ||||
|     }, "expected 'foobar' to include 'baz' | foo"); | ||||
|      | ||||
|     err(function(){ | ||||
|       'foobar'.should.not.include('bar', 'foo'); | ||||
|     }, "expected 'foobar' to not include 'bar' | foo"); | ||||
|   }, | ||||
|  | ||||
|   'test include() with array': function(){ | ||||
|     ['foo', 'bar'].should.include('foo'); | ||||
|     ['foo', 'bar'].should.include('foo'); | ||||
|     ['foo', 'bar'].should.include('bar'); | ||||
|     [1,2].should.include(1); | ||||
|     ['foo', 'bar'].should.not.include('baz'); | ||||
|     ['foo', 'bar'].should.not.include(1); | ||||
|  | ||||
|     err(function(){ | ||||
|       ['foo'].should.include('bar'); | ||||
|     }, "expected [ 'foo' ] to include 'bar'"); | ||||
|      | ||||
|     err(function(){ | ||||
|       ['bar', 'foo'].should.not.include('foo'); | ||||
|     }, "expected [ 'bar', 'foo' ] to not include 'foo'"); | ||||
|  | ||||
|     err(function(){ | ||||
|       ['foo'].should.include('bar', 'foo'); | ||||
|     }, "expected [ 'foo' ] to include 'bar' | foo"); | ||||
|      | ||||
|     err(function(){ | ||||
|       ['bar', 'foo'].should.not.include('foo', 'foo'); | ||||
|     }, "expected [ 'bar', 'foo' ] to not include 'foo' | foo"); | ||||
|   }, | ||||
|    | ||||
|   'test includeEql() with array': function(){ | ||||
|     [['foo'], ['bar']].should.includeEql(['foo']); | ||||
|     [['foo'], ['bar']].should.includeEql(['bar']); | ||||
|     [['foo'], ['bar']].should.not.includeEql(['baz']); | ||||
|     [].should.not.includeEql(['baz']); | ||||
|  | ||||
|     err(function(){ | ||||
|       [['foo']].should.includeEql(['bar']); | ||||
|     }, "expected [ [ 'foo' ] ] to include an object equal to [ 'bar' ]"); | ||||
|      | ||||
|     err(function(){ | ||||
|       [['foo']].should.not.includeEql(['foo']); | ||||
|     }, "expected [ [ 'foo' ] ] to not include an object equal to [ 'foo' ]"); | ||||
|  | ||||
|     err(function(){ | ||||
|       [['foo']].should.includeEql(['bar'], 'foo'); | ||||
|     }, "expected [ [ 'foo' ] ] to include an object equal to [ 'bar' ] | foo"); | ||||
|      | ||||
|     err(function(){ | ||||
|       [['foo']].should.not.includeEql(['foo'], 'foo'); | ||||
|     }, "expected [ [ 'foo' ] ] to not include an object equal to [ 'foo' ] | foo"); | ||||
|   }, | ||||
|    | ||||
|   'test keys(array)': function(){ | ||||
|     ({ foo: 1 }).should.have.keys(['foo']); | ||||
|     ({ foo: 1, bar: 2 }).should.have.keys(['foo', 'bar']); | ||||
|     ({ foo: 1, bar: 2 }).should.have.keys('foo', 'bar'); | ||||
|  | ||||
|     err(function(){ | ||||
|       ({ foo: 1 }).should.have.keys(); | ||||
|     }, "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(){ | ||||
|       ({ foo: 1, bar: 2 }).should.not.have.keys(['foo', 'bar']); | ||||
|     }, "expected { foo: 1, bar: 2 } to not have keys 'foo', and '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'); | ||||
|   }, | ||||
|  | ||||
|   'test throw()': function(){ | ||||
|     (function(){}).should.not.throw(); | ||||
|     (function(){ throw new Error('fail') }).should.throw(); | ||||
|  | ||||
|     err(function(){ | ||||
|       (function(){}).should.throw(); | ||||
|     }, 'expected an exception to be thrown'); | ||||
|  | ||||
|     err(function(){ | ||||
|       (function(){ | ||||
|         throw new Error('fail'); | ||||
|       }).should.not.throw(); | ||||
|     }, 'expected no exception to be thrown, got "fail"'); | ||||
|   }, | ||||
|  | ||||
|   'test throw() with regex message': function(){ | ||||
|     (function(){ throw new Error('fail'); }).should.throw(/fail/); | ||||
|  | ||||
|     err(function(){ | ||||
|       (function(){}).should.throw(/fail/); | ||||
|     }, 'expected an exception to be thrown'); | ||||
|  | ||||
|     err(function(){ | ||||
|       (function(){ throw new Error('error'); }).should.throw(/fail/); | ||||
|     }, "expected an exception to be thrown with a message matching /fail/, but got 'error'"); | ||||
|   }, | ||||
|  | ||||
|   'test throw() with string message': function(){ | ||||
|     (function(){ throw new Error('fail'); }).should.throw('fail'); | ||||
|  | ||||
|     err(function(){ | ||||
|       (function(){}).should.throw('fail'); | ||||
|     }, 'expected an exception to be thrown'); | ||||
|  | ||||
|     err(function(){ | ||||
|       (function(){ throw new Error('error'); }).should.throw('fail'); | ||||
|     }, "expected an exception to be thrown with a message matching 'fail', but got 'error'"); | ||||
|   } | ||||
| };  | ||||
		Reference in New Issue
	
	Block a user