mirror of
https://github.com/expressjs/express.git
synced 2026-03-13 08:13:05 +08:00
refactor routes.error tests
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user