config.js
This file
Path
test/config.js
162 lines · 4.4 KiB · JavaScript
Last changed by
Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
History of this fileTake it
The walk stopped after 200 commits: lines older than 6bc7574 point at it.
docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
line 1why, one step back1Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
lines 2–3why, one step back2var assert = require('assert');3var express = require('..');docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
line 4why, one step back4Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
lines 5–7why, one step back5describe('config', function () {6 describe('.set()', function () {7 it('should set a value', function () {docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
line 8why, one step back8 var app = express();Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
lines 9–10why, one step back9 app.set('foo', 'bar');10 assert.equal(app.get('foo'), 'bar');docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 11–12why, one step back11 })12Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
line 13why, one step back13 it('should return the app', function () {docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
line 14why, one step back14 var app = express();Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
line 15why, one step back15 assert.equal(app.set('foo', 'bar'), app);docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 16–17why, one step back16 })17Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
lines 18–22why, one step back18 it('should return the app when undefined', function () {19 var app = express();20 assert.equal(app.set('foo', undefined), app);21 })22docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 23–24why, one step back23 describe('"etag"', function(){24 it('should throw on bad value', function(){Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
lines 25–26why, one step back25 var app = express();26 assert.throws(app.set.bind(app, 'etag', 42), /unknown value/);docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 27–32why, one step back27 })2829 it('should set "etag fn"', function(){30 var app = express()31 var fn = function(){}32 app.set('etag', fn)Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
line 33why, one step back33 assert.equal(app.get('etag fn'), fn)docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 34–41why, one step back34 })35 })3637 describe('"trust proxy"', function(){38 it('should set "trust proxy fn"', function(){39 var app = express()40 var fn = function(){}41 app.set('trust proxy', fn)Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
line 42why, one step back42 assert.equal(app.get('trust proxy fn'), fn)docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 43–49why, one step back43 })44 })45 })4647 describe('.get()', function(){48 it('should return undefined when unset', function(){49 var app = express();Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
line 50why, one step back50 assert.strictEqual(app.get('foo'), undefined);docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 51–55why, one step back51 })52 53 it('should otherwise return the value', function(){54 var app = express();55 app.set('foo', 'bar');Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
line 56why, one step back56 assert.equal(app.get('foo'), 'bar');docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 57–60why, one step back57 })5859 describe('when mounted', function(){60 it('should default to the parent app', function(){Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
lines 61–62why, one step back61 var app = express();62 var blog = express();docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 63–65why, one step back6364 app.set('title', 'Express');65 app.use(blog);Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
line 66why, one step back66 assert.equal(blog.get('title'), 'Express');docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
line 67why, one step back67 })Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
line 68why, one step back68docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
line 69why, one step back69 it('should given precedence to the child', function(){Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
lines 70–71why, one step back70 var app = express();71 var blog = express();docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 72–76why, one step back7273 app.use(blog);74 app.set('title', 'Express');75 blog.set('title', 'Some Blog');76Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
line 77why, one step back77 assert.equal(blog.get('title'), 'Some Blog');docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
line 78why, one step back78 })Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
lines 79–117why, one step back7980 it('should inherit "trust proxy" setting', function () {81 var app = express();82 var blog = express();8384 function fn() { return false }8586 app.set('trust proxy', fn);87 assert.equal(app.get('trust proxy'), fn);88 assert.equal(app.get('trust proxy fn'), fn);8990 app.use(blog);9192 assert.equal(blog.get('trust proxy'), fn);93 assert.equal(blog.get('trust proxy fn'), fn);94 })9596 it('should prefer child "trust proxy" setting', function () {97 var app = express();98 var blog = express();99100 function fn1() { return false }101 function fn2() { return true }102103 app.set('trust proxy', fn1);104 assert.equal(app.get('trust proxy'), fn1);105 assert.equal(app.get('trust proxy fn'), fn1);106107 blog.set('trust proxy', fn2);108 assert.equal(blog.get('trust proxy'), fn2);109 assert.equal(blog.get('trust proxy fn'), fn2);110111 app.use(blog);112113 assert.equal(app.get('trust proxy'), fn1);114 assert.equal(app.get('trust proxy fn'), fn1);115 assert.equal(blog.get('trust proxy'), fn2);116 assert.equal(blog.get('trust proxy fn'), fn2);117 })docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 118–123why, one step back118 })119 })120121 describe('.enable()', function(){122 it('should set the value to true', function(){123 var app = express();Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
lines 124–125why, one step back124 assert.equal(app.enable('tobi'), app);125 assert.strictEqual(app.get('tobi'), true);docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 126–131why, one step back126 })127 })128 129 describe('.disable()', function(){130 it('should set the value to false', function(){131 var app = express();Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
lines 132–133why, one step back132 assert.equal(app.disable('tobi'), app);133 assert.strictEqual(app.get('tobi'), false);docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 134–139why, one step back134 })135 })136 137 describe('.enabled()', function(){138 it('should default to false', function(){139 var app = express();Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
line 140why, one step back140 assert.strictEqual(app.enabled('foo'), false);docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 141–145why, one step back141 })142 143 it('should return true when set', function(){144 var app = express();145 app.set('foo', 'bar');Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
line 146why, one step back146 assert.strictEqual(app.enabled('foo'), true);docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 147–152why, one step back147 })148 })149 150 describe('.disabled()', function(){151 it('should default to true', function(){152 var app = express();Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
line 153why, one step back153 assert.strictEqual(app.disabled('foo'), true);docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 154–158why, one step back154 })155 156 it('should return false when set', function(){157 var app = express();158 app.set('foo', 'bar');Merge tag '3.20.0'Douglas Christopher Wilsonbefore adoption531f024
line 159why, one step back159 assert.strictEqual(app.disabled('foo'), false);docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 160–162why, one step back160 })161 })162})