tests: add mounting to strict routing test
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent bcdeee2 · Browse files · 1 file·+82 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+82 added−0 removed
- tests:+82 added−0 removed
Provenance
- Commit
ef497fd- Tree
23a0475- Author
Douglas Christopher Wilson <doug@somethingdoug.com>- Committer
Douglas Christopher Wilson <doug@somethingdoug.com>- Parent
bcdeee2
1 file changed+82 added−0 removed
modified:test/app.router.js+82 added
366 unmodified lines367 .get('/user/')368 .expect('tj', done);369 })370 371+ it('should pass-though middleware', function(done){372+ var app = express();373+374+ app.enable('strict routing');375+376+ app.use(function (req, res, next) {377+ res.setHeader('x-middleware', 'true');378+ next();379+ });380+381+ app.get('/user/', function(req, res){382+ res.end('tj');383+ });384+385+ request(app)386+ .get('/user/')387+ .expect('x-middleware', 'true')388+ .expect(200, 'tj', done);389+ })390+391+ it('should pass-though mounted middleware', function(done){392+ var app = express();393+394+ app.enable('strict routing');395+396+ app.use('/user/', function (req, res, next) {397+ res.setHeader('x-middleware', 'true');398+ next();399+ });400+401+ app.get('/user/test/', function(req, res){402+ res.end('tj');403+ });404+405+ request(app)406+ .get('/user/test/')407+ .expect('x-middleware', 'true')408+ .expect(200, 'tj', done);409+ })410+411 it('should match no slashes', function(done){412 var app = express();413 414 app.enable('strict routing');6 unmodified lines421 .get('/user')422 .expect('tj', done);423 })424 425+ it('should match middleware when omitting the trailing slash', function(done){426+ var app = express();427+428+ app.enable('strict routing');429+430+ app.use('/user/', function(req, res){431+ res.end('tj');432+ });433+434+ request(app)435+ .get('/user')436+ .expect(200, 'tj', done);437+ })438+439+ it('should match middleware', function(done){440+ var app = express();441+442+ app.enable('strict routing');443+444+ app.use('/user', function(req, res){445+ res.end('tj');446+ });447+448+ request(app)449+ .get('/user')450+ .expect(200, 'tj', done);451+ })452+453+ it('should match middleware when adding the trailing slash', function(done){454+ var app = express();455+456+ app.enable('strict routing');457+458+ app.use('/user', function(req, res){459+ res.end('tj');460+ });461+462+ request(app)463+ .get('/user/')464+ .expect(200, 'tj', done);465+ })466+467 it('should fail when omitting the trailing slash', function(done){468 var app = express();469 470 app.enable('strict routing');432 unmodified lines