Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions bin/expresso
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ assert.response = function(server, req, res, msg){
response.on('end', function(){
if (timer) clearTimeout(timer);

// Shut down the server
check();

// Assert response body
if (res.body !== undefined) {
var eql = res.body instanceof RegExp
Expand Down Expand Up @@ -475,10 +478,9 @@ assert.response = function(server, req, res, msg){
);
}
}

// Callback
callback(response);
check();
});
});
request.end();
Expand Down
20 changes: 20 additions & 0 deletions test/http.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,26 @@ module.exports = {
})
},

'test assert.response(req, res, fn) with POSTed body': function(beforeExit){
var calls = 0;

assert.response(server, {
url: '/echo',
method: 'POST',
body: 'Hello, Expresso!'
},{
body: '/echo Hello, Expresso!',
status: 200
}, function(res){
++calls;
assert.ok(res);
});

beforeExit(function(){
assert.equal(1, calls);
})
},

'test assert.response(req, fn)': function(beforeExit){
var calls = 0;

Expand Down