Skip to content

Commit 289c43a

Browse files
committed
Adjusts test that relied upon the happenstance of the usage: res.send(statusCode, body) without recognizing that the order of those arguments is sometimes flipped.
1 parent 68b229f commit 289c43a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

test/hooks/request/req.options.usage.test.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,20 @@ describe('Request hook', function (){
4545
foo: 'nasty string'
4646
}
4747
}, {
48-
send: function (statusCode, body) {
49-
if (statusCode === 400) done();
50-
else done(new Error('Incorrect status code sent: '+statusCode+ '\nFull response body:'+body));
48+
send: function (_statusCode, body) {
49+
var statusCode;
50+
51+
// Determine order of arguments in this usage
52+
if ( +statusCode <999 && +statusCode > -1 ) {
53+
statusCode = _statusCode;
54+
}
55+
else {
56+
statusCode = body;
57+
body = _statusCode;
58+
}
59+
60+
if (statusCode === 400) return done();
61+
return done(new Error('Incorrect status code sent: '+statusCode+ '\nFull response body:'+body));
5162
}
5263
});
5364
});

0 commit comments

Comments
 (0)