Permalink
Browse files

Merge pull request #40 from eldargab/fix

.expect(status) should assert only status
  • Loading branch information...
2 parents 8672459 + 758db35 commit 490d246f40bea0763a23ba218c1fea7905e4f7b1 @tj tj committed Dec 7, 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 490d246

Please sign in to comment.