Permalink
Browse files

refactor routes.error tests

  • Loading branch information...
1 parent 78d5b72 commit 0dd80e7b502abb75515deffb1f37188c055cdc88 @tj tj committed Oct 10, 2012
Showing with 17 additions and 11 deletions.
  1. +17 −11 test/app.routes.error.js
View
@@ -6,27 +6,33 @@ describe('app', function(){
it('should only call an error handling routing callback when an error is propagated', function(done){
var app = express();
+ var a = false;
+ var b = false;
+ var c = false;
+ var d = false;
+
app.get('/', function(req, res, next){
- req.thruSecondCallback = false;
- req.thruThirdCallback = false;
- req.thruFourthCallback = false;
next(new Error('fabricated error'));
}, function(req, res, next) {
- req.thruSecondCallback = true;
+ a = true;
next();
}, function(err, req, res, next){
+ b = true;
+ err.message.should.equal('fabricated error');
+ next(err);
+ }, function(err, req, res, next){
+ c = true;
err.message.should.equal('fabricated error');
- req.thruThirdCallback = true;
next();
}, function(err, req, res, next){
- req.thruFourthCallback = true;
+ d = true;
next();
}, function(req, res){
- req.thruSecondCallback.should.equal(false);
- req.thruThirdCallback.should.equal(true);
- req.thruFourthCallback.should.equal(false);
- res.status(204);
- res.end();
+ a.should.be.false;
+ b.should.be.true;
+ c.should.be.true;
+ d.should.be.false;
+ res.send(204);
});
request(app)

0 comments on commit 0dd80e7

Please sign in to comment.