From 4d24a4b316a823cf70d6dbfeb9668cac9089d612 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 --- 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 2aefc1fff1d8f..573eb041a2a6b 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 706b4d9c956fa88037d296beadd12f706923cf9b 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 --- 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 ae8e419089628..2dfe037791027 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();