Permalink
Browse files

add .expect(status, body) support

  • Loading branch information...
1 parent 97ceeb3 commit 931b472983989dad84fd29e59b4671bc19cd482a @tj tj committed Jul 3, 2012
Showing with 26 additions and 0 deletions.
  1. +5 −0 History.md
  2. +6 −0 lib/test.js
  3. +15 −0 test/supertest.js
View
@@ -0,0 +1,5 @@
+
+0.1.0 / 2012-07-02
+==================
+
+ * add parsed body assertion support. Closes #1
View
@@ -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')
@@ -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
View
@@ -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();

0 comments on commit 931b472

Please sign in to comment.