Skip to content
Myr

app.js

This file

Path

test/app.js

132 lines · 2.8 KiB · JavaScript

Last changed by

tests: use strict modeDouglas Christopher Wilsonbefore adoptiona659137

History of this file

Take it

The walk stopped after 200 commits: lines older than 76bf96e point at it.

tests: use strict modeDouglas Christopher Wilsonbefore adoptiona659137

line 1why, one step back
1'use strict'

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

lines 2–35why, one step back
2
3var assert = require('assert')4var express = require('..')5var request = require('supertest')67describe('app', function(){8 it('should inherit from event emitter', function(done){9 var app = express();10 app.on('foo', done);11 app.emit('foo');12 })1314 it('should be callable', function(){15 var app = express();16 assert.equal(typeof app, 'function');17 })1819 it('should 404 without routes', function(done){20 request(express())21 .get('/')22 .expect(404, done);23 })24})2526describe('app.parent', function(){27 it('should return the parent when mounted', function(){28 var app = express()29 , blog = express()30 , blogAdmin = express();3132 app.use('/blog', blog);33 blog.use('/admin', blogAdmin);3435 assert(!app.parent, 'app.parent');

tests: remove global dependency on shouldDouglas Christopher Wilsonbefore adoptionbd4fdfe

lines 36–37why, one step back
36 assert.strictEqual(blog.parent, app)
37 assert.strictEqual(blogAdmin.parent, blog)

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

lines 38–51why, one step back
38 })
39})4041describe('app.mountpath', function(){42 it('should return the mounted path', function(){43 var admin = express();44 var app = express();45 var blog = express();46 var fallback = express();4748 app.use('/blog', blog);49 app.use(fallback);50 blog.use('/admin', admin);51

tests: remove global dependency on shouldDouglas Christopher Wilsonbefore adoptionbd4fdfe

lines 52–55why, one step back
52 assert.strictEqual(admin.mountpath, '/admin')
53 assert.strictEqual(app.mountpath, '/')54 assert.strictEqual(blog.mountpath, '/blog')55 assert.strictEqual(fallback.mountpath, '/')

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

lines 56–79why, one step back
56 })
57})5859describe('app.router', function(){60 it('should throw with notice', function(done){61 var app = express()6263 try {64 app.router;65 } catch(err) {66 done();67 }68 })69})7071describe('app.path()', function(){72 it('should return the canonical', function(){73 var app = express()74 , blog = express()75 , blogAdmin = express();7677 app.use('/blog', blog);78 blog.use('/admin', blogAdmin);79

tests: remove global dependency on shouldDouglas Christopher Wilsonbefore adoptionbd4fdfe

lines 80–82why, one step back
80 assert.strictEqual(app.path(), '')
81 assert.strictEqual(blog.path(), '/blog')82 assert.strictEqual(blogAdmin.path(), '/blog/admin')

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

lines 83–86why, one step back
83 })
84})8586describe('in development', function(){

tests: prevent leaking changes to NODE_ENVDouglas Christopher Wilsonbefore adoptiona39e409

lines 87–95why, one step back
87 before(function () {
88 this.env = process.env.NODE_ENV89 process.env.NODE_ENV = 'development'90 })9192 after(function () {93 process.env.NODE_ENV = this.env94 })95

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

lines 96–97why, one step back
96 it('should disable "view cache"', function(){
97 var app = express();

tests: remove global dependency on shouldDouglas Christopher Wilsonbefore adoptionbd4fdfe

line 98why, one step back
98 assert.ok(!app.enabled('view cache'))

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

lines 99–102why, one step back
99 })
100})101102describe('in production', function(){

tests: prevent leaking changes to NODE_ENVDouglas Christopher Wilsonbefore adoptiona39e409

lines 103–111why, one step back
103 before(function () {
104 this.env = process.env.NODE_ENV105 process.env.NODE_ENV = 'production'106 })107108 after(function () {109 process.env.NODE_ENV = this.env110 })111

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

lines 112–113why, one step back
112 it('should enable "view cache"', function(){
113 var app = express();

tests: remove global dependency on shouldDouglas Christopher Wilsonbefore adoptionbd4fdfe

line 114why, one step back
114 assert.ok(app.enabled('view cache'))

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

lines 115–118why, one step back
115 })
116})117118describe('without NODE_ENV', function(){

tests: prevent leaking changes to NODE_ENVDouglas Christopher Wilsonbefore adoptiona39e409

lines 119–127why, one step back
119 before(function () {
120 this.env = process.env.NODE_ENV121 process.env.NODE_ENV = ''122 })123124 after(function () {125 process.env.NODE_ENV = this.env126 })127

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

lines 128–129why, one step back
128 it('should default to development', function(){
129 var app = express();

tests: remove global dependency on shouldDouglas Christopher Wilsonbefore adoptionbd4fdfe

line 130why, one step back
130 assert.strictEqual(app.get('env'), 'development')

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

lines 131–132why, one step back
131 })
132})