2022-02-09 01:07:08 -05:00
|
|
|
'use strict'
|
2011-11-24 17:59:00 -08:00
|
|
|
|
|
|
|
|
var express = require('../')
|
2014-03-05 22:06:14 -08:00
|
|
|
, request = require('supertest');
|
2011-11-24 17:59:00 -08:00
|
|
|
|
|
|
|
|
describe('req', function(){
|
|
|
|
|
describe('.route', function(){
|
|
|
|
|
it('should be the executed Route', function(done){
|
|
|
|
|
var app = express();
|
|
|
|
|
|
2024-09-09 17:50:11 -05:00
|
|
|
app.get('/user/:id{/:op}', function(req, res, next){
|
2022-02-02 01:55:16 -05:00
|
|
|
res.header('path-1', req.route.path)
|
2011-11-24 17:59:00 -08:00
|
|
|
next();
|
|
|
|
|
});
|
2014-03-05 22:06:14 -08:00
|
|
|
|
2011-11-24 17:59:00 -08:00
|
|
|
app.get('/user/:id/edit', function(req, res){
|
2022-02-02 01:55:16 -05:00
|
|
|
res.header('path-2', req.route.path)
|
2011-11-24 17:59:00 -08:00
|
|
|
res.end();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
request(app)
|
2022-02-02 01:55:16 -05:00
|
|
|
.get('/user/12/edit')
|
2024-09-09 17:50:11 -05:00
|
|
|
.expect('path-1', '/user/:id{/:op}')
|
2022-02-02 01:55:16 -05:00
|
|
|
.expect('path-2', '/user/:id/edit')
|
|
|
|
|
.expect(200, done)
|
2011-11-24 17:59:00 -08:00
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|