Skip to content

Commit

Permalink
@uppy/core: fix uppy.resetProgress() (#4337)
Browse files Browse the repository at this point in the history
* Fix uppy.resetProgress()

* Update tests
  • Loading branch information
arturi committed Mar 2, 2023
1 parent cb5c0de commit 222e511
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/@uppy/core/src/Uppy.js
Expand Up @@ -233,15 +233,22 @@ class Uppy {
}
const files = { ...this.getState().files }
const updatedFiles = {}

Object.keys(files).forEach(fileID => {
const updatedFile = { ...files[fileID] }
updatedFile.progress = { ...updatedFile.progress, ...defaultProgress }
updatedFiles[fileID] = updatedFile
updatedFiles[fileID] = {
...files[fileID],
progress: {
...files[fileID].progress, ...defaultProgress,
},
}
})

this.setState({
files: updatedFiles,
totalProgress: 0,
allowNewUpload: true,
error: null,
recoveredState: null,
})

this.emit('reset-progress')
Expand Down
4 changes: 4 additions & 0 deletions packages/@uppy/core/src/Uppy.test.js
Expand Up @@ -1619,6 +1619,10 @@ describe('src/Core', () => {
uploadStarted: null,
})
expect(core.getState().totalProgress).toEqual(0)
expect(core.getState().allowNewUpload).toEqual(true)
expect(core.getState().error).toEqual(null)
expect(core.getState().recoveredState).toEqual(null)

expect(resetProgressEvent.mock.calls.length).toEqual(1)
})
})
Expand Down

0 comments on commit 222e511

Please sign in to comment.