mirror of
https://github.com/zebrajr/express.git
synced 2025-12-06 00:19:48 +01:00
tests: prevent leaking changes to NODE_ENV
This commit is contained in:
parent
82de4de5ab
commit
a39e409cf3
33
test/app.js
33
test/app.js
|
|
@ -83,28 +83,49 @@ describe('app.path()', function(){
|
|||
})
|
||||
|
||||
describe('in development', function(){
|
||||
before(function () {
|
||||
this.env = process.env.NODE_ENV
|
||||
process.env.NODE_ENV = 'development'
|
||||
})
|
||||
|
||||
after(function () {
|
||||
process.env.NODE_ENV = this.env
|
||||
})
|
||||
|
||||
it('should disable "view cache"', function(){
|
||||
process.env.NODE_ENV = 'development';
|
||||
var app = express();
|
||||
assert.ok(!app.enabled('view cache'))
|
||||
process.env.NODE_ENV = 'test';
|
||||
})
|
||||
})
|
||||
|
||||
describe('in production', function(){
|
||||
before(function () {
|
||||
this.env = process.env.NODE_ENV
|
||||
process.env.NODE_ENV = 'production'
|
||||
})
|
||||
|
||||
after(function () {
|
||||
process.env.NODE_ENV = this.env
|
||||
})
|
||||
|
||||
it('should enable "view cache"', function(){
|
||||
process.env.NODE_ENV = 'production';
|
||||
var app = express();
|
||||
assert.ok(app.enabled('view cache'))
|
||||
process.env.NODE_ENV = 'test';
|
||||
})
|
||||
})
|
||||
|
||||
describe('without NODE_ENV', function(){
|
||||
before(function () {
|
||||
this.env = process.env.NODE_ENV
|
||||
process.env.NODE_ENV = ''
|
||||
})
|
||||
|
||||
after(function () {
|
||||
process.env.NODE_ENV = this.env
|
||||
})
|
||||
|
||||
it('should default to development', function(){
|
||||
process.env.NODE_ENV = '';
|
||||
var app = express();
|
||||
assert.strictEqual(app.get('env'), 'development')
|
||||
process.env.NODE_ENV = 'test';
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user