app.route.js
This file
Path
test/app.route.js
62 lines · 1.1 KiB · JavaScript
Last changed by
tests: add more route testsDouglas Christopher Wilsonbefore adoption21393c2
History of this fileTake it
remove unnecessary test/support/httpJonathan Ongbefore adoption643397e
lines 1–2why, one step back1var express = require('../');2var request = require('supertest');implement app.route()Roman Shtylmanbefore adoption0719e5f
lines 3–19why, one step back34describe('app.route', function(){5 it('should return a new route', function(done){6 var app = express();78 app.route('/foo')9 .get(function(req, res) {10 res.send('get');11 })12 .post(function(req, res) {13 res.send('post');14 });1516 request(app)17 .post('/foo')18 .expect('post', done);19 });fix Route#all before Route#verbRoman Shtylmanbefore adoptiond368aed
lines 20–38why, one step back2021 it('should all .VERB after .all', function(done){22 var app = express();2324 app.route('/foo')25 .all(function(req, res, next) {26 next();27 })28 .get(function(req, res) {29 res.send('get');30 })31 .post(function(req, res) {32 res.send('post');33 });3435 request(app)36 .post('/foo')37 .expect('post', done);38 });Merge pull request #1964 from blakeembrey/modular-routingRoman Shtylmanbefore adoption4867cf1
lines 39–51why, one step back3940 it('should support dynamic routes', function(done){41 var app = express();4243 app.route('/:foo')44 .get(function(req, res) {45 res.send(req.params.foo);46 });4748 request(app)49 .get('/test')50 .expect('test', done);51 });tests: add more route testsDouglas Christopher Wilsonbefore adoption21393c2
lines 52–61why, one step back5253 it('should not error on empty routes', function(done){54 var app = express();5556 app.route('/:foo');5758 request(app)59 .get('/test')60 .expect(404, done);61 });implement app.route()Roman Shtylmanbefore adoption0719e5f
line 62why, one step back62});