Files
express/test/req.route.js

29 lines
662 B
JavaScript
Raw Normal View History

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){
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){
res.header('path-2', req.route.path)
2011-11-24 17:59:00 -08:00
res.end();
});
request(app)
.get('/user/12/edit')
2024-09-09 17:50:11 -05:00
.expect('path-1', '/user/:id{/:op}')
.expect('path-2', '/user/:id/edit')
.expect(200, done)
2011-11-24 17:59:00 -08:00
})
})
})