From 6f175f7bbd95e526890faa25d88daca2e48dabc4 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 20 Jun 2016 13:42:25 -0700 Subject: [PATCH 1/2] Emit new state + message as well, on status change Former-commit-id: 4d24a4b316a823cf70d6dbfeb9668cac9089d612 --- src/server/status/status.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/status/status.js b/src/server/status/status.js index 2aefc1fff1d8..573eb041a2a6 100644 --- a/src/server/status/status.js +++ b/src/server/status/status.js @@ -82,8 +82,8 @@ states.all.forEach(function (state) { return; } - this.emit(state.id, previous, previousMsg); - this.emit('change', previous, previousMsg); + this.emit(state.id, previous, previousMsg, this.state, this.message); + this.emit('change', previous, previousMsg, this.state, this.message); }; }); From c8bf8b0aefb9d531b1a16daff88794836740d614 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 20 Jun 2016 13:47:17 -0700 Subject: [PATCH 2/2] Updating unit tests Former-commit-id: 706b4d9c956fa88037d296beadd12f706923cf9b --- src/server/status/__tests__/status.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/server/status/__tests__/status.js b/src/server/status/__tests__/status.js index ae8e41908962..2dfe03779102 100644 --- a/src/server/status/__tests__/status.js +++ b/src/server/status/__tests__/status.js @@ -21,15 +21,15 @@ describe('Status class', function () { it('emits change when the status is set', function (done) { let status = serverStatus.createForPlugin(plugin); - status.once('change', function (prev, prevMsg) { - expect(status.state).to.be('green'); - expect(status.message).to.be('GREEN'); - expect(prev).to.be('uninitialized'); - - status.once('change', function (prev, prevMsg) { - expect(status.state).to.be('red'); - expect(status.message).to.be('RED'); - expect(prev).to.be('green'); + status.once('change', function (prevState, prevMsg, newState, newMsg) { + expect(newState).to.be('green'); + expect(newMsg).to.be('GREEN'); + expect(prevState).to.be('uninitialized'); + + status.once('change', function (prevState, prevMsg, newState, newMsg) { + expect(newState).to.be('red'); + expect(newMsg).to.be('RED'); + expect(prevState).to.be('green'); expect(prevMsg).to.be('GREEN'); done();