Skip to content

Commit

Permalink
Test cleanup (#560)
Browse files Browse the repository at this point in the history
Fix extra console message. Update dependencies. Migrate wreck tests to newer
versions.
  • Loading branch information
arb committed Aug 10, 2017
1 parent efd3755 commit 2c478b3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
11 changes: 9 additions & 2 deletions .travis.yml
@@ -1,16 +1,23 @@
sudo: false
language: node_js

node_js:
- "4"
- "6"
- "8"
- "node"

sudo: false

env:
- HAPI_VERSION="10"
- HAPI_VERSION="11"
- HAPI_VERSION="12"
- HAPI_VERSION="13"
- HAPI_VERSION="14"
- HAPI_VERSION="15"
- HAPI_VERSION="16"

install:
- npm install -g json
- json -I -f package.json -e "this.devDependencies.hapi=\"$HAPI_VERSION\""
- npm install
- npm install hapi@$HAPI_VERSION
4 changes: 3 additions & 1 deletion lib/monitor.js
Expand Up @@ -214,7 +214,9 @@ class Monitor {
if (this._state.report) {
internals.forOwn(this._reporters, (reporter) => {

reporter.write(value());
if (reporter.destroyed === false) {
reporter.write(value());
}
});
}
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -25,11 +25,11 @@
"hapi": ">=10.x.x"
},
"devDependencies": {
"async": "2.1.x",
"async": "2.5.x",
"code": "4.x.x",
"hapi": "16.x.x",
"lab": "11.x.x",
"wreck": "10.x.x"
"lab": "14.x.x",
"wreck": "12.x.x"
},
"scripts": {
"test": "lab -m 5000 -t 100 -v -La code"
Expand Down
11 changes: 7 additions & 4 deletions test/monitor.js
Expand Up @@ -95,7 +95,7 @@ describe('Monitor', () => {
const err = console.error;
console.error = (message) => {

console.error = err;
console.error = () => { };
expect(message).to.match(/There was a problem \(.*\) in foo and it has been destroyed\./);
};

Expand All @@ -105,7 +105,9 @@ describe('Monitor', () => {

monitor.push(() => ({ id: 1, number: 2 }));
monitor.push(() => ({ id: 2, number: 5 }));
two.emit('error');
// Verion 8 of node misses this change inside monitor, so force it here
monitor._reporters.foo.destroyed = true;
monitor._reporters.foo.emit('error');
monitor.push(() => ({ id: 3, number: 100 }));
// Need this because of https://github.com/nodejs/node/pull/5251
setImmediate(callback);
Expand All @@ -114,6 +116,7 @@ describe('Monitor', () => {

expect(two.data).to.have.length(2);
expect(two.data).to.equal([{ id: 1, number: 3 }, { id: 2, number: 6 }]);
console.error = err;
done();
});
});
Expand Down Expand Up @@ -1039,7 +1042,7 @@ describe('Monitor', () => {
], done);
});

it('has a standard "wreck" event schema for version 11 and above', { plan: 2 }, (done) => {
it('has a standard "wreck" event schema for version 10', { plan: 2 }, (done) => {

const server = new Hapi.Server();
server.connection();
Expand All @@ -1057,7 +1060,7 @@ describe('Monitor', () => {

// Manually emit Wreck 11+ style event to prevent complexity of duplicate wreck versions in a test suite.
const wreck = Symbol.for('wreck');
process[wreck].emit('response', null, { req: {}, res: {}, start: 0, uri: {} });
process[wreck].emit('response', null, {}, {}, 0, {});

expect(out.data.length).to.be.greaterThan(0);
const result = out.data.find((event) => {
Expand Down

0 comments on commit 2c478b3

Please sign in to comment.