Permalink
Browse files

.expect(status) should assert only status

  • Loading branch information...
1 parent 8672459 commit 758db358efefd0cbded26e7ef1dfe5ffb0074294 @eldargab eldargab committed Dec 2, 2012
Showing with 17 additions and 2 deletions.
  1. +2 −2 lib/test.js
  2. +15 −0 test/supertest.js
View
@@ -93,7 +93,7 @@ Test.prototype.expect = function(a, b, c){
if ('number' == typeof a) {
this._status = a;
// body
- if ('function' != typeof b) this._bodies.push(b);
+ if ('function' != typeof b && arguments.length > 1) this._bodies.push(b);
return this;
}
@@ -148,7 +148,7 @@ Test.prototype.assert = function(res, fn){
var b = http.STATUS_CODES[res.status];
return fn(new Error('expected ' + status + ' "' + a + '", got ' + res.status + ' "' + b + '"'), res);
}
-
+
// body
for (var i = 0; i < bodies.length; i++) {
var body = bodies[i];
View
@@ -137,6 +137,21 @@ describe('request(app)', function(){
})
})
+ describe('.expect(status)', function () {
+ it('should assert only status', function (done) {
+ var app = express();
+
+ app.get('/', function (req, res) {
+ res.send('hey');
+ })
+
+ request(app)
+ .get('/')
+ .expect(200)
+ .end(done)
+ })
+ })
+
describe('.expect(status, body[, fn])', function(){
it('should assert the response body and status', function(done){
var app = express();

0 comments on commit 758db35

Please sign in to comment.