Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Reset state in order to be able to continue uploading #1

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/DirectUploadProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class DirectUploadProvider extends React.Component<Props, State> {
[string]: ActiveStorageFileUpload,
}) =>
this.setState(({ fileUploads }) => ({
uploading: false,
fileUploads: { ...fileUploads, ...fileUpload },
}))

Expand Down
11 changes: 11 additions & 0 deletions src/DirectUploadProvider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,15 @@ describe('DirectUploadProvider', () => {
await tree.props.handleUpload([file])
expect(onSuccess).toHaveBeenCalledWith(['signedId'])
})

it('is ready for another upload when an error happens', async () => {
fetch.mockRejectedValue(new Error('Fetch error'))

await tree.props.handleUpload([file])
expect(component.getInstance().state.uploading).toBe(false)

// Try to upload again
await tree.props.handleUpload([file])
expect(component.getInstance().state.uploading).toBe(false)
})
})