forked from transloadit/uppy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
35 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,8 @@ | |
}, | ||
"peerDependencies": { | ||
"@uppy/core": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"nock": "^13.1.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,38 @@ | ||
const Core = require('@uppy/core') | ||
const nock = require('nock') | ||
|
||
const Tus = require('.') | ||
|
||
const KB = 1024 | ||
|
||
describe('Tus', () => { | ||
it('Throws errors if autoRetry option is true', () => { | ||
it('Throws errors if autoRetry option is passed', () => { | ||
const uppy = new Core() | ||
const errorMsg = /The `autoRetry` option was deprecated and has been removed/ | ||
|
||
expect(() => { | ||
uppy.use(Tus, { autoRetry: true }) | ||
}).toThrowError(/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) | ||
}) | ||
|
||
it('Throws errors if autoRetry option is false', () => { | ||
it('should do POST request again when retrying', async () => { | ||
const uppy = new Core() | ||
const endpoint = 'https://tusd.tusdemo.net/files/' | ||
const scope = nock(endpoint) | ||
|
||
expect(() => { | ||
uppy.use(Tus, { autoRetry: false }) | ||
}).toThrowError(/The `autoRetry` option was deprecated and has been removed/) | ||
}) | ||
scope.post('/').reply(201) | ||
|
||
it('Throws errors if autoRetry option is `undefined`', () => { | ||
const uppy = new Core() | ||
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)) | ||
|
||
await uppy.upload() | ||
|
||
expect(() => { | ||
uppy.use(Tus, { autoRetry: undefined }) | ||
}).toThrowError(/The `autoRetry` option was deprecated and has been removed/) | ||
scope.done() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters