Skip to content

Commit

Permalink
Don't create a reporter if no streams were provided. Addresses hapijs…
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwsperber committed Nov 18, 2016
1 parent dfe7912 commit 18780d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/monitor.js
Expand Up @@ -92,6 +92,9 @@ class Monitor {
start(callback) {

internals.forOwn(this.settings.reporters, (reporterName, streamsSpec) => {
if (!streamsSpec.length) {
return;
}

const streamObjs = [];
for (let i = 0; i < streamsSpec.length; ++i) {
Expand Down
18 changes: 18 additions & 0 deletions test/monitor.js
Expand Up @@ -245,6 +245,24 @@ describe('Monitor', () => {

done();
});

it('does not create a reporter if it has no streams', { plan: 2 }, (done) => {

const monitor = internals.monitorFactory(new Hapi.Server(), {
reporters: {
foo: []
}
});

monitor.start((error) => {

expect(error).to.not.exist();

expect(monitor._reporters).to.have.length(0);

done();
});
});
});

describe('push()', () => {
Expand Down

0 comments on commit 18780d3

Please sign in to comment.