mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-19 09:16:38 +00:00
Avoid "Invalid state percentage: null" errors
Change-type: patch
This commit is contained in:
parent
a21a82c64e
commit
ec015da795
@ -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)) {
|
||||||
|
@ -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 () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user