fix: don't throw if state percentage is zero (#536)

Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
This commit is contained in:
Juan Cruz Viotti 2016-06-27 16:15:35 -04:00 committed by GitHub
parent 74d436f4f5
commit 3bf712b592
2 changed files with 13 additions and 1 deletions

View File

@ -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');
}

View File

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