Skip to content

Commit

Permalink
Revert "WIP"
Browse files Browse the repository at this point in the history
This reverts commit e8f3198.
  • Loading branch information
Murderlon committed Oct 27, 2021
1 parent e8f3198 commit 84e11ff
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 35 deletions.
5 changes: 0 additions & 5 deletions packages/@uppy/companion/src/server/Uploader.js
Expand Up @@ -437,11 +437,6 @@ class Uploader {
* start the tus upload
*/
uploadTus () {
if (!this.failed) {
this.failed = true
setTimeout(() => this.emitError(new Error('test')), 1000)
return
}
const file = fs.createReadStream(this.path)
const uploader = this

Expand Down
3 changes: 0 additions & 3 deletions packages/@uppy/tus/package.json
Expand Up @@ -28,8 +28,5 @@
},
"peerDependencies": {
"@uppy/core": "^2.0.0"
},
"devDependencies": {
"nock": "^13.1.4"
}
}
2 changes: 1 addition & 1 deletion packages/@uppy/tus/src/index.js
Expand Up @@ -366,7 +366,7 @@ module.exports = class Tus extends BasePlugin {
this.uppy.emit('upload-started', file)
this.uppy.log(file.remote.url)

if (file.serverToken && file.response) {
if (file.serverToken) {
return this.connectToServerSocket(file)
}

Expand Down
38 changes: 14 additions & 24 deletions packages/@uppy/tus/src/index.test.js
@@ -1,38 +1,28 @@
const Core = require('@uppy/core')
const nock = require('nock')

const Tus = require('.')

const KB = 1024

describe('Tus', () => {
it('Throws errors if autoRetry option is passed', () => {
it('Throws errors if autoRetry option is true', () => {
const uppy = new Core()
const errorMsg = /The `autoRetry` option was deprecated and has been removed/

expect(() => uppy.use(Tus, { autoRetry: true })).toThrowError(errorMsg)
expect(() => uppy.use(Tus, { autoRetry: false })).toThrowError(errorMsg)
expect(() => uppy.use(Tus, { autoRetry: undefined })).toThrowError(errorMsg)
expect(() => {
uppy.use(Tus, { autoRetry: true })
}).toThrowError(/The `autoRetry` option was deprecated and has been removed/)
})

it('should do POST request again when retrying', async () => {
it('Throws errors if autoRetry option is false', () => {
const uppy = new Core()
const endpoint = 'https://tusd.tusdemo.net/files/'
const scope = nock(endpoint)

scope.post('/').reply(201)

uppy.use(Tus, { endpoint })
uppy.addFile({
source: 'jest',
name: 'foo1.jpg',
type: 'image/jpeg',
data: new File([Buffer.alloc(KB)], { type: 'image/jpeg' }),
})
uppy.on('complete', (result) => expect(result.successful.length).toEqual(1))
expect(() => {
uppy.use(Tus, { autoRetry: false })
}).toThrowError(/The `autoRetry` option was deprecated and has been removed/)
})

await uppy.upload()
it('Throws errors if autoRetry option is `undefined`', () => {
const uppy = new Core()

scope.done()
expect(() => {
uppy.use(Tus, { autoRetry: undefined })
}).toThrowError(/The `autoRetry` option was deprecated and has been removed/)
})
})
3 changes: 1 addition & 2 deletions yarn.lock
Expand Up @@ -9557,7 +9557,6 @@ __metadata:
dependencies:
"@uppy/companion-client": "workspace:*"
"@uppy/utils": "workspace:*"
nock: ^13.1.4
tus-js-client: ^2.1.1
peerDependencies:
"@uppy/core": ^2.0.0
Expand Down Expand Up @@ -30411,7 +30410,7 @@ hexo-filter-github-emojis@arturi/hexo-filter-github-emojis:
languageName: node
linkType: hard

"nock@npm:^13.1.0, nock@npm:^13.1.4":
"nock@npm:^13.1.0":
version: 13.1.4
resolution: "nock@npm:13.1.4"
dependencies:
Expand Down

0 comments on commit 84e11ff

Please sign in to comment.