/
http.js
33 lines (26 loc) · 928 Bytes
/
http.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*!
* 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);
};