Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than 34c83d7 point at it.

3.4.7Jonathan Ongbefore adoption34c83d7

lines 1–2why, one step back
1
2var express = require('../')

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 3why, one step back
3 , request = require('supertest');

3.4.7Jonathan Ongbefore adoption34c83d7

lines 4–17why, one step back
4
5describe('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 })17

tests: add more testsDouglas Christopher Wilsonbefore adoption5019f38

lines 18–22why, one step back
18 it('should reject numbers', function(){
19 var app = express();20 app.use.bind(app, 3).should.throw(/Number/);21 })22

3.4.7Jonathan Ongbefore adoption34c83d7

lines 23–30why, one step back
23 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 back
31

3.4.7Jonathan Ongbefore adoption34c83d7

lines 32–70why, one step back
32 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 back
71
72 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 back
77 res.end('success');

Merge pull request #1964 from blakeembrey/modular-routingRoman Shtylmanbefore adoption4867cf1

lines 78–83why, one step back
78 });
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 back
84 .expect('success', done);

Merge pull request #1964 from blakeembrey/modular-routingRoman Shtylmanbefore adoption4867cf1

line 85why, one step back
85 })

3.4.7Jonathan Ongbefore adoption34c83d7

lines 86–87why, one step back
86 })
87})