Skip to content

Commit

Permalink
Strict object check in environment.load
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriangalliat committed Feb 4, 2015
1 parent 52a4a6f commit 494997c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ export default class Environment extends EventEmitter {
return this.loadDefaultFile();
}

if (typeof config === 'string') {
if (is.string(config)) {
return this.loadFile(config);
}

if (typeof config === 'object') {
if (is.plainObject(config)) {
return this.loadObject(config);
}

Expand Down
13 changes: 9 additions & 4 deletions test/env/environment.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,20 @@ describe('#environment', function () {
* Passed in wrong type config file.
*/
describe('#config-fail', function () {
var spy = sinon.spy();
var spy;

beforeEach(function () {
spy = sinon.spy();
env.on('error', spy);
env.load(123); // @TOO [] pass
env.postProcess();
});

it('should error if config is of a wrong format', function () {
it('should error if config is a number', function () {
env.load(123);
assert.ok(spy.called);
});

it('should error if config is an array', function () {
env.load([]);
assert.ok(spy.called);
});
});
Expand Down

0 comments on commit 494997c

Please sign in to comment.