Comparing version 0.2.4 to 0.3.0
162
chai.js
@@ -95,4 +95,3 @@ !function (name, definition) { | ||
, eql = require('./utils/eql') | ||
, inspect = require('./utils/inspect') | ||
, statusCodes = require('./utils/constants').STATUS_CODES; | ||
, inspect = require('./utils/inspect'); | ||
@@ -846,3 +845,3 @@ /*! | ||
} catch (err) { | ||
if (constructor) { | ||
if (constructor && 'function' === typeof constructor) { | ||
this.assert( | ||
@@ -852,4 +851,9 @@ err instanceof constructor && err.name == constructor.name | ||
, '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 ' + inspect(constructor) + ' but got ' + inspect(err.message) | ||
, 'expected ' + this.inspect + ' to throw error not matching ' + inspect(constructor) ); | ||
return this; | ||
} else { | ||
@@ -870,76 +874,2 @@ thrown = true; | ||
/** | ||
* # .header(code) | ||
* | ||
* Assert `header` field has expected `value`. | ||
* | ||
* @name header | ||
* @param {String} field | ||
* @param {String} value | ||
* @api public | ||
*/ | ||
Assertion.prototype.header = function (field, val) { | ||
new Assertion(this.obj) | ||
.to.have.property('headers').and | ||
.to.have.property(field.toLowerCase(), val); | ||
return this; | ||
} | ||
/** | ||
* # .status(code) | ||
* | ||
* Assert `statusCode` of `code'. | ||
* | ||
* @name status | ||
* @param {Number} code | ||
* @api public | ||
*/ | ||
Assertion.prototype.status = function (code) { | ||
new Assertion(this.obj).to.have.property('statusCode'); | ||
var status = this.obj.statusCode; | ||
this.assert( | ||
code == status | ||
, 'expected response code of ' + code + ' ' + inspect(statusCodes[code]) | ||
+ ', but got ' + status + ' ' + inspect(statusCodes[status]) | ||
, 'expected to not respond with ' + code + ' ' + inspect(statusCodes[code])); | ||
} | ||
/** | ||
* # json | ||
* | ||
* Assert that this response has content-type: application/json. | ||
* | ||
* @name json | ||
* @api public | ||
*/ | ||
Object.defineProperty(Assertion.prototype, 'json', | ||
{ get: function () { | ||
new Assertion(this.obj).to.have.header('content-type', 'application/json; charset=utf-8'); | ||
return this; | ||
} | ||
}); | ||
/** | ||
* # html | ||
* | ||
* Assert that this response has content-type: text/html. | ||
* | ||
* @name html | ||
* @api public | ||
*/ | ||
Object.defineProperty(Assertion.prototype, 'html', | ||
{ get: function () { | ||
new Assertion(this.obj).to.have.header('content-type', 'text/html; charset=utf-8'); | ||
return this; | ||
} | ||
}); | ||
/*! | ||
@@ -967,9 +897,10 @@ * Aliases. | ||
* chai | ||
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com> | ||
* Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com> | ||
* MIT Licensed | ||
*/ | ||
var used = []; | ||
var exports = module.exports = {}; | ||
exports.version = '0.2.4'; | ||
exports.version = '0.3.0'; | ||
@@ -982,3 +913,7 @@ exports.Assertion = require('./assertion'); | ||
exports.use = function (fn) { | ||
fn(this); | ||
if (!~used.indexOf(fn)) { | ||
fn(this); | ||
used.push(fn); | ||
} | ||
return this; | ||
@@ -1684,67 +1619,2 @@ }; | ||
require.register("utils/constants.js", function(module, exports, require){ | ||
var exports = module.exports = {}; | ||
/** | ||
* More includes from node.js code | ||
* https://github.com/joyent/node/blob/master/lib/http.js | ||
*/ | ||
exports.STATUS_CODES = { | ||
100 : 'Continue', | ||
101 : 'Switching Protocols', | ||
102 : 'Processing', // RFC 2518, obsoleted by RFC 4918 | ||
200 : 'OK', | ||
201 : 'Created', | ||
202 : 'Accepted', | ||
203 : 'Non-Authoritative Information', | ||
204 : 'No Content', | ||
205 : 'Reset Content', | ||
206 : 'Partial Content', | ||
207 : 'Multi-Status', // RFC 4918 | ||
300 : 'Multiple Choices', | ||
301 : 'Moved Permanently', | ||
302 : 'Moved Temporarily', | ||
303 : 'See Other', | ||
304 : 'Not Modified', | ||
305 : 'Use Proxy', | ||
307 : 'Temporary Redirect', | ||
400 : 'Bad Request', | ||
401 : 'Unauthorized', | ||
402 : 'Payment Required', | ||
403 : 'Forbidden', | ||
404 : 'Not Found', | ||
405 : 'Method Not Allowed', | ||
406 : 'Not Acceptable', | ||
407 : 'Proxy Authentication Required', | ||
408 : 'Request Time-out', | ||
409 : 'Conflict', | ||
410 : 'Gone', | ||
411 : 'Length Required', | ||
412 : 'Precondition Failed', | ||
413 : 'Request Entity Too Large', | ||
414 : 'Request-URI Too Large', | ||
415 : 'Unsupported Media Type', | ||
416 : 'Requested Range Not Satisfiable', | ||
417 : 'Expectation Failed', | ||
418 : 'I\'m a teapot', // RFC 2324 | ||
422 : 'Unprocessable Entity', // RFC 4918 | ||
423 : 'Locked', // RFC 4918 | ||
424 : 'Failed Dependency', // RFC 4918 | ||
425 : 'Unordered Collection', // RFC 4918 | ||
426 : 'Upgrade Required', // RFC 2817 | ||
500 : 'Internal Server Error', | ||
501 : 'Not Implemented', | ||
502 : 'Bad Gateway', | ||
503 : 'Service Unavailable', | ||
504 : 'Gateway Time-out', | ||
505 : 'HTTP Version not supported', | ||
506 : 'Variant Also Negotiates', // RFC 2295 | ||
507 : 'Insufficient Storage', // RFC 4918 | ||
509 : 'Bandwidth Limit Exceeded', | ||
510 : 'Not Extended' // RFC 2774 | ||
}; | ||
}); // module: utils/constants.js | ||
require.register("utils/eql.js", function(module, exports, require){ | ||
@@ -1751,0 +1621,0 @@ // This is directly from Node.js assert |
0.3.0 / 2012-02-07 | ||
================== | ||
* Merge branch 'feature/03x' | ||
* browser build | ||
* remove html/json/headers testign | ||
* regex error.message testing | ||
* tests for using plugins | ||
* Merge pull request #11 from domenic/master | ||
* Make `chai.use` a no-op if the function has already been used. | ||
0.2.4 / 2012-02-02 | ||
@@ -3,0 +14,0 @@ ================== |
@@ -42,4 +42,3 @@ /*! | ||
, eql = require('./utils/eql') | ||
, inspect = require('./utils/inspect') | ||
, statusCodes = require('./utils/constants').STATUS_CODES; | ||
, inspect = require('./utils/inspect'); | ||
@@ -793,3 +792,3 @@ /*! | ||
} catch (err) { | ||
if (constructor) { | ||
if (constructor && 'function' === typeof constructor) { | ||
this.assert( | ||
@@ -799,4 +798,9 @@ err instanceof constructor && err.name == constructor.name | ||
, '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 ' + inspect(constructor) + ' but got ' + inspect(err.message) | ||
, 'expected ' + this.inspect + ' to throw error not matching ' + inspect(constructor) ); | ||
return this; | ||
} else { | ||
@@ -817,76 +821,2 @@ thrown = true; | ||
/** | ||
* # .header(code) | ||
* | ||
* Assert `header` field has expected `value`. | ||
* | ||
* @name header | ||
* @param {String} field | ||
* @param {String} value | ||
* @api public | ||
*/ | ||
Assertion.prototype.header = function (field, val) { | ||
new Assertion(this.obj) | ||
.to.have.property('headers').and | ||
.to.have.property(field.toLowerCase(), val); | ||
return this; | ||
} | ||
/** | ||
* # .status(code) | ||
* | ||
* Assert `statusCode` of `code'. | ||
* | ||
* @name status | ||
* @param {Number} code | ||
* @api public | ||
*/ | ||
Assertion.prototype.status = function (code) { | ||
new Assertion(this.obj).to.have.property('statusCode'); | ||
var status = this.obj.statusCode; | ||
this.assert( | ||
code == status | ||
, 'expected response code of ' + code + ' ' + inspect(statusCodes[code]) | ||
+ ', but got ' + status + ' ' + inspect(statusCodes[status]) | ||
, 'expected to not respond with ' + code + ' ' + inspect(statusCodes[code])); | ||
} | ||
/** | ||
* # json | ||
* | ||
* Assert that this response has content-type: application/json. | ||
* | ||
* @name json | ||
* @api public | ||
*/ | ||
Object.defineProperty(Assertion.prototype, 'json', | ||
{ get: function () { | ||
new Assertion(this.obj).to.have.header('content-type', 'application/json; charset=utf-8'); | ||
return this; | ||
} | ||
}); | ||
/** | ||
* # html | ||
* | ||
* Assert that this response has content-type: text/html. | ||
* | ||
* @name html | ||
* @api public | ||
*/ | ||
Object.defineProperty(Assertion.prototype, 'html', | ||
{ get: function () { | ||
new Assertion(this.obj).to.have.header('content-type', 'text/html; charset=utf-8'); | ||
return this; | ||
} | ||
}); | ||
/*! | ||
@@ -893,0 +823,0 @@ * Aliases. |
/*! | ||
* chai | ||
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com> | ||
* Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com> | ||
* MIT Licensed | ||
*/ | ||
var used = []; | ||
var exports = module.exports = {}; | ||
exports.version = '0.2.4'; | ||
exports.version = '0.3.0'; | ||
@@ -17,3 +18,7 @@ exports.Assertion = require('./assertion'); | ||
exports.use = function (fn) { | ||
fn(this); | ||
if (!~used.indexOf(fn)) { | ||
fn(this); | ||
used.push(fn); | ||
} | ||
return this; | ||
@@ -20,0 +25,0 @@ }; |
@@ -6,3 +6,3 @@ { | ||
"keywords": [ "test", "assertion", "assert", "testing" ], | ||
"version": "0.2.4", | ||
"version": "0.3.0", | ||
"repository": { | ||
@@ -9,0 +9,0 @@ "type": "git", |
@@ -390,2 +390,5 @@ /*! | ||
expect(badFn).to.throw(/testing/); | ||
expect(badFn).to.not.throw(/hello/); | ||
err(function(){ | ||
@@ -418,4 +421,12 @@ expect(goodFn).to.throw(); | ||
}, "expected [Function] to throw Error but a ReferenceError was thrown"); | ||
err(function (){ | ||
expect(badFn).to.not.throw(/testing/); | ||
}, "expected [Function] to throw error not matching /testing/"); | ||
err(function () { | ||
expect(badFn).to.throw(/hello/); | ||
}, "expected [Function] to throw error matching /hello/ but got \'testing\'"); | ||
}); | ||
}); |
@@ -378,2 +378,5 @@ /** | ||
(badFn).should.throw(/testing/); | ||
(badFn).should.not.throw(/hello/); | ||
should.throw(badFn); | ||
@@ -411,3 +414,11 @@ should.throw(refErrFn, ReferenceError); | ||
}, "expected [Function] to throw Error but a ReferenceError was thrown"); | ||
err(function (){ | ||
(badFn).should.not.throw(/testing/); | ||
}, "expected [Function] to throw error not matching /testing/"); | ||
err(function () { | ||
(badFn).should.throw(/hello/); | ||
}, "expected [Function] to throw error matching /hello/ but got \'testing\'"); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
126558
24
4216