config.env.js
This file
Path
test/config.env.js
96 lines · 2.1 KiB · JavaScript
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than 8ac3e80 point at it.
Merge branch 'master' of github.com:visionmedia/expressTJ Holowaychukbefore adoption8ac3e80
lines 1–96why, one step back12var express = require('../');34describe('config', function(){5 describe('.configure()', function(){6 describe('when no env is given', function(){7 it('should always execute', function(){8 var app = express();9 var calls = [];1011 app.configure(function(){12 calls.push('all');13 });1415 app.configure('test', function(){16 calls.push('test');17 });1819 app.configure('test', function(){20 calls.push('test 2');21 });2223 calls.should.eql(['all', 'test', 'test 2'])24 })25 })2627 describe('when an env is given', function(){28 it('should only execute the matching env', function(){29 var app = express();30 var calls = [];3132 app.set('env', 'development');3334 app.configure('development', function(){35 calls.push('dev');36 });3738 app.configure('test', function(){39 calls.push('test');40 });4142 calls.should.eql(['dev']);43 })44 })45 46 describe('when several envs are given', function(){47 it('should execute when matching one', function(){48 var app = express();49 var calls = [];5051 app.set('env', 'development');5253 app.configure('development', function(){54 calls.push('dev');55 });5657 app.configure('test', 'development', function(){58 calls.push('dev 2');59 });60 61 app.configure('development', 'test', function(){62 calls.push('dev 3');63 });64 65 app.configure('test', function(){66 calls.push('dev 3');67 });6869 calls.should.eql(['dev', 'dev 2', 'dev 3']);70 })71 })7273 it('should execute in order as defined', function(){74 var app = express();75 var calls = [];7677 app.configure(function(){78 calls.push('all');79 });80 81 app.configure('test', function(){82 calls.push('test');83 });8485 app.configure(function(){86 calls.push('all 2');87 });8889 app.configure('test', function(){90 calls.push('test 2');91 });9293 calls.should.eql(['all', 'test', 'all 2', 'test 2'])94 })95 })96})