config.js
This file
Path
test/config.js
117 lines · 3.0 KiB · JavaScript
Last changed by
Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d
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–15why, one step back12var express = require('../')3 , assert = require('assert');45describe('config', function(){6 describe('.set()', function(){7 it('should set a value', function(){8 var app = express();9 app.set('foo', 'bar').should.equal(app);10 })1112 it('should return the app when undefined', function(){13 var app = express();14 app.set('foo', undefined).should.equal(app);15 })Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d
lines 16–38why, one step back1617 describe('"etag"', function(){18 it('should throw on bad value', function(){19 var app = express()20 app.set.bind(app, 'etag', 42).should.throw(/unknown value/)21 })2223 it('should set "etag fn"', function(){24 var app = express()25 var fn = function(){}26 app.set('etag', fn)27 app.get('etag fn').should.equal(fn)28 })29 })3031 describe('"trust proxy"', function(){32 it('should set "trust proxy fn"', function(){33 var app = express()34 var fn = function(){}35 app.set('trust proxy', fn)36 app.get('trust proxy fn').should.equal(fn)37 })38 })3.4.7Jonathan Ongbefore adoption34c83d7
lines 39–117why, one step back39 })4041 describe('.get()', function(){42 it('should return undefined when unset', function(){43 var app = express();44 assert(undefined === app.get('foo'));45 })46 47 it('should otherwise return the value', function(){48 var app = express();49 app.set('foo', 'bar');50 app.get('foo').should.equal('bar');51 })5253 describe('when mounted', function(){54 it('should default to the parent app', function(){55 var app = express()56 , blog = express();5758 app.set('title', 'Express');59 app.use(blog);60 blog.get('title').should.equal('Express');61 })62 63 it('should given precedence to the child', function(){64 var app = express()65 , blog = express();6667 app.use(blog);68 app.set('title', 'Express');69 blog.set('title', 'Some Blog');7071 blog.get('title').should.equal('Some Blog');72 })73 })74 })7576 describe('.enable()', function(){77 it('should set the value to true', function(){78 var app = express();79 app.enable('tobi').should.equal(app);80 app.get('tobi').should.be.true;81 })82 })83 84 describe('.disable()', function(){85 it('should set the value to false', function(){86 var app = express();87 app.disable('tobi').should.equal(app);88 app.get('tobi').should.be.false;89 })90 })91 92 describe('.enabled()', function(){93 it('should default to false', function(){94 var app = express();95 app.enabled('foo').should.be.false;96 })97 98 it('should return true when set', function(){99 var app = express();100 app.set('foo', 'bar');101 app.enabled('foo').should.be.true;102 })103 })104 105 describe('.disabled()', function(){106 it('should default to true', function(){107 var app = express();108 app.disabled('foo').should.be.true;109 })110 111 it('should return false when set', function(){112 var app = express();113 app.set('foo', 'bar');114 app.disabled('foo').should.be.false;115 })116 })117})