Avoid "Invalid state percentage: null" errors

Change-type: patch
This commit is contained in:
Alexis Svinartchouk 2019-03-28 16:14:08 +01:00
parent a21a82c64e
commit ec015da795
2 changed files with 2 additions and 18 deletions

View File

@ -119,7 +119,8 @@ exports.setProgressState = (state) => {
const data = _.assign({}, state, { const data = _.assign({}, state, {
percentage: _.isFinite(state.percentage) percentage: _.isFinite(state.percentage)
? Math.floor(state.percentage) ? Math.floor(state.percentage)
: state.percentage, // eslint-disable-next-line no-undefined
: undefined,
speed: _.attempt(() => { speed: _.attempt(() => {
if (_.isFinite(state.speed)) { if (_.isFinite(state.speed)) {

View File

@ -126,23 +126,6 @@ describe('Model: flashState', function () {
}).to.not.throw('Missing flash fields: percentage') }).to.not.throw('Missing flash fields: percentage')
}) })
it('should throw if percentage is not a number', function () {
flashState.setFlashingFlag()
m.chai.expect(function () {
flashState.setProgressState({
flashing: 2,
verifying: 0,
successful: 0,
failed: 0,
type: 'write',
percentage: '50',
eta: 15,
speed: 100000000000,
totalSpeed: 200000000000
})
}).to.throw('Invalid state percentage: 50')
})
it('should throw if percentage is outside maximum bound', function () { it('should throw if percentage is outside maximum bound', function () {
flashState.setFlashingFlag() flashState.setFlashingFlag()
m.chai.expect(function () { m.chai.expect(function () {