Skip to content

Commit c3470c9

Browse files
committed
tests: add route ordering test
1 parent 7f04916 commit c3470c9

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/app.router.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,45 @@ describe('app.router', function(){
588588
.expect('editing user 12', done);
589589
})
590590

591+
it('should run in order added', function(done){
592+
var app = express();
593+
var path = [];
594+
595+
app.get('*', function(req, res, next){
596+
path.push(0);
597+
next();
598+
});
599+
600+
app.get('/user/:id', function(req, res, next){
601+
path.push(1);
602+
next();
603+
});
604+
605+
app.use(function(req, res, next){
606+
path.push(2);
607+
next();
608+
});
609+
610+
app.all('/user/:id', function(req, res, next){
611+
path.push(3);
612+
next();
613+
});
614+
615+
app.get('*', function(req, res, next){
616+
path.push(4);
617+
next();
618+
});
619+
620+
app.use(function(req, res, next){
621+
path.push(5);
622+
res.end(path.join(','))
623+
});
624+
625+
request(app)
626+
.get('/user/1')
627+
.expect(200, '0,1,2,3,4,5', done);
628+
})
629+
591630
it('should be chainable', function(){
592631
var app = express();
593632
app.get('/', function(){}).should.equal(app);

0 commit comments

Comments
 (0)