Kill test server before checking assertions. #96

Open
wants to merge 3 commits into
from
View
@@ -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
@@ -475,10 +478,9 @@ assert.response = function(server, req, res, msg){
);
}
}
-
+
// Callback
callback(response);
- check();
});
});
request.end();
View
@@ -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;