Skip to content

Commit

Permalink
@uppy/companion: fix infinite recursion in uploader test (#4536)
Browse files Browse the repository at this point in the history
* fix stack size exceeded

* remove invalid assertion

success event never seems to have included "bytesTotal" in payload
this assertion was mistakenly moved from onProgress to success in 
1b5c0d7.
  • Loading branch information
mifi authored Jul 6, 2023
1 parent 8afe533 commit a78679a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/@uppy/companion/test/__tests__/uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,15 @@ describe('uploader with tus protocol', () => {
}

const uploader = new Uploader(opts)
const originalTryDeleteTmpPath = uploader.tryDeleteTmpPath.bind(uploader)
uploader.tryDeleteTmpPath = async () => {
// validate that the tmp file has been downloaded and saved into the file path
// must do it before it gets deleted
const fileInfo = fs.statSync(uploader.tmpPath)
expect(fileInfo.isFile()).toBe(true)
expect(fileInfo.size).toBe(fileContent.length)

return uploader.tryDeleteTmpPath()
return originalTryDeleteTmpPath()
}
const uploadToken = uploader.token
expect(uploadToken).toBeTruthy()
Expand All @@ -148,13 +149,12 @@ describe('uploader with tus protocol', () => {
// emulate socket connection
socketClient.connect(uploadToken)
socketClient.onProgress(uploadToken, (message) => {
if (firstReceivedProgress == null) firstReceivedProgress = message.payload.bytesUploaded
if (firstReceivedProgress == null) firstReceivedProgress = message.payload
})
socketClient.onUploadSuccess(uploadToken, (message) => {
try {
expect(message.payload.bytesTotal).toBe(fileContent.length)
expect(firstReceivedProgress.bytesUploaded).toBe(8192)

expect(firstReceivedProgress).toBe(8192)
// see __mocks__/tus-js-client.js
expect(message.payload.url).toBe('https://tus.endpoint/files/foo-bar')
} catch (err) {
Expand Down

0 comments on commit a78679a

Please sign in to comment.