tests: add more route tests
This commit is contained in:
parent
4279e6ef45
commit
21393c244c
@ -167,5 +167,24 @@ describe('Route', function(){
|
||||
|
||||
route.dispatch({ method: 'get' }, {});
|
||||
});
|
||||
|
||||
it('should handle throwing inside error handlers', function(done) {
|
||||
var route = new Route('');
|
||||
|
||||
route.get(function(req, res, next){
|
||||
throw new Error('boom!');
|
||||
});
|
||||
|
||||
route.get(function(err, req, res, next){
|
||||
throw new Error('oops');
|
||||
});
|
||||
|
||||
route.get(function(err, req, res, next){
|
||||
assert.equal(err.message, 'oops');
|
||||
done();
|
||||
});
|
||||
|
||||
route.dispatch({ url: '/', method: 'GET' }, {}, done);
|
||||
});
|
||||
})
|
||||
})
|
||||
|
@ -131,6 +131,25 @@ describe('Router', function(){
|
||||
|
||||
router.handle({ url: '/foo/2', method: 'GET' }, {}, done);
|
||||
});
|
||||
|
||||
it('should handle throwing inside error handlers', function(done) {
|
||||
var router = new Router();
|
||||
|
||||
router.use(function(req, res, next){
|
||||
throw new Error('boom!');
|
||||
});
|
||||
|
||||
router.use(function(err, req, res, next){
|
||||
throw new Error('oops');
|
||||
});
|
||||
|
||||
router.use(function(err, req, res, next){
|
||||
assert.equal(err.message, 'oops');
|
||||
done();
|
||||
});
|
||||
|
||||
router.handle({ url: '/', method: 'GET' }, {}, done);
|
||||
});
|
||||
})
|
||||
|
||||
describe('.all', function() {
|
||||
|
@ -49,4 +49,14 @@ describe('app.route', function(){
|
||||
.get('/test')
|
||||
.expect('test', done);
|
||||
});
|
||||
|
||||
it('should not error on empty routes', function(done){
|
||||
var app = express();
|
||||
|
||||
app.route('/:foo');
|
||||
|
||||
request(app)
|
||||
.get('/test')
|
||||
.expect(404, done);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user