Skip to content
Myr

tests: add more various tests

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent e660f19 · Browse files · 3 files+61 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+61 added−2 removed

  • tests:+61 added−2 removed

3 files+61 added−2 removed

modified:test/app.js+10 added-1 removed
modified:test/app.param.js+43 added
35 unmodified lines
36 .expect(404, done);37 });3839 })4041 it('should fail if not given fn', function(){42 var app = express();43 app.param.bind(app, ':name', 'bob').should.throw();44 })45 })4647 describe('.param(names, fn)', function(){48 it('should map the array', function(done){
50 unmodified lines
99 request(app)100 .get('/user/123')101 .expect('123', done);102 })103104 it('should catch thrown error', function(done){105 var app = express();106107 app.param('id', function(req, res, next, id){108 throw new Error('err!');109 });110111 app.get('/user/:id', function(req, res){112 var id = req.params.id;113 res.send('' + id);114 });115116 request(app)117 .get('/user/123')118 .expect(500, done);119 })120121 it('should defer to next route', function(done){122 var app = express();123124 app.param('id', function(req, res, next, id){125 next('route');126 });127128 app.get('/user/:id', function(req, res){129 var id = req.params.id;130 res.send('' + id);131 });132133 app.get('/:name/123', function(req, res){134 res.send('name');135 });136137 request(app)138 .get('/user/123')139 .expect('name', done);140 })141 })142})
modified:test/req.range.js+8 added-1 removed