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() {