Skip to content

Commit 295fb52

Browse files
authored
Merge pull request #123 from atom-morgan/response-status-code-property
Issue 104: Update status assertion to also check for 'statusCode' property
2 parents 1b2d578 + 4998de7 commit 295fb52

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/http.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ module.exports = function (chai, _) {
7777
*/
7878

7979
Assertion.addMethod('status', function (code) {
80-
new Assertion(this._obj).to.have.property('status');
81-
var status = this._obj.status;
80+
new Assertion(this._obj).to.have.any.keys('status', 'statusCode');
81+
var status = this._obj.status || this._obj.statusCode;
8282

8383
this.assert(
8484
status == code

test/http.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
describe('assertions', function () {
22

3-
it('#status', function () {
3+
it('#status property "status"', function () {
44
var res = { status: 200 };
55
res.should.to.have.status(200);
66

@@ -10,7 +10,12 @@ describe('assertions', function () {
1010

1111
(function () {
1212
({}).should.not.to.have.status(200);
13-
}).should.throw("expected {} to have a property 'status'");
13+
}).should.throw("expected {} to have keys 'status', or 'statusCode'");
14+
});
15+
16+
it('#status property "statusCode"', function () {
17+
var res = { statusCode: 200 };
18+
res.should.to.have.status(200);
1419
});
1520

1621
it('#ip', function () {

0 commit comments

Comments
 (0)