Skip to content
Myr

app.js

This file

Path

test/app.js

110 lines · 2.5 KiB · JavaScript

Last changed by

Fix subapp.mountpath regression for app.use(subapp)Douglas Christopher Wilsonbefore adoption3e32721

History of this file

Take it

The walk stopped after 200 commits: lines older than 269dc53 point at it.

Invoke router.param() only when route matchesDouglas Christopher Wilsonbefore adoption269dc53

lines 1–41why, one step back
1
2var assert = require('assert')3var express = require('..')4var request = require('supertest')56describe('app', function(){7 it('should inherit from event emitter', function(done){8 var app = express();9 app.on('foo', done);10 app.emit('foo');11 })1213 it('should be callable', function(){14 var app = express();15 assert(typeof app, 'function');16 })1718 it('should 404 without routes', function(done){19 request(express())20 .get('/')21 .expect(404, done);22 })23})2425describe('app.parent', function(){26 it('should return the parent when mounted', function(){27 var app = express()28 , blog = express()29 , blogAdmin = express();3031 app.use('/blog', blog);32 blog.use('/admin', blogAdmin);3334 assert(!app.parent, 'app.parent');35 blog.parent.should.equal(app);36 blogAdmin.parent.should.equal(blog);37 })38})3940describe('app.mountpath', function(){41 it('should return the mounted path', function(){

Fix subapp.mountpath regression for app.use(subapp)Douglas Christopher Wilsonbefore adoption3e32721

lines 42–45why, one step back
42 var admin = express();
43 var app = express();44 var blog = express();45 var fallback = express();

Invoke router.param() only when route matchesDouglas Christopher Wilsonbefore adoption269dc53

lines 46–47why, one step back
46
47 app.use('/blog', blog);

Fix subapp.mountpath regression for app.use(subapp)Douglas Christopher Wilsonbefore adoption3e32721

lines 48–49why, one step back
48 app.use(fallback);
49 blog.use('/admin', admin);

Invoke router.param() only when route matchesDouglas Christopher Wilsonbefore adoption269dc53

line 50why, one step back
50

Fix subapp.mountpath regression for app.use(subapp)Douglas Christopher Wilsonbefore adoption3e32721

line 51why, one step back
51 admin.mountpath.should.equal('/admin');

Invoke router.param() only when route matchesDouglas Christopher Wilsonbefore adoption269dc53

lines 52–53why, one step back
52 app.mountpath.should.equal('/');
53 blog.mountpath.should.equal('/blog');

Fix subapp.mountpath regression for app.use(subapp)Douglas Christopher Wilsonbefore adoption3e32721

line 54why, one step back
54 fallback.mountpath.should.equal('/');

Invoke router.param() only when route matchesDouglas Christopher Wilsonbefore adoption269dc53

lines 55–110why, one step back
55 })
56})5758describe('app.router', function(){59 it('should throw with notice', function(done){60 var app = express()6162 try {63 app.router;64 } catch(err) {65 done();66 }67 })68})6970describe('app.path()', function(){71 it('should return the canonical', function(){72 var app = express()73 , blog = express()74 , blogAdmin = express();7576 app.use('/blog', blog);77 blog.use('/admin', blogAdmin);7879 app.path().should.equal('');80 blog.path().should.equal('/blog');81 blogAdmin.path().should.equal('/blog/admin');82 })83})8485describe('in development', function(){86 it('should disable "view cache"', function(){87 process.env.NODE_ENV = 'development';88 var app = express();89 app.enabled('view cache').should.be.false;90 process.env.NODE_ENV = 'test';91 })92})9394describe('in production', function(){95 it('should enable "view cache"', function(){96 process.env.NODE_ENV = 'production';97 var app = express();98 app.enabled('view cache').should.be.true;99 process.env.NODE_ENV = 'test';100 })101})102103describe('without NODE_ENV', function(){104 it('should default to development', function(){105 process.env.NODE_ENV = '';106 var app = express();107 app.get('env').should.equal('development');108 process.env.NODE_ENV = 'test';109 })110})