Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #20 from elliotf/allow_empty_body_assertion

Allow for assertions that the body is empty when asserting on the respon...
  • Loading branch information...
commit 3dfae51ced89af0c37ab483e7b53301782716fba 2 parents 85982a6 + 8e18872
@tj tj authored
Showing with 21 additions and 3 deletions.
  1. +1 −1  lib/test.js
  2. +20 −2 test/supertest.js
View
2  lib/test.js
@@ -74,7 +74,7 @@ Test.prototype.expect = function(a, b, c){
if ('number' == typeof a) {
this._status = a;
// body
- if (b && 'function' != typeof b) this._body = b;
+ if ('function' != typeof b) this._body = b;
return this;
}
View
22 test/supertest.js
@@ -93,7 +93,25 @@ describe('request(app)', function(){
request(app)
.get('/')
.expect(200, 'foo', done)
- })
+ });
+
+ describe("when the body argument is an empty string", function() {
+ it("should not quietly pass on failure", function(done) {
+ var app = express();
+
+ app.get('/', function(req, res){
+ res.send('foo');
+ });
+
+ request(app)
+ .get('/')
+ .expect(200, '')
+ .end(function(err, res){
+ err.message.should.equal('expected \'\' response body, got \'foo\'');
+ done();
+ });
+ });
+ });
})
describe('.expect(body[, fn])', function(){
@@ -231,4 +249,4 @@ describe('request(app)', function(){
});
})
})
-})
+})
Please sign in to comment.
Something went wrong with that request. Please try again.