Skip to content

Commit

Permalink
add test for missing handler in config
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Jun 1, 2017
1 parent c92191d commit 943d782
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ function configureHandler(handler, options) {
}

function getHandler(name, options) {
var handler = options.handlers[name];
var handler = options.handlers && options.handlers[name];
if (!handler) {
var errStr = util.format('Handler "%s" is not defined in config.', name);
var errStr = util.format('Handler "%s" is not defined in config', name);
throw new Error(errStr);
}
if (typeof handler.handle !== 'function') {
Expand Down
11 changes: 11 additions & 0 deletions test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,17 @@ module.exports = {
});
}, /function parameter did not parse as a function$/);
},
'should error if cannot find handler': function() {
assert.throws(function() {
intel.config({
loggers: {
'missingHandler': {
handlers: ['nope']
}
}
});
}, /Handler "nope" is not defined in config$/);
},
'should assign a NullHandler to ROOT if handlers object': function() {
intel._handlers = [];
intel.config({
Expand Down

0 comments on commit 943d782

Please sign in to comment.