mirror of
https://github.com/zebrajr/express.git
synced 2026-01-15 12:15:27 +00:00
param single-segment test
This commit is contained in:
@@ -128,7 +128,7 @@ describe('app.router', function(){
|
||||
|
||||
request(app)
|
||||
.get('/user')
|
||||
.expect('Cannot GET /user', done);
|
||||
.expect(404, done);
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -186,7 +186,7 @@ describe('app.router', function(){
|
||||
|
||||
request(app)
|
||||
.get('/user')
|
||||
.expect('Cannot GET /user', done);
|
||||
.expect(404, done);
|
||||
})
|
||||
|
||||
it('should fail when adding the trailing slash', function(done){
|
||||
@@ -200,7 +200,7 @@ describe('app.router', function(){
|
||||
|
||||
request(app)
|
||||
.get('/user/')
|
||||
.expect('Cannot GET /user/', done);
|
||||
.expect(404, done);
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -218,6 +218,18 @@ describe('app.router', function(){
|
||||
.expect('tj', done);
|
||||
})
|
||||
|
||||
it('should match a single segment only', function(done){
|
||||
var app = express();
|
||||
|
||||
app.get('/user/:user', function(req, res){
|
||||
res.end(req.params.user);
|
||||
});
|
||||
|
||||
request(app)
|
||||
.get('/user/tj/edit')
|
||||
.expect(404, done);
|
||||
})
|
||||
|
||||
it('should allow several capture groups', function(done){
|
||||
var app = express();
|
||||
|
||||
|
||||
@@ -57,7 +57,11 @@ Request.prototype.request = function(method, path){
|
||||
|
||||
Request.prototype.expect = function(body, fn){
|
||||
this.end(function(res){
|
||||
res.body.should.equal(body);
|
||||
if ('number' == typeof body) {
|
||||
res.statusCode.should.equal(body);
|
||||
} else {
|
||||
res.body.should.equal(body);
|
||||
}
|
||||
fn();
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user