Comparing version 0.4.1 to 0.4.2
16
chai.js
@@ -82,7 +82,7 @@ !function (name, definition) { | ||
* The `expect` interface provides a function as a starting point for chaining | ||
* your language assertions. It works on both node.js and in the browser. | ||
* your language assertions. It works on node.js and in all browsers. | ||
* | ||
* The `should` interface extends `Object.prototype` to provide a single getter as | ||
* the starting point for your language assertions. Most browser don't like | ||
* extensions to `Object.prototype` so it is not recommended for browser use. | ||
* the starting point for your language assertions. It works on node.js and in | ||
* all browsers except Internet Explorer. | ||
* | ||
@@ -349,3 +349,3 @@ * #### Configuration | ||
, 'expected ' + this.inspect + ' to be truthy' | ||
, 'expected ' + this.inspect + ' to be falsey'); | ||
, 'expected ' + this.inspect + ' to be falsy'); | ||
@@ -1015,3 +1015,3 @@ return this; | ||
exports.version = '0.4.1'; | ||
exports.version = '0.4.2'; | ||
@@ -1335,3 +1335,3 @@ exports.Assertion = require('./assertion'); | ||
assert.isNull = function (val, msg) { | ||
new Assertion(val, msg).to.not.exist; | ||
new Assertion(val, msg).to.equal(null); | ||
}; | ||
@@ -1354,3 +1354,3 @@ | ||
assert.isNotNull = function (val, msg) { | ||
new Assertion(val, msg).to.exist; | ||
new Assertion(val, msg).to.not.equal(null); | ||
}; | ||
@@ -1462,3 +1462,3 @@ | ||
assert.isNumber = function (val, msg) { | ||
new Assertion(val, msg).to.be.instanceof(Number); | ||
new Assertion(val, msg).to.be.a('number'); | ||
}; | ||
@@ -1465,0 +1465,0 @@ |
0.4.2 / 2012-02-28 | ||
================== | ||
* fix for `process` not available in browser when used via browserify. Closes #28 | ||
* Merge pull request #31 from joliss/doc | ||
* Document that "should" works in browsers other than IE | ||
* Merge pull request #30 from logicalparadox/assert-tests | ||
* Update the browser version of chai. | ||
* Update `assert.doesNotThrow` test in order to check the use case when type is a string. | ||
* Add test for `assert.ifError`. | ||
* Falsey -> falsy. | ||
* Full coverage for `assert.throws` and `assert.doesNotThrow`. | ||
* Add test for `assert.doesNotThrow`. | ||
* Add test for `assert.throws`. | ||
* Add test for `assert.length`. | ||
* Add test for `assert.include`. | ||
* Add test for `assert.isBoolean`. | ||
* Fix the implementation of `assert.isNumber`. | ||
* Add test for `assert.isNumber`. | ||
* Add test for `assert.isString`. | ||
* Add test for `assert.isArray`. | ||
* Add test for `assert.isUndefined`. | ||
* Add test for `assert.isNotNull`. | ||
* Fix `assert.isNotNull` implementation. | ||
* Fix `assert.isNull` implementation. | ||
* Add test for `assert.isNull`. | ||
* Add test for `assert.notDeepEqual`. | ||
* Add test for `assert.deepEqual`. | ||
* Add test for `assert.notStrictEqual`. | ||
* Add test for `assert.strictEqual`. | ||
* Add test for `assert.notEqual`. | ||
0.4.1 / 2012-02-26 | ||
@@ -3,0 +35,0 @@ ================== |
@@ -1,3 +0,3 @@ | ||
module.exports = process.env.CHAI_COV | ||
module.exports = (process && process.env && process.env.CHAI_COV) | ||
? require('./lib-cov/chai') | ||
: require('./lib/chai'); |
@@ -241,3 +241,3 @@ /* automatically generated by JSCoverage - do not edit */ | ||
_$jscoverage['assertion.js'][292]++; | ||
this.assert(this.obj, "expected " + this.inspect + " to be truthy", "expected " + this.inspect + " to be falsey"); | ||
this.assert(this.obj, "expected " + this.inspect + " to be truthy", "expected " + this.inspect + " to be falsy"); | ||
_$jscoverage['assertion.js'][297]++; | ||
@@ -528,2 +528,2 @@ return this; | ||
})("length", "lengthOf")("keys", "key")("ownProperty", "haveOwnProperty")("above", "greaterThan")("below", "lessThan")("throw", "throws")("throw", "Throw")("instanceof", "instanceOf"); | ||
_$jscoverage['assertion.js'].source = ["/*!"," * chai"," * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>"," * MIT Licensed"," *"," * Primarily a refactor of: should.js"," * https://github.com/visionmedia/should.js"," * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>"," * MIT Licensed"," */","","/**"," * ### BDD Style Introduction"," *"," * The BDD style is exposed through `expect` or `should` interfaces. In both"," * scenarios, you chain together natural language assertions."," *"," * // expect"," * var expect = require('chai').expect;"," * expect(foo).to.equal('bar');"," *"," * // should"," * var should = require('chai').should();"," * foo.should.equal('bar');"," *"," * #### Differences"," *"," * The `expect` interface provides a function as a starting point for chaining"," * your language assertions. It works on both node.js and in the browser."," *"," * The `should` interface extends `Object.prototype` to provide a single getter as"," * the starting point for your language assertions. Most browser don't like"," * extensions to `Object.prototype` so it is not recommended for browser use."," *"," * #### Configuration"," *"," * By default, Chai does not show stack traces upon an AssertionError. This can"," * be changed by modifying the `includeStack` parameter for chai.Assertion. For example:"," *"," * var chai = require('chai');"," * chai.Assertion.includeStack = true; // defaults to false"," */","","/*!"," * Module dependencies."," */","","var AssertionError = require('./error')"," , eql = require('./utils/eql')"," , toString = Object.prototype.toString"," , inspect = require('./utils/inspect');","","/*!"," * Module export."," */","","module.exports = Assertion;","","","/*!"," * # Assertion Constructor"," *"," * Creates object for chaining."," *"," * @api private"," */","","function Assertion (obj, msg, stack) {"," this.ssfi = stack || arguments.callee;"," this.obj = obj;"," this.msg = msg;","}","","/*!"," * ## Assertion.includeStack"," * , toString = Object.prototype.toString "," *"," * User configurable property, influences whether stack trace"," * is included in Assertion error message. Default of false"," * suppresses stack trace in the error message"," *"," * Assertion.includeStack = true; // enable stack on error"," *"," * @api public"," */","","Assertion.includeStack = false;","","/*!"," * # .assert(expression, message, negateMessage)"," *"," * Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass."," *"," * @name assert"," * @param {Philosophical} expression to be tested"," * @param {String} message to display if fails"," * @param {String} negatedMessage to display if negated expression fails"," * @api private"," */","","Assertion.prototype.assert = function (expr, msg, negateMsg) {"," var msg = (this.negate ? negateMsg : msg)"," , ok = this.negate ? !expr : expr;",""," if (!ok) {"," throw new AssertionError({"," operator: this.msg,"," message: msg,"," stackStartFunction: (Assertion.includeStack) ? this.assert : this.ssfi"," });"," }","};","","/*!"," * # inspect"," *"," * Returns the current object stringified."," *"," * @name inspect"," * @api private"," */","","Object.defineProperty(Assertion.prototype, 'inspect',"," { get: function () {"," return inspect(this.obj);"," },"," configurable: true","});","","/**"," * # to"," *"," * Language chain."," *"," * @name to"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'to',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # be"," *"," * Language chain."," *"," * @name be"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'be',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # been"," *"," * Language chain. Also tests `tense` to past for addon"," * modules that use the tense feature."," *"," * @name been"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'been',"," { get: function () {"," this.tense = 'past';"," return this;"," },"," configurable: true","});","","/**"," * # an"," *"," * Language chain."," *"," * @name an"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'an',"," { get: function () {"," return this;"," },"," configurable: true","});","/**"," * # is"," *"," * Language chain."," *"," * @name is"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'is',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # and"," *"," * Language chain."," *"," * @name and"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'and',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # have"," *"," * Language chain."," *"," * @name have"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'have',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # with"," *"," * Language chain."," *"," * @name with"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'with',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # .not"," *"," * Negates any of assertions following in the chain."," *"," * @name not"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'not',"," { get: function () {"," this.negate = true;"," return this;"," },"," configurable: true","});","","/**"," * # .ok"," *"," * Assert object truthiness."," *"," * expect('everthing').to.be.ok;"," * expect(false).to.not.be.ok;"," * expect(undefined).to.not.be.ok;"," * expect(null).to.not.be.ok;"," *"," * @name ok"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'ok',"," { get: function () {"," this.assert("," this.obj"," , 'expected ' + this.inspect + ' to be truthy'"," , 'expected ' + this.inspect + ' to be falsey');",""," return this;"," },"," configurable: true","});","","/**"," * # .true"," *"," * Assert object is true"," *"," * @name true"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'true',"," { get: function () {"," this.assert("," true === this.obj"," , 'expected ' + this.inspect + ' to be true'"," , 'expected ' + this.inspect + ' to be false');",""," return this;"," },"," configurable: true","});","","/**"," * # .false"," *"," * Assert object is false"," *"," * @name false"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'false',"," { get: function () {"," this.assert("," false === this.obj"," , 'expected ' + this.inspect + ' to be false'"," , 'expected ' + this.inspect + ' to be true');",""," return this;"," },"," configurable: true","});","","/**"," * # .exist"," *"," * Assert object exists (null)."," *"," * var foo = 'hi'"," * , bar;"," * expect(foo).to.exist;"," * expect(bar).to.not.exist;"," *"," * @name exist"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'exist',"," { get: function () {"," this.assert("," null != this.obj"," , 'expected ' + this.inspect + ' to exist'"," , 'expected ' + this.inspect + ' to not exist');",""," return this;"," },"," configurable: true","});","","/**"," * # .empty"," *"," * Assert object's length to be 0."," *"," * expect([]).to.be.empty;"," *"," * @name empty"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'empty',"," { get: function () {"," new Assertion(this.obj).to.have.property('length');",""," this.assert("," 0 === this.obj.length"," , 'expected ' + this.inspect + ' to be empty'"," , 'expected ' + this.inspect + ' not to be empty');",""," return this;"," },"," configurable: true","});","","/**"," * # .arguments"," *"," * Assert object is an instanceof arguments."," *"," * function test () {"," * expect(arguments).to.be.arguments;"," * }"," *"," * @name arguments"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'arguments',"," { get: function () {"," 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;"," },"," configurable: true","});","","/**"," * # .equal(value)"," *"," * Assert strict equality."," *"," * expect('hello').to.equal('hello');"," *"," * @name equal"," * @param {*} value"," * @api public"," */","","Assertion.prototype.equal = function (val) {"," this.assert("," val === this.obj"," , 'expected ' + this.inspect + ' to equal ' + inspect(val)"," , 'expected ' + this.inspect + ' to not equal ' + inspect(val));",""," return this;","};","","/**"," * # .eql(value)"," *"," * Assert deep equality."," *"," * expect({ foo: 'bar' }).to.eql({ foo: 'bar' });"," *"," * @name eql"," * @param {*} value"," * @api public"," */","","Assertion.prototype.eql = function (obj) {"," this.assert("," eql(obj, this.obj)"," , 'expected ' + this.inspect + ' to equal ' + inspect(obj)"," , 'expected ' + this.inspect + ' to not equal ' + inspect(obj));"," return this;","};","","/**"," * # .above(value)"," *"," * Assert greater than `value`."," *"," * expect(10).to.be.above(5);"," *"," * @name above"," * @param {Number} value"," * @api public"," */","","Assertion.prototype.above = function (val) {"," this.assert("," this.obj > val"," , 'expected ' + this.inspect + ' to be above ' + val"," , 'expected ' + this.inspect + ' to be below ' + val);",""," return this;","};","","/**"," * # .below(value)"," *"," * Assert less than `value`."," *"," * expect(5).to.be.below(10);"," *"," * @name below"," * @param {Number} value"," * @api public"," */","","Assertion.prototype.below = function (val) {"," this.assert("," this.obj < val"," , 'expected ' + this.inspect + ' to be below ' + val"," , 'expected ' + this.inspect + ' to be above ' + val);",""," return this;","};","","/**"," * # .within(start, finish)"," *"," * Assert that a number is within a range."," *"," * expect(7).to.be.within(5,10);"," *"," * @name within"," * @param {Number} start lowerbound inclusive"," * @param {Number} finish upperbound inclusive"," * @api public"," */","","Assertion.prototype.within = function (start, finish) {"," var range = start + '..' + finish;",""," this.assert("," this.obj >= start && this.obj <= finish"," , 'expected ' + this.inspect + ' to be within ' + range"," , 'expected ' + this.inspect + ' to not be within ' + range);",""," return this;","};","","/**"," * # .a(type)"," *"," * Assert typeof."," *"," * expect('test').to.be.a('string');"," *"," * @name a"," * @param {String} type"," * @api public"," */","","Assertion.prototype.a = function (type) {"," var klass = type.charAt(0).toUpperCase() + type.slice(1);",""," this.assert("," '[object ' + klass + ']' === toString.call(this.obj)"," , 'expected ' + this.inspect + ' to be a ' + type"," , 'expected ' + this.inspect + ' not to be a ' + type);",""," return this;","};","","/**"," * # .instanceof(constructor)"," *"," * Assert instanceof."," *"," * var Tea = function (name) { this.name = name; }"," * , Chai = new Tea('chai');"," *"," * expect(Chai).to.be.an.instanceOf(Tea);"," *"," * @name instanceof"," * @param {Constructor}"," * @alias instanceOf"," * @api public"," */","","Assertion.prototype.instanceof = function (constructor) {"," var name = constructor.name;"," this.assert("," this.obj instanceof constructor"," , 'expected ' + this.inspect + ' to be an instance of ' + name"," , 'expected ' + this.inspect + ' to not be an instance of ' + name);",""," return this;","};","","/**"," * # .property(name, [value])"," *"," * Assert that property of `name` exists, optionally with `value`."," *"," * var obj = { foo: 'bar' }"," * expect(obj).to.have.property('foo');"," * expect(obj).to.have.property('foo', 'bar');"," * expect(obj).to.have.property('foo').to.be.a('string');"," *"," * @name property"," * @param {String} name"," * @param {*} value (optional)"," * @returns value of property for chaining"," * @api public"," */","","Assertion.prototype.property = function (name, val) {"," if (this.negate && undefined !== val) {"," if (undefined === this.obj[name]) {"," throw new Error(this.inspect + ' has no property ' + inspect(name));"," }"," } else {"," this.assert("," undefined !== this.obj[name]"," , 'expected ' + this.inspect + ' to have a property ' + inspect(name)"," , 'expected ' + this.inspect + ' to not have property ' + inspect(name));"," }",""," if (undefined !== val) {"," this.assert("," val === this.obj[name]"," , 'expected ' + this.inspect + ' to have a property ' + inspect(name) + ' of ' +"," inspect(val) + ', but got ' + inspect(this.obj[name])"," , 'expected ' + this.inspect + ' to not have a property ' + inspect(name) + ' of ' + inspect(val));"," }",""," this.obj = this.obj[name];"," return this;","};","","/**"," * # .ownProperty(name)"," *"," * Assert that has own property by `name`."," *"," * expect('test').to.have.ownProperty('length');"," *"," * @name ownProperty"," * @alias haveOwnProperty"," * @param {String} name"," * @api public"," */","","Assertion.prototype.ownProperty = function (name) {"," this.assert("," this.obj.hasOwnProperty(name)"," , 'expected ' + this.inspect + ' to have own property ' + inspect(name)"," , 'expected ' + this.inspect + ' to not have own property ' + inspect(name));"," return this;","};","","/**"," * # .length(val)"," *"," * Assert that object has expected length."," *"," * expect([1,2,3]).to.have.length(3);"," * expect('foobar').to.have.length(6);"," *"," * @name length"," * @alias lengthOf"," * @param {Number} length"," * @api public"," */","","Assertion.prototype.length = function (n) {"," new Assertion(this.obj).to.have.property('length');"," var len = this.obj.length;",""," this.assert("," len == n"," , 'expected ' + this.inspect + ' to have a length of ' + n + ' but got ' + len"," , 'expected ' + this.inspect + ' to not have a length of ' + len);",""," return this;","};","","/**"," * # .match(regexp)"," *"," * Assert that matches regular expression."," *"," * expect('foobar').to.match(/^foo/);"," *"," * @name match"," * @param {RegExp} RegularExpression"," * @api public"," */","","Assertion.prototype.match = function (re) {"," this.assert("," re.exec(this.obj)"," , 'expected ' + this.inspect + ' to match ' + re"," , 'expected ' + this.inspect + ' not to match ' + re);",""," return this;","};","","/**"," * # .include(obj)"," *"," * Assert the inclusion of an object in an Array or substring in string."," *"," * expect([1,2,3]).to.include(2);"," *"," * @name include"," * @param {Object|String|Number} obj"," * @api public"," */","","Assertion.prototype.include = function (obj) {"," this.assert("," ~this.obj.indexOf(obj)"," , 'expected ' + this.inspect + ' to include ' + inspect(obj)"," , 'expected ' + this.inspect + ' to not include ' + inspect(obj));",""," return this;","};","","/**"," * # .string(string)"," *"," * Assert inclusion of string in string."," *"," * expect('foobar').to.have.string('bar');"," *"," * @name string"," * @param {String} string"," * @api public"," */","","Assertion.prototype.string = function (str) {"," new Assertion(this.obj).is.a('string');",""," this.assert("," ~this.obj.indexOf(str)"," , 'expected ' + this.inspect + ' to contain ' + inspect(str)"," , 'expected ' + this.inspect + ' to not contain ' + inspect(str));",""," return this;","};","","","","/**"," * # contain"," *"," * Toggles the `contain` flag for the `keys` assertion."," *"," * @name contain"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'contain',"," { get: function () {"," this.contains = true;"," return this;"," },"," configurable: true","});","","/**"," * # .keys(key1, [key2], [...])"," *"," * Assert exact keys or the inclusing of keys using the `contain` modifier."," *"," * expect({ foo: 1, bar: 2 }).to.have.keys(['foo', 'bar']);"," * expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('foo', 'bar');"," *"," * @name keys"," * @alias key"," * @param {String|Array} Keys"," * @api public"," */","","Assertion.prototype.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;",""," // Inclusion"," ok = keys.every(function(key){"," return ~actual.indexOf(key);"," });",""," // Strict"," if (!this.negate && !this.contains) {"," ok = ok && keys.length == actual.length;"," }",""," // Key string"," if (len > 1) {"," keys = keys.map(function(key){"," return inspect(key);"," });"," var last = keys.pop();"," str = keys.join(', ') + ', and ' + last;"," } else {"," str = inspect(keys[0]);"," }",""," // Form"," str = (len > 1 ? 'keys ' : 'key ') + str;",""," // Have / include"," str = (this.contains ? 'contain ' : 'have ') + str;",""," // Assertion"," this.assert("," ok"," , 'expected ' + this.inspect + ' to ' + str"," , 'expected ' + this.inspect + ' to not ' + str);",""," return this;","}","","/**"," * # .throw(constructor)"," *"," * Assert that a function will throw a specific type of error."," *"," * var fn = function () { throw new ReferenceError(''); }"," * expect(fn).to.throw(ReferenceError);"," *"," * @name throw"," * @alias throws"," * @alias Throw"," * @param {ErrorConstructor} constructor"," * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types"," * @api public"," */","","Assertion.prototype.throw = function (constructor) {"," new Assertion(this.obj).is.a('function');",""," var thrown = false;",""," try {"," this.obj();"," } catch (err) {"," if (constructor && 'function' === typeof constructor && constructor.constructor != RegExp) {"," this.assert("," err instanceof constructor && err.name == constructor.name"," , 'expected ' + this.inspect + ' to throw ' + constructor.name + ' but a ' + err.name + ' was thrown'"," , 'expected ' + this.inspect + ' to not throw ' + constructor.name );"," return this;"," } else if (constructor && constructor instanceof RegExp) {"," this.assert("," constructor.exec(err.message)"," , 'expected ' + this.inspect + ' to throw error matching ' + constructor + ' but got ' + inspect(err.message)"," , 'expected ' + this.inspect + ' to throw error not matching ' + constructor);"," return this;"," } else {"," thrown = true;"," }"," }",""," var name = (constructor ? constructor.name : 'an error');",""," this.assert("," thrown === true"," , 'expected ' + this.inspect + ' to throw ' + name"," , 'expected ' + this.inspect + ' to not throw ' + name);",""," return this;","};","","/**"," * # .respondTo(method)"," *"," * Assert that object/class will respond to a method."," *"," * expect(Klass).to.respondTo('bar');"," * expect(obj).to.respondTo('bar');"," *"," * @name respondTo"," * @param {String} method"," * @api public"," */","","Assertion.prototype.respondTo = function (method) {"," var context = ('function' === typeof this.obj)"," ? this.obj.prototype[method]"," : this.obj[method];",""," this.assert("," 'function' === typeof context"," , 'expected ' + this.inspect + ' to respond to ' + inspect(method)"," , 'expected ' + this.inspect + ' to not respond to ' + inspect(method));",""," return this;","};","","/**"," * # .satisfy(method)"," *"," * Assert that passes a truth test."," *"," * expect(1).to.satisfy(function(num) { return num > 0; });"," *"," * @name satisfy"," * @param {Function} matcher"," * @api public"," */","","Assertion.prototype.satisfy = function (matcher) {"," this.assert("," matcher(this.obj)"," , 'expected ' + this.inspect + ' to satisfy ' + inspect(matcher)"," , 'expected ' + this.inspect + ' to not satisfy' + inspect(matcher));",""," return this;","};","","/**"," * # .closeTo(expected, delta)"," *"," * Assert that actual is equal to +/- delta."," *"," * expect(1.5).to.be.closeTo(1, 0.5);"," *"," * @name closeTo"," * @param {Number} expected"," * @param {Number} delta"," * @api public"," */","","Assertion.prototype.closeTo = function (expected, delta) {"," this.assert("," (this.obj - delta === expected) || (this.obj + delta === expected)"," , 'expected ' + this.inspect + ' to be close to ' + expected + ' +/- ' + delta"," , 'expected ' + this.inspect + ' not to be close to ' + expected + ' +/- ' + delta);",""," 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')","('throw', 'throws')","('throw', 'Throw') // for troublesome browsers","('instanceof', 'instanceOf');"]; | ||
_$jscoverage['assertion.js'].source = ["/*!"," * chai"," * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>"," * MIT Licensed"," *"," * Primarily a refactor of: should.js"," * https://github.com/visionmedia/should.js"," * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>"," * MIT Licensed"," */","","/**"," * ### BDD Style Introduction"," *"," * The BDD style is exposed through `expect` or `should` interfaces. In both"," * scenarios, you chain together natural language assertions."," *"," * // expect"," * var expect = require('chai').expect;"," * expect(foo).to.equal('bar');"," *"," * // should"," * var should = require('chai').should();"," * foo.should.equal('bar');"," *"," * #### Differences"," *"," * The `expect` interface provides a function as a starting point for chaining"," * your language assertions. It works on node.js and in all browsers."," *"," * The `should` interface extends `Object.prototype` to provide a single getter as"," * the starting point for your language assertions. It works on node.js and in"," * all browsers except Internet Explorer."," *"," * #### Configuration"," *"," * By default, Chai does not show stack traces upon an AssertionError. This can"," * be changed by modifying the `includeStack` parameter for chai.Assertion. For example:"," *"," * var chai = require('chai');"," * chai.Assertion.includeStack = true; // defaults to false"," */","","/*!"," * Module dependencies."," */","","var AssertionError = require('./error')"," , eql = require('./utils/eql')"," , toString = Object.prototype.toString"," , inspect = require('./utils/inspect');","","/*!"," * Module export."," */","","module.exports = Assertion;","","","/*!"," * # Assertion Constructor"," *"," * Creates object for chaining."," *"," * @api private"," */","","function Assertion (obj, msg, stack) {"," this.ssfi = stack || arguments.callee;"," this.obj = obj;"," this.msg = msg;","}","","/*!"," * ## Assertion.includeStack"," * , toString = Object.prototype.toString "," *"," * User configurable property, influences whether stack trace"," * is included in Assertion error message. Default of false"," * suppresses stack trace in the error message"," *"," * Assertion.includeStack = true; // enable stack on error"," *"," * @api public"," */","","Assertion.includeStack = false;","","/*!"," * # .assert(expression, message, negateMessage)"," *"," * Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass."," *"," * @name assert"," * @param {Philosophical} expression to be tested"," * @param {String} message to display if fails"," * @param {String} negatedMessage to display if negated expression fails"," * @api private"," */","","Assertion.prototype.assert = function (expr, msg, negateMsg) {"," var msg = (this.negate ? negateMsg : msg)"," , ok = this.negate ? !expr : expr;",""," if (!ok) {"," throw new AssertionError({"," operator: this.msg,"," message: msg,"," stackStartFunction: (Assertion.includeStack) ? this.assert : this.ssfi"," });"," }","};","","/*!"," * # inspect"," *"," * Returns the current object stringified."," *"," * @name inspect"," * @api private"," */","","Object.defineProperty(Assertion.prototype, 'inspect',"," { get: function () {"," return inspect(this.obj);"," },"," configurable: true","});","","/**"," * # to"," *"," * Language chain."," *"," * @name to"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'to',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # be"," *"," * Language chain."," *"," * @name be"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'be',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # been"," *"," * Language chain. Also tests `tense` to past for addon"," * modules that use the tense feature."," *"," * @name been"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'been',"," { get: function () {"," this.tense = 'past';"," return this;"," },"," configurable: true","});","","/**"," * # an"," *"," * Language chain."," *"," * @name an"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'an',"," { get: function () {"," return this;"," },"," configurable: true","});","/**"," * # is"," *"," * Language chain."," *"," * @name is"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'is',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # and"," *"," * Language chain."," *"," * @name and"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'and',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # have"," *"," * Language chain."," *"," * @name have"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'have',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # with"," *"," * Language chain."," *"," * @name with"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'with',"," { get: function () {"," return this;"," },"," configurable: true","});","","/**"," * # .not"," *"," * Negates any of assertions following in the chain."," *"," * @name not"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'not',"," { get: function () {"," this.negate = true;"," return this;"," },"," configurable: true","});","","/**"," * # .ok"," *"," * Assert object truthiness."," *"," * expect('everthing').to.be.ok;"," * expect(false).to.not.be.ok;"," * expect(undefined).to.not.be.ok;"," * expect(null).to.not.be.ok;"," *"," * @name ok"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'ok',"," { get: function () {"," this.assert("," this.obj"," , 'expected ' + this.inspect + ' to be truthy'"," , 'expected ' + this.inspect + ' to be falsy');",""," return this;"," },"," configurable: true","});","","/**"," * # .true"," *"," * Assert object is true"," *"," * @name true"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'true',"," { get: function () {"," this.assert("," true === this.obj"," , 'expected ' + this.inspect + ' to be true'"," , 'expected ' + this.inspect + ' to be false');",""," return this;"," },"," configurable: true","});","","/**"," * # .false"," *"," * Assert object is false"," *"," * @name false"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'false',"," { get: function () {"," this.assert("," false === this.obj"," , 'expected ' + this.inspect + ' to be false'"," , 'expected ' + this.inspect + ' to be true');",""," return this;"," },"," configurable: true","});","","/**"," * # .exist"," *"," * Assert object exists (null)."," *"," * var foo = 'hi'"," * , bar;"," * expect(foo).to.exist;"," * expect(bar).to.not.exist;"," *"," * @name exist"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'exist',"," { get: function () {"," this.assert("," null != this.obj"," , 'expected ' + this.inspect + ' to exist'"," , 'expected ' + this.inspect + ' to not exist');",""," return this;"," },"," configurable: true","});","","/**"," * # .empty"," *"," * Assert object's length to be 0."," *"," * expect([]).to.be.empty;"," *"," * @name empty"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'empty',"," { get: function () {"," new Assertion(this.obj).to.have.property('length');",""," this.assert("," 0 === this.obj.length"," , 'expected ' + this.inspect + ' to be empty'"," , 'expected ' + this.inspect + ' not to be empty');",""," return this;"," },"," configurable: true","});","","/**"," * # .arguments"," *"," * Assert object is an instanceof arguments."," *"," * function test () {"," * expect(arguments).to.be.arguments;"," * }"," *"," * @name arguments"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'arguments',"," { get: function () {"," 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;"," },"," configurable: true","});","","/**"," * # .equal(value)"," *"," * Assert strict equality."," *"," * expect('hello').to.equal('hello');"," *"," * @name equal"," * @param {*} value"," * @api public"," */","","Assertion.prototype.equal = function (val) {"," this.assert("," val === this.obj"," , 'expected ' + this.inspect + ' to equal ' + inspect(val)"," , 'expected ' + this.inspect + ' to not equal ' + inspect(val));",""," return this;","};","","/**"," * # .eql(value)"," *"," * Assert deep equality."," *"," * expect({ foo: 'bar' }).to.eql({ foo: 'bar' });"," *"," * @name eql"," * @param {*} value"," * @api public"," */","","Assertion.prototype.eql = function (obj) {"," this.assert("," eql(obj, this.obj)"," , 'expected ' + this.inspect + ' to equal ' + inspect(obj)"," , 'expected ' + this.inspect + ' to not equal ' + inspect(obj));"," return this;","};","","/**"," * # .above(value)"," *"," * Assert greater than `value`."," *"," * expect(10).to.be.above(5);"," *"," * @name above"," * @param {Number} value"," * @api public"," */","","Assertion.prototype.above = function (val) {"," this.assert("," this.obj > val"," , 'expected ' + this.inspect + ' to be above ' + val"," , 'expected ' + this.inspect + ' to be below ' + val);",""," return this;","};","","/**"," * # .below(value)"," *"," * Assert less than `value`."," *"," * expect(5).to.be.below(10);"," *"," * @name below"," * @param {Number} value"," * @api public"," */","","Assertion.prototype.below = function (val) {"," this.assert("," this.obj < val"," , 'expected ' + this.inspect + ' to be below ' + val"," , 'expected ' + this.inspect + ' to be above ' + val);",""," return this;","};","","/**"," * # .within(start, finish)"," *"," * Assert that a number is within a range."," *"," * expect(7).to.be.within(5,10);"," *"," * @name within"," * @param {Number} start lowerbound inclusive"," * @param {Number} finish upperbound inclusive"," * @api public"," */","","Assertion.prototype.within = function (start, finish) {"," var range = start + '..' + finish;",""," this.assert("," this.obj >= start && this.obj <= finish"," , 'expected ' + this.inspect + ' to be within ' + range"," , 'expected ' + this.inspect + ' to not be within ' + range);",""," return this;","};","","/**"," * # .a(type)"," *"," * Assert typeof."," *"," * expect('test').to.be.a('string');"," *"," * @name a"," * @param {String} type"," * @api public"," */","","Assertion.prototype.a = function (type) {"," var klass = type.charAt(0).toUpperCase() + type.slice(1);",""," this.assert("," '[object ' + klass + ']' === toString.call(this.obj)"," , 'expected ' + this.inspect + ' to be a ' + type"," , 'expected ' + this.inspect + ' not to be a ' + type);",""," return this;","};","","/**"," * # .instanceof(constructor)"," *"," * Assert instanceof."," *"," * var Tea = function (name) { this.name = name; }"," * , Chai = new Tea('chai');"," *"," * expect(Chai).to.be.an.instanceOf(Tea);"," *"," * @name instanceof"," * @param {Constructor}"," * @alias instanceOf"," * @api public"," */","","Assertion.prototype.instanceof = function (constructor) {"," var name = constructor.name;"," this.assert("," this.obj instanceof constructor"," , 'expected ' + this.inspect + ' to be an instance of ' + name"," , 'expected ' + this.inspect + ' to not be an instance of ' + name);",""," return this;","};","","/**"," * # .property(name, [value])"," *"," * Assert that property of `name` exists, optionally with `value`."," *"," * var obj = { foo: 'bar' }"," * expect(obj).to.have.property('foo');"," * expect(obj).to.have.property('foo', 'bar');"," * expect(obj).to.have.property('foo').to.be.a('string');"," *"," * @name property"," * @param {String} name"," * @param {*} value (optional)"," * @returns value of property for chaining"," * @api public"," */","","Assertion.prototype.property = function (name, val) {"," if (this.negate && undefined !== val) {"," if (undefined === this.obj[name]) {"," throw new Error(this.inspect + ' has no property ' + inspect(name));"," }"," } else {"," this.assert("," undefined !== this.obj[name]"," , 'expected ' + this.inspect + ' to have a property ' + inspect(name)"," , 'expected ' + this.inspect + ' to not have property ' + inspect(name));"," }",""," if (undefined !== val) {"," this.assert("," val === this.obj[name]"," , 'expected ' + this.inspect + ' to have a property ' + inspect(name) + ' of ' +"," inspect(val) + ', but got ' + inspect(this.obj[name])"," , 'expected ' + this.inspect + ' to not have a property ' + inspect(name) + ' of ' + inspect(val));"," }",""," this.obj = this.obj[name];"," return this;","};","","/**"," * # .ownProperty(name)"," *"," * Assert that has own property by `name`."," *"," * expect('test').to.have.ownProperty('length');"," *"," * @name ownProperty"," * @alias haveOwnProperty"," * @param {String} name"," * @api public"," */","","Assertion.prototype.ownProperty = function (name) {"," this.assert("," this.obj.hasOwnProperty(name)"," , 'expected ' + this.inspect + ' to have own property ' + inspect(name)"," , 'expected ' + this.inspect + ' to not have own property ' + inspect(name));"," return this;","};","","/**"," * # .length(val)"," *"," * Assert that object has expected length."," *"," * expect([1,2,3]).to.have.length(3);"," * expect('foobar').to.have.length(6);"," *"," * @name length"," * @alias lengthOf"," * @param {Number} length"," * @api public"," */","","Assertion.prototype.length = function (n) {"," new Assertion(this.obj).to.have.property('length');"," var len = this.obj.length;",""," this.assert("," len == n"," , 'expected ' + this.inspect + ' to have a length of ' + n + ' but got ' + len"," , 'expected ' + this.inspect + ' to not have a length of ' + len);",""," return this;","};","","/**"," * # .match(regexp)"," *"," * Assert that matches regular expression."," *"," * expect('foobar').to.match(/^foo/);"," *"," * @name match"," * @param {RegExp} RegularExpression"," * @api public"," */","","Assertion.prototype.match = function (re) {"," this.assert("," re.exec(this.obj)"," , 'expected ' + this.inspect + ' to match ' + re"," , 'expected ' + this.inspect + ' not to match ' + re);",""," return this;","};","","/**"," * # .include(obj)"," *"," * Assert the inclusion of an object in an Array or substring in string."," *"," * expect([1,2,3]).to.include(2);"," *"," * @name include"," * @param {Object|String|Number} obj"," * @api public"," */","","Assertion.prototype.include = function (obj) {"," this.assert("," ~this.obj.indexOf(obj)"," , 'expected ' + this.inspect + ' to include ' + inspect(obj)"," , 'expected ' + this.inspect + ' to not include ' + inspect(obj));",""," return this;","};","","/**"," * # .string(string)"," *"," * Assert inclusion of string in string."," *"," * expect('foobar').to.have.string('bar');"," *"," * @name string"," * @param {String} string"," * @api public"," */","","Assertion.prototype.string = function (str) {"," new Assertion(this.obj).is.a('string');",""," this.assert("," ~this.obj.indexOf(str)"," , 'expected ' + this.inspect + ' to contain ' + inspect(str)"," , 'expected ' + this.inspect + ' to not contain ' + inspect(str));",""," return this;","};","","","","/**"," * # contain"," *"," * Toggles the `contain` flag for the `keys` assertion."," *"," * @name contain"," * @api public"," */","","Object.defineProperty(Assertion.prototype, 'contain',"," { get: function () {"," this.contains = true;"," return this;"," },"," configurable: true","});","","/**"," * # .keys(key1, [key2], [...])"," *"," * Assert exact keys or the inclusing of keys using the `contain` modifier."," *"," * expect({ foo: 1, bar: 2 }).to.have.keys(['foo', 'bar']);"," * expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('foo', 'bar');"," *"," * @name keys"," * @alias key"," * @param {String|Array} Keys"," * @api public"," */","","Assertion.prototype.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;",""," // Inclusion"," ok = keys.every(function(key){"," return ~actual.indexOf(key);"," });",""," // Strict"," if (!this.negate && !this.contains) {"," ok = ok && keys.length == actual.length;"," }",""," // Key string"," if (len > 1) {"," keys = keys.map(function(key){"," return inspect(key);"," });"," var last = keys.pop();"," str = keys.join(', ') + ', and ' + last;"," } else {"," str = inspect(keys[0]);"," }",""," // Form"," str = (len > 1 ? 'keys ' : 'key ') + str;",""," // Have / include"," str = (this.contains ? 'contain ' : 'have ') + str;",""," // Assertion"," this.assert("," ok"," , 'expected ' + this.inspect + ' to ' + str"," , 'expected ' + this.inspect + ' to not ' + str);",""," return this;","}","","/**"," * # .throw(constructor)"," *"," * Assert that a function will throw a specific type of error."," *"," * var fn = function () { throw new ReferenceError(''); }"," * expect(fn).to.throw(ReferenceError);"," *"," * @name throw"," * @alias throws"," * @alias Throw"," * @param {ErrorConstructor} constructor"," * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types"," * @api public"," */","","Assertion.prototype.throw = function (constructor) {"," new Assertion(this.obj).is.a('function');",""," var thrown = false;",""," try {"," this.obj();"," } catch (err) {"," if (constructor && 'function' === typeof constructor && constructor.constructor != RegExp) {"," this.assert("," err instanceof constructor && err.name == constructor.name"," , 'expected ' + this.inspect + ' to throw ' + constructor.name + ' but a ' + err.name + ' was thrown'"," , 'expected ' + this.inspect + ' to not throw ' + constructor.name );"," return this;"," } else if (constructor && constructor instanceof RegExp) {"," this.assert("," constructor.exec(err.message)"," , 'expected ' + this.inspect + ' to throw error matching ' + constructor + ' but got ' + inspect(err.message)"," , 'expected ' + this.inspect + ' to throw error not matching ' + constructor);"," return this;"," } else {"," thrown = true;"," }"," }",""," var name = (constructor ? constructor.name : 'an error');",""," this.assert("," thrown === true"," , 'expected ' + this.inspect + ' to throw ' + name"," , 'expected ' + this.inspect + ' to not throw ' + name);",""," return this;","};","","/**"," * # .respondTo(method)"," *"," * Assert that object/class will respond to a method."," *"," * expect(Klass).to.respondTo('bar');"," * expect(obj).to.respondTo('bar');"," *"," * @name respondTo"," * @param {String} method"," * @api public"," */","","Assertion.prototype.respondTo = function (method) {"," var context = ('function' === typeof this.obj)"," ? this.obj.prototype[method]"," : this.obj[method];",""," this.assert("," 'function' === typeof context"," , 'expected ' + this.inspect + ' to respond to ' + inspect(method)"," , 'expected ' + this.inspect + ' to not respond to ' + inspect(method));",""," return this;","};","","/**"," * # .satisfy(method)"," *"," * Assert that passes a truth test."," *"," * expect(1).to.satisfy(function(num) { return num > 0; });"," *"," * @name satisfy"," * @param {Function} matcher"," * @api public"," */","","Assertion.prototype.satisfy = function (matcher) {"," this.assert("," matcher(this.obj)"," , 'expected ' + this.inspect + ' to satisfy ' + inspect(matcher)"," , 'expected ' + this.inspect + ' to not satisfy' + inspect(matcher));",""," return this;","};","","/**"," * # .closeTo(expected, delta)"," *"," * Assert that actual is equal to +/- delta."," *"," * expect(1.5).to.be.closeTo(1, 0.5);"," *"," * @name closeTo"," * @param {Number} expected"," * @param {Number} delta"," * @api public"," */","","Assertion.prototype.closeTo = function (expected, delta) {"," this.assert("," (this.obj - delta === expected) || (this.obj + delta === expected)"," , 'expected ' + this.inspect + ' to be close to ' + expected + ' +/- ' + delta"," , 'expected ' + this.inspect + ' not to be close to ' + expected + ' +/- ' + delta);",""," 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')","('throw', 'throws')","('throw', 'Throw') // for troublesome browsers","('instanceof', 'instanceOf');"]; |
@@ -30,3 +30,3 @@ /* automatically generated by JSCoverage - do not edit */ | ||
_$jscoverage['chai.js'][10]++; | ||
exports.version = "0.4.1"; | ||
exports.version = "0.4.2"; | ||
_$jscoverage['chai.js'][12]++; | ||
@@ -67,2 +67,2 @@ exports.Assertion = require("./assertion"); | ||
exports.use(assert); | ||
_$jscoverage['chai.js'].source = ["/*!"," * chai"," * Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com>"," * MIT Licensed"," */","","var used = [];","var exports = module.exports = {};","","exports.version = '0.4.1';","","exports.Assertion = require('./assertion');","exports.AssertionError = require('./error');","","exports.inspect = require('./utils/inspect');","","exports.use = function (fn) {"," if (!~used.indexOf(fn)) {"," fn(this);"," used.push(fn);"," }",""," return this;","};","","exports.fail = function (actual, expected, message, operator, stackStartFunction) {"," throw new exports.AssertionError({"," message: message,"," actual: actual,"," expected: expected,"," operator: operator,"," stackStartFunction: stackStartFunction"," });","};","","var expect = require('./interface/expect');","exports.use(expect);","","var should = require('./interface/should');","exports.use(should);","","var assert = require('./interface/assert');","exports.use(assert);"]; | ||
_$jscoverage['chai.js'].source = ["/*!"," * chai"," * Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com>"," * MIT Licensed"," */","","var used = [];","var exports = module.exports = {};","","exports.version = '0.4.2';","","exports.Assertion = require('./assertion');","exports.AssertionError = require('./error');","","exports.inspect = require('./utils/inspect');","","exports.use = function (fn) {"," if (!~used.indexOf(fn)) {"," fn(this);"," used.push(fn);"," }",""," return this;","};","","exports.fail = function (actual, expected, message, operator, stackStartFunction) {"," throw new exports.AssertionError({"," message: message,"," actual: actual,"," expected: expected,"," operator: operator,"," stackStartFunction: stackStartFunction"," });","};","","var expect = require('./interface/expect');","exports.use(expect);","","var should = require('./interface/should');","exports.use(should);","","var assert = require('./interface/assert');","exports.use(assert);"]; |
@@ -134,3 +134,3 @@ /* automatically generated by JSCoverage - do not edit */ | ||
_$jscoverage['interface/assert.js'][230]++; | ||
new Assertion(val, msg).to.not.exist; | ||
new Assertion(val, msg).to.equal(null); | ||
}); | ||
@@ -140,3 +140,3 @@ _$jscoverage['interface/assert.js'][247]++; | ||
_$jscoverage['interface/assert.js'][248]++; | ||
new Assertion(val, msg).to.exist; | ||
new Assertion(val, msg).to.not.equal(null); | ||
}); | ||
@@ -171,3 +171,3 @@ _$jscoverage['interface/assert.js'][264]++; | ||
_$jscoverage['interface/assert.js'][355]++; | ||
new Assertion(val, msg).to.be["instanceof"](Number); | ||
new Assertion(val, msg).to.be.a("number"); | ||
}); | ||
@@ -253,2 +253,2 @@ _$jscoverage['interface/assert.js'][375]++; | ||
}); | ||
_$jscoverage['interface/assert.js'].source = ["/*!"," * chai"," * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>"," * MIT Licensed"," */","","/**"," * ### TDD Style Introduction"," *"," * The TDD style is exposed through `assert` interfaces. This provides"," * the classic assert.`test` notation, similiar to that packaged with"," * node.js. This assert module, however, provides several additional"," * tests and is browser compatible."," *"," * // assert"," * var assert = require('chai').assert;"," * , foo = 'bar';"," *"," * assert.typeOf(foo, 'string');"," * assert.equal(foo, 'bar');"," *"," * #### Configuration"," *"," * By default, Chai does not show stack traces upon an AssertionError. This can"," * be changed by modifying the `includeStack` parameter for chai.Assertion. For example:"," *"," * var chai = require('chai');"," * chai.Assertion.includeStack = true; // defaults to false"," */","","module.exports = function (chai) {"," /*!"," * Chai dependencies."," */"," var Assertion = chai.Assertion"," , inspect = chai.inspect;",""," /*!"," * Module export."," */",""," var assert = chai.assert = {};",""," /**"," * # .ok(object, [message])"," *"," * Assert object is truthy."," *"," * assert.ok('everthing', 'everything is ok');"," * assert.ok(false, 'this will fail');"," *"," * @name ok"," * @param {*} object to test"," * @param {String} message"," * @api public"," */",""," assert.ok = function (val, msg) {"," new Assertion(val, msg).is.ok;"," };",""," /**"," * # .equal(actual, expected, [message])"," *"," * Assert strict equality."," *"," * assert.equal(3, 3, 'these numbers are equal');"," *"," * @name equal"," * @param {*} actual"," * @param {*} expected"," * @param {String} message"," * @api public"," */",""," assert.equal = function (act, exp, msg) {"," var test = new Assertion(act, msg);",""," test.assert("," exp == test.obj"," , 'expected ' + test.inspect + ' to equal ' + inspect(exp)"," , 'expected ' + test.inspect + ' to not equal ' + inspect(exp));"," };",""," /**"," * # .notEqual(actual, expected, [message])"," *"," * Assert not equal."," *"," * assert.notEqual(3, 4, 'these numbers are not equal');"," *"," * @name notEqual"," * @param {*} actual"," * @param {*} expected"," * @param {String} message"," * @api public"," */",""," assert.notEqual = function (act, exp, msg) {"," var test = new Assertion(act, msg);",""," test.assert("," exp != test.obj"," , 'expected ' + test.inspect + ' to equal ' + inspect(exp)"," , 'expected ' + test.inspect + ' to not equal ' + inspect(exp));"," };",""," /**"," * # .strictEqual(actual, expected, [message])"," *"," * Assert strict equality."," *"," * assert.strictEqual(true, true, 'these booleans are strictly equal');"," *"," * @name strictEqual"," * @param {*} actual"," * @param {*} expected"," * @param {String} message"," * @api public"," */",""," assert.strictEqual = function (act, exp, msg) {"," new Assertion(act, msg).to.equal(exp);"," };",""," /**"," * # .notStrictEqual(actual, expected, [message])"," *"," * Assert strict equality."," *"," * assert.notStrictEqual(1, true, 'these booleans are not strictly equal');"," *"," * @name notStrictEqual"," * @param {*} actual"," * @param {*} expected"," * @param {String} message"," * @api public"," */",""," assert.notStrictEqual = function (act, exp, msg) {"," new Assertion(act, msg).to.not.equal(exp);"," };",""," /**"," * # .deepEqual(actual, expected, [message])"," *"," * Assert not deep equality."," *"," * assert.deepEqual({ tea: 'green' }, { tea: 'green' });"," *"," * @name deepEqual"," * @param {*} actual"," * @param {*} expected"," * @param {String} message"," * @api public"," */",""," assert.deepEqual = function (act, exp, msg) {"," new Assertion(act, msg).to.eql(exp);"," };",""," /**"," * # .notDeepEqual(actual, expected, [message])"," *"," * Assert not deep equality."," *"," * assert.notDeepEqual({ tea: 'green' }, { tea: 'jasmine' });"," *"," * @name notDeepEqual"," * @param {*} actual"," * @param {*} expected"," * @param {String} message"," * @api public"," */",""," assert.notDeepEqual = function (act, exp, msg) {"," new Assertion(act, msg).to.not.eql(exp);"," };",""," /**"," * # .isTrue(value, [message])"," *"," * Assert `value` is true."," *"," * var tea_served = true;"," * assert.isTrue(tea_served, 'the tea has been served');"," *"," * @name isTrue"," * @param {Boolean} value"," * @param {String} message"," * @api public"," */",""," assert.isTrue = function (val, msg) {"," new Assertion(val, msg).is.true;"," };",""," /**"," * # .isFalse(value, [message])"," *"," * Assert `value` is false."," *"," * var tea_served = false;"," * assert.isFalse(tea_served, 'no tea yet? hmm...');"," *"," * @name isFalse"," * @param {Boolean} value"," * @param {String} message"," * @api public"," */",""," assert.isFalse = function (val, msg) {"," new Assertion(val, msg).is.false;"," };",""," /**"," * # .isNull(value, [message])"," *"," * Assert `value` is null."," *"," * assert.isNull(err, 'no errors');"," *"," * @name isNull"," * @param {*} value"," * @param {String} message"," * @api public"," */",""," assert.isNull = function (val, msg) {"," new Assertion(val, msg).to.not.exist;"," };",""," /**"," * # .isNotNull(value, [message])"," *"," * Assert `value` is not null."," *"," * var tea = 'tasty chai';"," * assert.isNotNull(tea, 'great, time for tea!');"," *"," * @name isNotNull"," * @param {*} value"," * @param {String} message"," * @api public"," */",""," assert.isNotNull = function (val, msg) {"," new Assertion(val, msg).to.exist;"," };",""," /**"," * # .isUndefined(value, [message])"," *"," * Assert `value` is undefined."," *"," * assert.isUndefined(tea, 'no tea defined');"," *"," * @name isUndefined"," * @param {*} value"," * @param {String} message"," * @api public"," */",""," assert.isUndefined = function (val, msg) {"," new Assertion(val, msg).to.equal(undefined);"," };",""," /**"," * # .isFunction(value, [message])"," *"," * Assert `value` is a function."," *"," * var serve_tea = function () { return 'cup of tea'; };"," * assert.isFunction(serve_tea, 'great, we can have tea now');"," *"," * @name isFunction"," * @param {Function} value"," * @param {String} message"," * @api public"," */",""," assert.isFunction = function (val, msg) {"," new Assertion(val, msg).to.be.a('function');"," };",""," /**"," * # .isObject(value, [message])"," *"," * Assert `value` is an object."," *"," * var selection = { name: 'Chai', serve: 'with spices' };"," * assert.isObject(selection, 'tea selection is an object');"," *"," * @name isObject"," * @param {Object} value"," * @param {String} message"," * @api public"," */",""," assert.isObject = function (val, msg) {"," new Assertion(val, msg).to.be.a('object');"," };",""," /**"," * # .isArray(value, [message])"," *"," * Assert `value` is an instance of Array."," *"," * var menu = [ 'green', 'chai', 'oolong' ];"," * assert.isArray(menu, 'what kind of tea do we want?');"," *"," * @name isArray"," * @param {*} value"," * @param {String} message"," * @api public"," */",""," assert.isArray = function (val, msg) {"," new Assertion(val, msg).to.be.instanceof(Array);"," };",""," /**"," * # .isString(value, [message])"," *"," * Assert `value` is a string."," *"," * var teaorder = 'chai';"," * assert.isString(tea_order, 'order placed');"," *"," * @name isString"," * @param {String} value"," * @param {String} message"," * @api public"," */",""," assert.isString = function (val, msg) {"," new Assertion(val, msg).to.be.a('string');"," };",""," /**"," * # .isNumber(value, [message])"," *"," * Assert `value` is a number"," *"," * var cups = 2;"," * assert.isNumber(cups, 'how many cups');"," *"," * @name isNumber"," * @param {Number} value"," * @param {String} message"," * @api public"," */",""," assert.isNumber = function (val, msg) {"," new Assertion(val, msg).to.be.instanceof(Number);"," };",""," /**"," * # .isBoolean(value, [message])"," *"," * Assert `value` is a boolean"," *"," * var teaready = true"," * , teaserved = false;"," *"," * assert.isBoolean(tea_ready, 'is the tea ready');"," * assert.isBoolean(tea_served, 'has tea been served');"," *"," * @name isBoolean"," * @param {*} value"," * @param {String} message"," * @api public"," */",""," assert.isBoolean = function (val, msg) {"," new Assertion(val, msg).to.be.a('boolean');"," };",""," /**"," * # .typeOf(value, name, [message])"," *"," * Assert typeof `value` is `name`."," *"," * assert.typeOf('tea', 'string', 'we have a string');"," *"," * @name typeOf"," * @param {*} value"," * @param {String} typeof name"," * @param {String} message"," * @api public"," */",""," assert.typeOf = function (val, type, msg) {"," new Assertion(val, msg).to.be.a(type);"," };",""," /**"," * # .instanceOf(object, constructor, [message])"," *"," * Assert `value` is instanceof `constructor`."," *"," * var Tea = function (name) { this.name = name; }"," * , Chai = new Tea('chai');"," *"," * assert.instanceOf(Chai, Tea, 'chai is an instance of tea');"," *"," * @name instanceOf"," * @param {Object} object"," * @param {Constructor} constructor"," * @param {String} message"," * @api public"," */",""," assert.instanceOf = function (val, type, msg) {"," new Assertion(val, msg).to.be.instanceof(type);"," };",""," /**"," * # .include(value, includes, [message])"," *"," * Assert the inclusion of an object in another. Works"," * for strings and arrays."," *"," * assert.include('foobar', 'bar', 'foobar contains string `var`);"," * assert.include([ 1, 2, 3], 3, 'array contains value);"," *"," * @name include"," * @param {Array|String} value"," * @param {*} includes"," * @param {String} message"," * @api public"," */",""," assert.include = function (exp, inc, msg) {"," var obj = new Assertion(exp, msg);",""," if (Array.isArray(exp)) {"," obj.to.include(inc);"," } else if ('string' === typeof exp) {"," obj.to.contain.string(inc);"," }"," };",""," /**"," * # .match(value, regex, [message])"," *"," * Assert that `value` matches regular expression."," *"," * assert.match('foobar', /^foo/, 'Regexp matches');"," *"," * @name match"," * @param {*} value"," * @param {RegExp} RegularExpression"," * @param {String} message"," * @api public"," */",""," assert.match = function (exp, re, msg) {"," new Assertion(exp, msg).to.match(re);"," };",""," /**"," * # .length(value, constructor, [message])"," *"," * Assert that object has expected length."," *"," * assert.length([1,2,3], 3, 'Array has length of 3');"," * assert.length('foobar', 5, 'String has length of 6');"," *"," * @name length"," * @param {*} value"," * @param {Number} length"," * @param {String} message"," * @api public"," */",""," assert.length = function (exp, len, msg) {"," new Assertion(exp, msg).to.have.length(len);"," };",""," /**"," * # .throws(function, [constructor/regexp], [message])"," *"," * Assert that a function will throw a specific"," * type of error."," *"," * assert.throw(fn, ReferenceError, 'function throw reference error');"," *"," * @name throws"," * @alias throw"," * @param {Function} function to test"," * @param {ErrorConstructor} constructor"," * @param {String} message"," * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types"," * @api public"," */",""," assert.throws = function (fn, type, msg) {"," if ('string' === typeof type) {"," msg = type;"," type = null;"," }",""," new Assertion(fn, msg).to.throw(type);"," };",""," /**"," * # .doesNotThrow(function, [constructor/regexp], [message])"," *"," * Assert that a function will throw a specific"," * type of error."," *"," * var fn = function (err) { if (err) throw Error(err) };"," * assert.doesNotThrow(fn, Error, 'function throw reference error');"," *"," * @name doesNotThrow"," * @param {Function} function to test"," * @param {ErrorConstructor} constructor"," * @param {String} message"," * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types"," * @api public"," */",""," assert.doesNotThrow = function (fn, type, msg) {"," if ('string' === typeof type) {"," msg = type;"," type = null;"," }",""," new Assertion(fn, msg).to.not.throw(type);"," };",""," /*!"," * Undocumented / untested"," */",""," assert.ifError = function (val, msg) {"," new Assertion(val, msg).to.not.be.ok;"," };",""," /*!"," * Aliases."," */",""," (function alias(name, as){"," assert[as] = assert[name];"," return alias;"," })"," ('length', 'lengthOf')"," ('throws', 'throw');","};"]; | ||
_$jscoverage['interface/assert.js'].source = ["/*!"," * chai"," * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>"," * MIT Licensed"," */","","/**"," * ### TDD Style Introduction"," *"," * The TDD style is exposed through `assert` interfaces. This provides"," * the classic assert.`test` notation, similiar to that packaged with"," * node.js. This assert module, however, provides several additional"," * tests and is browser compatible."," *"," * // assert"," * var assert = require('chai').assert;"," * , foo = 'bar';"," *"," * assert.typeOf(foo, 'string');"," * assert.equal(foo, 'bar');"," *"," * #### Configuration"," *"," * By default, Chai does not show stack traces upon an AssertionError. This can"," * be changed by modifying the `includeStack` parameter for chai.Assertion. For example:"," *"," * var chai = require('chai');"," * chai.Assertion.includeStack = true; // defaults to false"," */","","module.exports = function (chai) {"," /*!"," * Chai dependencies."," */"," var Assertion = chai.Assertion"," , inspect = chai.inspect;",""," /*!"," * Module export."," */",""," var assert = chai.assert = {};",""," /**"," * # .ok(object, [message])"," *"," * Assert object is truthy."," *"," * assert.ok('everthing', 'everything is ok');"," * assert.ok(false, 'this will fail');"," *"," * @name ok"," * @param {*} object to test"," * @param {String} message"," * @api public"," */",""," assert.ok = function (val, msg) {"," new Assertion(val, msg).is.ok;"," };",""," /**"," * # .equal(actual, expected, [message])"," *"," * Assert strict equality."," *"," * assert.equal(3, 3, 'these numbers are equal');"," *"," * @name equal"," * @param {*} actual"," * @param {*} expected"," * @param {String} message"," * @api public"," */",""," assert.equal = function (act, exp, msg) {"," var test = new Assertion(act, msg);",""," test.assert("," exp == test.obj"," , 'expected ' + test.inspect + ' to equal ' + inspect(exp)"," , 'expected ' + test.inspect + ' to not equal ' + inspect(exp));"," };",""," /**"," * # .notEqual(actual, expected, [message])"," *"," * Assert not equal."," *"," * assert.notEqual(3, 4, 'these numbers are not equal');"," *"," * @name notEqual"," * @param {*} actual"," * @param {*} expected"," * @param {String} message"," * @api public"," */",""," assert.notEqual = function (act, exp, msg) {"," var test = new Assertion(act, msg);",""," test.assert("," exp != test.obj"," , 'expected ' + test.inspect + ' to equal ' + inspect(exp)"," , 'expected ' + test.inspect + ' to not equal ' + inspect(exp));"," };",""," /**"," * # .strictEqual(actual, expected, [message])"," *"," * Assert strict equality."," *"," * assert.strictEqual(true, true, 'these booleans are strictly equal');"," *"," * @name strictEqual"," * @param {*} actual"," * @param {*} expected"," * @param {String} message"," * @api public"," */",""," assert.strictEqual = function (act, exp, msg) {"," new Assertion(act, msg).to.equal(exp);"," };",""," /**"," * # .notStrictEqual(actual, expected, [message])"," *"," * Assert strict equality."," *"," * assert.notStrictEqual(1, true, 'these booleans are not strictly equal');"," *"," * @name notStrictEqual"," * @param {*} actual"," * @param {*} expected"," * @param {String} message"," * @api public"," */",""," assert.notStrictEqual = function (act, exp, msg) {"," new Assertion(act, msg).to.not.equal(exp);"," };",""," /**"," * # .deepEqual(actual, expected, [message])"," *"," * Assert not deep equality."," *"," * assert.deepEqual({ tea: 'green' }, { tea: 'green' });"," *"," * @name deepEqual"," * @param {*} actual"," * @param {*} expected"," * @param {String} message"," * @api public"," */",""," assert.deepEqual = function (act, exp, msg) {"," new Assertion(act, msg).to.eql(exp);"," };",""," /**"," * # .notDeepEqual(actual, expected, [message])"," *"," * Assert not deep equality."," *"," * assert.notDeepEqual({ tea: 'green' }, { tea: 'jasmine' });"," *"," * @name notDeepEqual"," * @param {*} actual"," * @param {*} expected"," * @param {String} message"," * @api public"," */",""," assert.notDeepEqual = function (act, exp, msg) {"," new Assertion(act, msg).to.not.eql(exp);"," };",""," /**"," * # .isTrue(value, [message])"," *"," * Assert `value` is true."," *"," * var tea_served = true;"," * assert.isTrue(tea_served, 'the tea has been served');"," *"," * @name isTrue"," * @param {Boolean} value"," * @param {String} message"," * @api public"," */",""," assert.isTrue = function (val, msg) {"," new Assertion(val, msg).is.true;"," };",""," /**"," * # .isFalse(value, [message])"," *"," * Assert `value` is false."," *"," * var tea_served = false;"," * assert.isFalse(tea_served, 'no tea yet? hmm...');"," *"," * @name isFalse"," * @param {Boolean} value"," * @param {String} message"," * @api public"," */",""," assert.isFalse = function (val, msg) {"," new Assertion(val, msg).is.false;"," };",""," /**"," * # .isNull(value, [message])"," *"," * Assert `value` is null."," *"," * assert.isNull(err, 'no errors');"," *"," * @name isNull"," * @param {*} value"," * @param {String} message"," * @api public"," */",""," assert.isNull = function (val, msg) {"," new Assertion(val, msg).to.equal(null);"," };",""," /**"," * # .isNotNull(value, [message])"," *"," * Assert `value` is not null."," *"," * var tea = 'tasty chai';"," * assert.isNotNull(tea, 'great, time for tea!');"," *"," * @name isNotNull"," * @param {*} value"," * @param {String} message"," * @api public"," */",""," assert.isNotNull = function (val, msg) {"," new Assertion(val, msg).to.not.equal(null);"," };",""," /**"," * # .isUndefined(value, [message])"," *"," * Assert `value` is undefined."," *"," * assert.isUndefined(tea, 'no tea defined');"," *"," * @name isUndefined"," * @param {*} value"," * @param {String} message"," * @api public"," */",""," assert.isUndefined = function (val, msg) {"," new Assertion(val, msg).to.equal(undefined);"," };",""," /**"," * # .isFunction(value, [message])"," *"," * Assert `value` is a function."," *"," * var serve_tea = function () { return 'cup of tea'; };"," * assert.isFunction(serve_tea, 'great, we can have tea now');"," *"," * @name isFunction"," * @param {Function} value"," * @param {String} message"," * @api public"," */",""," assert.isFunction = function (val, msg) {"," new Assertion(val, msg).to.be.a('function');"," };",""," /**"," * # .isObject(value, [message])"," *"," * Assert `value` is an object."," *"," * var selection = { name: 'Chai', serve: 'with spices' };"," * assert.isObject(selection, 'tea selection is an object');"," *"," * @name isObject"," * @param {Object} value"," * @param {String} message"," * @api public"," */",""," assert.isObject = function (val, msg) {"," new Assertion(val, msg).to.be.a('object');"," };",""," /**"," * # .isArray(value, [message])"," *"," * Assert `value` is an instance of Array."," *"," * var menu = [ 'green', 'chai', 'oolong' ];"," * assert.isArray(menu, 'what kind of tea do we want?');"," *"," * @name isArray"," * @param {*} value"," * @param {String} message"," * @api public"," */",""," assert.isArray = function (val, msg) {"," new Assertion(val, msg).to.be.instanceof(Array);"," };",""," /**"," * # .isString(value, [message])"," *"," * Assert `value` is a string."," *"," * var teaorder = 'chai';"," * assert.isString(tea_order, 'order placed');"," *"," * @name isString"," * @param {String} value"," * @param {String} message"," * @api public"," */",""," assert.isString = function (val, msg) {"," new Assertion(val, msg).to.be.a('string');"," };",""," /**"," * # .isNumber(value, [message])"," *"," * Assert `value` is a number"," *"," * var cups = 2;"," * assert.isNumber(cups, 'how many cups');"," *"," * @name isNumber"," * @param {Number} value"," * @param {String} message"," * @api public"," */",""," assert.isNumber = function (val, msg) {"," new Assertion(val, msg).to.be.a('number');"," };",""," /**"," * # .isBoolean(value, [message])"," *"," * Assert `value` is a boolean"," *"," * var teaready = true"," * , teaserved = false;"," *"," * assert.isBoolean(tea_ready, 'is the tea ready');"," * assert.isBoolean(tea_served, 'has tea been served');"," *"," * @name isBoolean"," * @param {*} value"," * @param {String} message"," * @api public"," */",""," assert.isBoolean = function (val, msg) {"," new Assertion(val, msg).to.be.a('boolean');"," };",""," /**"," * # .typeOf(value, name, [message])"," *"," * Assert typeof `value` is `name`."," *"," * assert.typeOf('tea', 'string', 'we have a string');"," *"," * @name typeOf"," * @param {*} value"," * @param {String} typeof name"," * @param {String} message"," * @api public"," */",""," assert.typeOf = function (val, type, msg) {"," new Assertion(val, msg).to.be.a(type);"," };",""," /**"," * # .instanceOf(object, constructor, [message])"," *"," * Assert `value` is instanceof `constructor`."," *"," * var Tea = function (name) { this.name = name; }"," * , Chai = new Tea('chai');"," *"," * assert.instanceOf(Chai, Tea, 'chai is an instance of tea');"," *"," * @name instanceOf"," * @param {Object} object"," * @param {Constructor} constructor"," * @param {String} message"," * @api public"," */",""," assert.instanceOf = function (val, type, msg) {"," new Assertion(val, msg).to.be.instanceof(type);"," };",""," /**"," * # .include(value, includes, [message])"," *"," * Assert the inclusion of an object in another. Works"," * for strings and arrays."," *"," * assert.include('foobar', 'bar', 'foobar contains string `var`);"," * assert.include([ 1, 2, 3], 3, 'array contains value);"," *"," * @name include"," * @param {Array|String} value"," * @param {*} includes"," * @param {String} message"," * @api public"," */",""," assert.include = function (exp, inc, msg) {"," var obj = new Assertion(exp, msg);",""," if (Array.isArray(exp)) {"," obj.to.include(inc);"," } else if ('string' === typeof exp) {"," obj.to.contain.string(inc);"," }"," };",""," /**"," * # .match(value, regex, [message])"," *"," * Assert that `value` matches regular expression."," *"," * assert.match('foobar', /^foo/, 'Regexp matches');"," *"," * @name match"," * @param {*} value"," * @param {RegExp} RegularExpression"," * @param {String} message"," * @api public"," */",""," assert.match = function (exp, re, msg) {"," new Assertion(exp, msg).to.match(re);"," };",""," /**"," * # .length(value, constructor, [message])"," *"," * Assert that object has expected length."," *"," * assert.length([1,2,3], 3, 'Array has length of 3');"," * assert.length('foobar', 5, 'String has length of 6');"," *"," * @name length"," * @param {*} value"," * @param {Number} length"," * @param {String} message"," * @api public"," */",""," assert.length = function (exp, len, msg) {"," new Assertion(exp, msg).to.have.length(len);"," };",""," /**"," * # .throws(function, [constructor/regexp], [message])"," *"," * Assert that a function will throw a specific"," * type of error."," *"," * assert.throw(fn, ReferenceError, 'function throw reference error');"," *"," * @name throws"," * @alias throw"," * @param {Function} function to test"," * @param {ErrorConstructor} constructor"," * @param {String} message"," * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types"," * @api public"," */",""," assert.throws = function (fn, type, msg) {"," if ('string' === typeof type) {"," msg = type;"," type = null;"," }",""," new Assertion(fn, msg).to.throw(type);"," };",""," /**"," * # .doesNotThrow(function, [constructor/regexp], [message])"," *"," * Assert that a function will throw a specific"," * type of error."," *"," * var fn = function (err) { if (err) throw Error(err) };"," * assert.doesNotThrow(fn, Error, 'function throw reference error');"," *"," * @name doesNotThrow"," * @param {Function} function to test"," * @param {ErrorConstructor} constructor"," * @param {String} message"," * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types"," * @api public"," */",""," assert.doesNotThrow = function (fn, type, msg) {"," if ('string' === typeof type) {"," msg = type;"," type = null;"," }",""," new Assertion(fn, msg).to.not.throw(type);"," };",""," /*!"," * Undocumented / untested"," */",""," assert.ifError = function (val, msg) {"," new Assertion(val, msg).to.not.be.ok;"," };",""," /*!"," * Aliases."," */",""," (function alias(name, as){"," assert[as] = assert[name];"," return alias;"," })"," ('length', 'lengthOf')"," ('throws', 'throw');","};"]; |
@@ -29,7 +29,7 @@ /*! | ||
* The `expect` interface provides a function as a starting point for chaining | ||
* your language assertions. It works on both node.js and in the browser. | ||
* your language assertions. It works on node.js and in all browsers. | ||
* | ||
* The `should` interface extends `Object.prototype` to provide a single getter as | ||
* the starting point for your language assertions. Most browser don't like | ||
* extensions to `Object.prototype` so it is not recommended for browser use. | ||
* the starting point for your language assertions. It works on node.js and in | ||
* all browsers except Internet Explorer. | ||
* | ||
@@ -296,3 +296,3 @@ * #### Configuration | ||
, 'expected ' + this.inspect + ' to be truthy' | ||
, 'expected ' + this.inspect + ' to be falsey'); | ||
, 'expected ' + this.inspect + ' to be falsy'); | ||
@@ -299,0 +299,0 @@ return this; |
@@ -10,3 +10,3 @@ /*! | ||
exports.version = '0.4.1'; | ||
exports.version = '0.4.2'; | ||
@@ -13,0 +13,0 @@ exports.Assertion = require('./assertion'); |
@@ -230,3 +230,3 @@ /*! | ||
assert.isNull = function (val, msg) { | ||
new Assertion(val, msg).to.not.exist; | ||
new Assertion(val, msg).to.equal(null); | ||
}; | ||
@@ -249,3 +249,3 @@ | ||
assert.isNotNull = function (val, msg) { | ||
new Assertion(val, msg).to.exist; | ||
new Assertion(val, msg).to.not.equal(null); | ||
}; | ||
@@ -357,3 +357,3 @@ | ||
assert.isNumber = function (val, msg) { | ||
new Assertion(val, msg).to.be.instanceof(Number); | ||
new Assertion(val, msg).to.be.a('number'); | ||
}; | ||
@@ -360,0 +360,0 @@ |
@@ -6,3 +6,3 @@ { | ||
"keywords": [ "test", "assertion", "assert", "testing" ], | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"repository": { | ||
@@ -9,0 +9,0 @@ "type": "git", |
@@ -117,2 +117,161 @@ | ||
test('notEqual', function() { | ||
assert.notEqual(3, 4); | ||
err(function () { | ||
assert.notEqual(5, 5); | ||
}, "expected 5 to equal 5"); | ||
}); | ||
test('strictEqual', function() { | ||
assert.strictEqual('foo', 'foo'); | ||
err(function () { | ||
assert.strictEqual('5', 5); | ||
}, "expected \'5\' to equal 5"); | ||
}); | ||
test('notStrictEqual', function() { | ||
assert.notStrictEqual(5, '5'); | ||
err(function () { | ||
assert.notStrictEqual(5, 5); | ||
}, "expected 5 to not equal 5"); | ||
}); | ||
test('deepEqual', function() { | ||
assert.deepEqual({tea: 'chai'}, {tea: 'chai'}); | ||
err(function () { | ||
assert.deepEqual({tea: 'chai'}, {tea: 'black'}); | ||
}, "expected { tea: \'chai\' } to equal { tea: \'black\' }"); | ||
}); | ||
test('notDeepEqual', function() { | ||
assert.notDeepEqual({tea: 'jasmine'}, {tea: 'chai'}); | ||
err(function () { | ||
assert.notDeepEqual({tea: 'chai'}, {tea: 'chai'}); | ||
}, "expected { tea: \'chai\' } to not equal { tea: \'chai\' }"); | ||
}); | ||
test('isNull', function() { | ||
assert.isNull(null); | ||
err(function () { | ||
assert.isNull(undefined); | ||
}, "expected undefined to equal null"); | ||
}); | ||
test('isNotNull', function() { | ||
assert.isNotNull(undefined); | ||
err(function () { | ||
assert.isNotNull(null); | ||
}, "expected null to not equal null"); | ||
}); | ||
test('isUndefined', function() { | ||
assert.isUndefined(undefined); | ||
err(function () { | ||
assert.isUndefined(null); | ||
}, "expected null to equal undefined"); | ||
}); | ||
test('isFunction', function() { | ||
var func = function() {}; | ||
assert.isFunction(func); | ||
err(function () { | ||
assert.isFunction({}); | ||
}, "expected {} to be a function"); | ||
}); | ||
test('isArray', function() { | ||
assert.isArray([]); | ||
assert.isArray(new Array); | ||
err(function () { | ||
assert.isArray({}); | ||
}, "expected {} to be an instance of Array"); | ||
}); | ||
test('isString', function() { | ||
assert.isString('Foo'); | ||
assert.isString(new String('foo')); | ||
err(function () { | ||
assert.isString(1); | ||
}, "expected 1 to be a string"); | ||
}); | ||
test('isNumber', function() { | ||
assert.isNumber(1); | ||
assert.isNumber(Number('3')); | ||
err(function () { | ||
assert.isNumber('1'); | ||
}, "expected \'1\' to be a number"); | ||
}); | ||
test('isBoolean', function() { | ||
assert.isBoolean(true); | ||
assert.isBoolean(false); | ||
err(function () { | ||
assert.isBoolean('1'); | ||
}, "expected \'1\' to be a boolean"); | ||
}); | ||
test('include', function() { | ||
assert.include('foobar', 'bar'); | ||
assert.include([ 1, 2, 3], 3); | ||
err(function () { | ||
assert.include('foobar', 'baz'); | ||
}, "expected \'foobar\' to contain \'baz\'"); | ||
}); | ||
test('length', function() { | ||
assert.length([1,2,3], 3); | ||
assert.length('foobar', 6); | ||
err(function () { | ||
assert.length('foobar', 5); | ||
}, "expected 'foobar' to have a length of 5 but got 6"); | ||
err(function () { | ||
assert.length(1, 5); | ||
}, "expected 1 to have a property \'length\'"); | ||
}); | ||
test('throws', function() { | ||
assert.throws(function() { throw new Error('foo'); }); | ||
assert.throws(function() { throw new Error('bar'); }, 'foo'); | ||
err(function () { | ||
assert.throws(function() {}); | ||
}, "expected [Function] to throw an error"); | ||
}); | ||
test('doesNotThrow', function() { | ||
assert.doesNotThrow(function() { }); | ||
assert.doesNotThrow(function() { }, 'foo'); | ||
err(function () { | ||
assert.doesNotThrow(function() { throw new Error('foo'); }); | ||
}, 'expected [Function] to not throw an error'); | ||
}); | ||
test('ifError', function() { | ||
assert.ifError(false); | ||
assert.ifError(null); | ||
assert.ifError(undefined); | ||
err(function () { | ||
assert.ifError('foo'); | ||
}, "expected \'foo\' to be falsy"); | ||
}); | ||
}); |
@@ -59,3 +59,3 @@ /*! | ||
expect('test').to.not.be.ok; | ||
}, "expected 'test' to be falsey"); | ||
}, "expected 'test' to be falsy"); | ||
}); | ||
@@ -62,0 +62,0 @@ |
@@ -73,3 +73,3 @@ /** | ||
'test'.should.not.be.ok; | ||
}, "expected 'test' to be falsey"); | ||
}, "expected 'test' to be falsy"); | ||
}); | ||
@@ -76,0 +76,0 @@ |
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
495878
6485
11