Skip to content
Myr

Added test for `app.param(fn)`

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

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent ca0d29d · Browse files · 1 file+28 added−0 removed
This commit

State

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

Diff stats

1 file+28 added−0 removed

  • tests:+28 added−0 removed

1 file+28 added−0 removed

modified:test/router.test.js+28 added
72 unmodified lines
73 calls.should.equal(3);74 });75 },7677 'test app.param(fn)': function(){78 var app = express.createServer();79 80 app.param(function(name, fn){81 if (fn instanceof RegExp) {82 return function(req, res, next, val){83 var captures;84 if (captures = fn.exec(String(val))) {85 req.params[name] = captures[1];86 next();87 } else {88 next('route');89 }90 }91 }92 });9394 app.param('commit', /^(\d+)$/);9596 app.get('/commit/:commit', function(req, res){97 res.send(req.params.commit);98 });99100 assert.response(app,101 { url: '/commit/12' },102 { body: '12' });103 },104105 'test precedence': function(){106 var app = express.createServer();107 108 var hits = [];
383 unmodified lines