mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-27 21:26:38 +00:00
fix: don't allow to set the flashing state if not flashing (#519)
Currently, we allow updating the flashing state independently on the value of the `flashing` property. In order to maintain the application state coherent, we deny updating the flashing state if we're not currently flashing, which lets us safely assume that the state will be in a reset state if we're not flashing. Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
This commit is contained in:
parent
2ecf9d32a7
commit
5ac5f3a423
@ -86,6 +86,10 @@ const store = function(state, action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'SET_FLASH_STATE': {
|
case 'SET_FLASH_STATE': {
|
||||||
|
if (!state.getIn([ 'flash', 'flashing' ])) {
|
||||||
|
throw new Error('Can\'t set the flashing state when not flashing');
|
||||||
|
}
|
||||||
|
|
||||||
return state.setIn([ 'flash', 'state' ], Immutable.fromJS(action.data));
|
return state.setIn([ 'flash', 'state' ], Immutable.fromJS(action.data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +67,22 @@ describe('Browser: ImageWriter', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('.setProgressState()', function() {
|
||||||
|
|
||||||
|
it('should not allow setting the state if flashing is false', function() {
|
||||||
|
ImageWriterService.setFlashing(false);
|
||||||
|
m.chai.expect(function() {
|
||||||
|
ImageWriterService.setProgressState({
|
||||||
|
type: 'write',
|
||||||
|
percentage: 50,
|
||||||
|
eta: 15,
|
||||||
|
speed: 100000000000
|
||||||
|
});
|
||||||
|
}).to.throw('Can\'t set the flashing state when not flashing');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
describe('.setFlashing()', function() {
|
describe('.setFlashing()', function() {
|
||||||
|
|
||||||
it('should be able to set flashing to true', function() {
|
it('should be able to set flashing to true', function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user