From 3bf712b592a7fb7d045ad1c208ab0da987e9f297 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 27 Jun 2016 16:15:35 -0400 Subject: [PATCH] fix: don't throw if state percentage is zero (#536) Signed-off-by: Juan Cruz Viotti --- lib/gui/models/store.js | 2 +- tests/gui/modules/image-writer.spec.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/gui/models/store.js b/lib/gui/models/store.js index 5855fd5b..173be8de 100644 --- a/lib/gui/models/store.js +++ b/lib/gui/models/store.js @@ -133,7 +133,7 @@ const storeReducer = (state, action) => { throw new Error(`Invalid state type: ${action.data.type}`); } - if (!action.data.percentage) { + if (_.isUndefined(action.data.percentage) || _.isNull(action.data.percentage)) { throw new Error('Missing state percentage'); } diff --git a/tests/gui/modules/image-writer.spec.js b/tests/gui/modules/image-writer.spec.js index 7e96fdd1..cb0c2f75 100644 --- a/tests/gui/modules/image-writer.spec.js +++ b/tests/gui/modules/image-writer.spec.js @@ -120,6 +120,18 @@ describe('Browser: ImageWriter', function() { }).to.throw('Invalid state type: 1234'); }); + it('should not throw if percentage is 0', function() { + ImageWriterService.setFlashingFlag(); + m.chai.expect(function() { + ImageWriterService.setProgressState({ + type: 'write', + percentage: 0, + eta: 15, + speed: 100000000000 + }); + }).to.not.throw('Missing state percentage'); + }); + it('should throw if percentage is missing', function() { ImageWriterService.setFlashingFlag(); m.chai.expect(function() {