should-http
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -1,4 +0,9 @@ | ||
0.0.1 / 2014-05-29 | ||
0.0.3 / 2015-05-21 | ||
================== | ||
* .status will show only body and statusCode | ||
0.0.2 / 2014-05-29 | ||
================== | ||
* Fix for current should.js version | ||
@@ -5,0 +10,0 @@ |
53
http.js
@@ -10,2 +10,15 @@ /*! | ||
/** | ||
* Asserts given object has property headers which contain `field` and optional `val`. Will work well with node Request/Response etc. | ||
* | ||
* @name header | ||
* @memberOf Assertion | ||
* @category assertion http | ||
* @module should-http | ||
* @param {string} field Name of field | ||
* @param {string} [val] Optional value of field | ||
* @example | ||
* | ||
* res.should.have.header('content-type', 'application/json'); | ||
*/ | ||
Assertion.add('header', function(field, val) { | ||
@@ -21,9 +34,32 @@ this.have.property('headers'); | ||
/** | ||
* Asserts given object has property statusCode which equal to `code`. Works well with node's Response. | ||
* | ||
* @name status | ||
* @memberOf Assertion | ||
* @category assertion http | ||
* @module should-http | ||
* @param {number} code Status code value | ||
* @example | ||
* | ||
* res.should.have.status(200); | ||
*/ | ||
Assertion.add('status', function(code) { | ||
//this.params = { operator: 'to have response code ' + code + ' ' + i(statusCodes[code]) | ||
// + ', but got ' + this.obj.statusCode + ' ' + i(statusCodes[this.obj.statusCode]) } | ||
var obj = this.obj; | ||
var copy = { body: obj.body, statusCode: obj.statusCode }; | ||
this.have.property('statusCode', code); | ||
copy.should.have.property('statusCode', code); | ||
}); | ||
/** | ||
* Shortcut for .should.header('content-type', 'application/json') | ||
* | ||
* @name json | ||
* @memberOf Assertion | ||
* @category assertion http | ||
* @module should-http | ||
* @example | ||
* | ||
* res.should.be.json; | ||
*/ | ||
Assertion.add('json', function() { | ||
@@ -33,2 +69,13 @@ this.have.header('content-type').match(/application\/json/i); | ||
/** | ||
* Shortcut for .should.header('content-type', 'text/html') | ||
* | ||
* @name html | ||
* @memberOf Assertion | ||
* @category assertion http | ||
* @module should-http | ||
* @example | ||
* | ||
* res.should.be.json; | ||
*/ | ||
Assertion.add('html', function() { | ||
@@ -35,0 +82,0 @@ this.have.header('content-type').match(/text\/html/i); |
{ | ||
"name": "should-http", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Http requests, response assertions for should.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6991
138