Skip to content

Commit

Permalink
added failing test for #682
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed May 26, 2011
1 parent d1bfe13 commit 1ce43dd
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion test/router.test.js
Expand Up @@ -138,7 +138,7 @@ module.exports = {
{ body: 'Cannot GET /user/ab' });
},

'test .param()': function(){
'test app.param()': function(){
var app = express.createServer();

var users = [
Expand Down Expand Up @@ -169,6 +169,35 @@ module.exports = {
{ url: '/user/1' },
{ body: 'user tobi' });
},

'test app.param() optional execution': function(beforeExit){
var app = express.createServer()
, calls = 0;

var months = ['Jan', 'Feb', 'Mar'];

app.param('month', function(req, res, next, n){
req.params.month = months[n];
++calls;
next();
});

app.get('/calendar/:month?', function(req, res, next){
res.send(req.params.month || months[0]);
});

assert.response(app,
{ url: '/calendar' },
{ body: 'Jan' });

assert.response(app,
{ url: '/calendar/1' },
{ body: 'Feb' });

beforeExit(function(){
calls.should.equal(1);
});
},

'test OPTIONS': function(){
var app = express.createServer();
Expand Down

0 comments on commit 1ce43dd

Please sign in to comment.