Added param passing specs
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parent 5e46da1 · Browse files · 1 file·+39 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+39 added−0 removed
- tests:+39 added−0 removed
Provenance
- Commit
af0493b- Tree
2d89f3d- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent
5e46da1
1 file changed+39 added−0 removed
modified:spec/spec.routing.js+39 added
101 unmodified linesExpand all1021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451463 unmodified lines1501511521531541551561571581591601611621631641651661671681691701711721731745 unmodified lines101 unmodified linesExpand all it 'should not match with an additional path segment' get('/user/:id', function(){ return 'yay' }) get('/user/12/edit').body.should.eql 'Not Found' end it 'should pass it to the route function' get('/user/:id', function(id){ return id }) get('/user/12').body.should.eql '12' end end describe 'with several placeholders' it 'should still match' get('/user/:id/:op', function(){ return 'yay' }) get('/user/12/edit').body.should.eql 'yay' end it 'should pass them to the route function' get('/user/:id/:op', function(id, op){ return op + 'ing user ' + id }) get('/user/12/edit').body.should.eql 'editing user 12' end end describe 'with an optional placeholder' it 'should match with a value' get('/user/:id?', function(){ return 'yay' }) get('/user/1').body.should.eql 'yay' end it 'should pass it to the route function' get('/user/:id?', function(id){ return id || 'You' }) get('/user/12').body.should.eql '12' get('/user').body.should.eql 'You' end it 'should match without a value' get('/user/:id?', function(){ return 'yay' }) get('/user').body.should.eql 'yay' end3 unmodified lines get('/user/12/edit').body.should.eql 'Not Found' end end describe 'with partial placeholder' it 'should still match' get('/report.:format', function(){ return 'yay' }) get('/report.csv').body.should.eql 'yay' get('/report.pdf').body.should.eql 'yay' end it 'should not match without value' get('/report.:format', function(){ return 'yay' }) get('/report.').body.should.eql 'Not Found' end end describe 'with an unmatchable request path' it 'should respond with 404 Not Found' get('/something').status.should.eql 404 get('/something').body.should.eql 'Not Found'5 unmodified lines