mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-27 05:06:40 +00:00
fix: don't throw missing eta if eta is zero (#528)
The commit 0f8136f, which enforced validation for the state object, introduced a subtle bug where `Missing state eta` would be thrown if `eta === 0`, since `!0` evaluates to `true`. This would cause the flashing to stop right at the end (when eta is zero). Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
This commit is contained in:
parent
60b68d775b
commit
d16d5469fd
@ -123,7 +123,7 @@ const storeReducer = (state, action) => {
|
|||||||
throw new Error(`Invalid state percentage: ${action.data.percentage}`);
|
throw new Error(`Invalid state percentage: ${action.data.percentage}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!action.data.eta) {
|
if (!action.data.eta && action.data.eta !== 0) {
|
||||||
throw new Error('Missing state eta');
|
throw new Error('Missing state eta');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,6 +138,18 @@ describe('Browser: ImageWriter', function() {
|
|||||||
}).to.throw('Missing state eta');
|
}).to.throw('Missing state eta');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not throw if eta is equal to zero', function() {
|
||||||
|
ImageWriterService.setFlashing(true);
|
||||||
|
m.chai.expect(function() {
|
||||||
|
ImageWriterService.setProgressState({
|
||||||
|
type: 'write',
|
||||||
|
percentage: 50,
|
||||||
|
eta: 0,
|
||||||
|
speed: 100000000000
|
||||||
|
});
|
||||||
|
}).to.not.throw('Missing state eta');
|
||||||
|
});
|
||||||
|
|
||||||
it('should throw if eta is not a number', function() {
|
it('should throw if eta is not a number', function() {
|
||||||
ImageWriterService.setFlashing(true);
|
ImageWriterService.setFlashing(true);
|
||||||
m.chai.expect(function() {
|
m.chai.expect(function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user