mirror of
https://github.com/balena-io/etcher.git
synced 2025-04-24 07:17:18 +00:00
fix(tests): Remove throw if no percentage or eta test
Since 25916200f2864a9b137325f919c0f8ef5d62fa60 we can handle a progress state with no percentage or eta.
This commit is contained in:
parent
6b270885bf
commit
63967d1558
@ -24,6 +24,7 @@ const constraints = require('../../../shared/drive-constraints')
|
||||
const supportedFormats = require('../../../shared/supported-formats')
|
||||
const errors = require('../../../shared/errors')
|
||||
const fileExtensions = require('../../../shared/file-extensions')
|
||||
const utils = require('../../../shared/utils')
|
||||
const settings = require('./settings')
|
||||
|
||||
/**
|
||||
@ -250,6 +251,20 @@ const storeReducer = (state = DEFAULT_STATE, action) => {
|
||||
})
|
||||
}
|
||||
|
||||
if (action.data.percentage !== undefined) {
|
||||
if (!utils.isValidPercentage(action.data.percentage)) {
|
||||
throw errors.createError({
|
||||
title: `Invalid state percentage: ${action.data.percentage}`
|
||||
})
|
||||
}
|
||||
|
||||
if (!_.isNumber(action.data.eta)) {
|
||||
throw errors.createError({
|
||||
title: `Invalid state eta: ${action.data.eta}`
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return state.set('flashState', Immutable.fromJS(action.data))
|
||||
}
|
||||
|
||||
|
@ -126,22 +126,6 @@ describe('Model: flashState', function () {
|
||||
}).to.not.throw('Missing flash fields: percentage')
|
||||
})
|
||||
|
||||
it('should throw if percentage is missing', function () {
|
||||
flashState.setFlashingFlag()
|
||||
m.chai.expect(function () {
|
||||
flashState.setProgressState({
|
||||
flashing: 2,
|
||||
verifying: 0,
|
||||
successful: 0,
|
||||
failed: 0,
|
||||
type: 'write',
|
||||
eta: 15,
|
||||
speed: 100000000000,
|
||||
totalSpeed: 200000000000
|
||||
})
|
||||
}).to.throw('Missing flash fields: percentage')
|
||||
})
|
||||
|
||||
it('should throw if percentage is not a number', function () {
|
||||
flashState.setFlashingFlag()
|
||||
m.chai.expect(function () {
|
||||
@ -193,22 +177,6 @@ describe('Model: flashState', function () {
|
||||
}).to.throw('Invalid state percentage: -1')
|
||||
})
|
||||
|
||||
it('should throw if eta is missing', function () {
|
||||
flashState.setFlashingFlag()
|
||||
m.chai.expect(function () {
|
||||
flashState.setProgressState({
|
||||
flashing: 2,
|
||||
verifying: 0,
|
||||
successful: 0,
|
||||
failed: 0,
|
||||
type: 'write',
|
||||
percentage: 50,
|
||||
speed: 100000000000,
|
||||
totalSpeed: 200000000000
|
||||
})
|
||||
}).to.throw('Missing flash fields: eta')
|
||||
})
|
||||
|
||||
it('should not throw if eta is equal to zero', function () {
|
||||
flashState.setFlashingFlag()
|
||||
m.chai.expect(function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user