app.use.js
This file
Path
test/app.use.js
87 lines · 1.8 KiB · JavaScript
Last changed by
tests: add more testsDouglas Christopher Wilsonbefore adoption5019f38
History of this fileTake it
The walk stopped after 200 commits: lines older than 34c83d7 point at it.
3.4.7Jonathan Ongbefore adoption34c83d7
lines 1–2why, one step back12var express = require('../')remove unnecessary test/support/httpJonathan Ongbefore adoption643397e
line 3why, one step back3 , request = require('supertest');3.4.7Jonathan Ongbefore adoption34c83d7
lines 4–17why, one step back45describe('app', function(){6 it('should emit "mount" when mounted', function(done){7 var blog = express()8 , app = express();910 blog.on('mount', function(arg){11 arg.should.equal(app);12 done();13 });1415 app.use(blog);16 })17tests: add more testsDouglas Christopher Wilsonbefore adoption5019f38
lines 18–22why, one step back18 it('should reject numbers', function(){19 var app = express();20 app.use.bind(app, 3).should.throw(/Number/);21 })223.4.7Jonathan Ongbefore adoption34c83d7
lines 23–30why, one step back23 describe('.use(app)', function(){24 it('should mount the app', function(done){25 var blog = express()26 , app = express();2728 blog.get('/blog', function(req, res){29 res.end('blog');30 });remove unnecessary test/support/httpJonathan Ongbefore adoption643397e
line 31why, one step back313.4.7Jonathan Ongbefore adoption34c83d7
lines 32–70why, one step back32 app.use(blog);3334 request(app)35 .get('/blog')36 .expect('blog', done);37 })3839 it('should support mount-points', function(done){40 var blog = express()41 , forum = express()42 , app = express();4344 blog.get('/', function(req, res){45 res.end('blog');46 });4748 forum.get('/', function(req, res){49 res.end('forum');50 });5152 app.use('/blog', blog);53 app.use('/forum', forum);5455 request(app)56 .get('/blog')57 .expect('blog', function(){58 request(app)59 .get('/forum')60 .expect('forum', done);61 });62 })6364 it('should set the child\'s .parent', function(){65 var blog = express()66 , app = express();6768 app.use('/blog', blog);69 blog.parent.should.equal(app);70 })Merge pull request #1964 from blakeembrey/modular-routingRoman Shtylmanbefore adoption4867cf1
lines 71–76why, one step back7172 it('should support dynamic routes', function(done){73 var blog = express()74 , app = express();7576 blog.get('/', function(req, res){Merge pull request #1984 from blakeembrey/params-updateRoman Shtylmanbefore adoptioncc38ccc
line 77why, one step back77 res.end('success');Merge pull request #1964 from blakeembrey/modular-routingRoman Shtylmanbefore adoption4867cf1
lines 78–83why, one step back78 });7980 app.use('/post/:article', blog);8182 request(app)83 .get('/post/once-upon-a-time')Merge pull request #1984 from blakeembrey/params-updateRoman Shtylmanbefore adoptioncc38ccc
line 84why, one step back84 .expect('success', done);Merge pull request #1964 from blakeembrey/modular-routingRoman Shtylmanbefore adoption4867cf1
line 85why, one step back85 })3.4.7Jonathan Ongbefore adoption34c83d7
lines 86–87why, one step back86 })87})