Skip to content

Commit

Permalink
add .expect(status, body) support
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jul 3, 2012
1 parent 97ceeb3 commit 931b472
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions History.md
@@ -0,0 +1,5 @@

0.1.0 / 2012-07-02
==================

* add parsed body assertion support. Closes #1
6 changes: 6 additions & 0 deletions lib/test.js
Expand Up @@ -54,6 +54,7 @@ Test.prototype.__proto__ = Request.prototype;
*
* .expect(200)
* .expect(200, fn)
* .expect(200, body)
* .expect('Some body')
* .expect('Some body', fn)
* .expect('Content-Type', 'application/json')
Expand All @@ -69,6 +70,11 @@ Test.prototype.expect = function(val, fn){
// status
if ('number' == typeof val) {
this._status = val;
// body
if (fn && 'function' != typeof fn) {
this._body = fn;
return this;
}
}

// callback
Expand Down
15 changes: 15 additions & 0 deletions test/supertest.js
Expand Up @@ -82,6 +82,21 @@ describe('request(app)', function(){
})
})

describe('.expect(status, body[, fn])', function(){
it('should assert the response body and status', function(done){
var app = express();

app.get('/', function(req, res){
res.send('foo');
});

request(app)
.get('/')
.expect(200, 'foo')
.end(done);
})
})

describe('.expect(body[, fn])', function(){
it('should assert the response body', function(done){
var app = express();
Expand Down

0 comments on commit 931b472

Please sign in to comment.