Files
hudozka/node_modules/should/lib/ext/http.js
T
2014-02-12 12:36:59 +04:00

33 lines
928 B
JavaScript

/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
//var statusCodes = require('http').STATUS_CODES;
module.exports = function(should, Assertion) {
Assertion.add('header', function(field, val) {
this
.have.property('headers')
.and.have.property(field.toLowerCase(), val);
});
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]) }
this.have.property('statusCode', code);
});
Assertion.add('json', function() {
this.have.property('headers')
.and.have.property('content-type').include('application/json');
}, true);
Assertion.add('html', function() {
this.have.property('headers')
.and.have.property('content-type').include('text/html');
}, true);
};