mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-22 17:58:05 +00:00
Transloadit: Add test for params validation after getAssemblyOptions
This commit is contained in:
parent
a1c0200d89
commit
c58d4338a1
1 changed files with 25 additions and 4 deletions
|
|
@ -5,10 +5,6 @@ import Transloadit from '../../src/plugins/Transloadit'
|
|||
test('Transloadit: Throws errors if options are missing', (t) => {
|
||||
const uppy = new Core()
|
||||
|
||||
t.throws(() => {
|
||||
uppy.use(Transloadit, {})
|
||||
}, /The `params` option is required/)
|
||||
|
||||
t.throws(() => {
|
||||
uppy.use(Transloadit, { params: {} })
|
||||
}, /The `params\.auth\.key` option is required/)
|
||||
|
|
@ -38,3 +34,28 @@ test('Transloadit: Accepts a JSON string as `params` for signature authenticatio
|
|||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Transloadit: Validates response from getAssemblyOptions()', (t) => {
|
||||
const uppy = new Core({ autoProceed: false })
|
||||
|
||||
uppy.use(Transloadit, {
|
||||
getAssemblyOptions: (file) => {
|
||||
t.equal(file.name, 'testfile')
|
||||
return {
|
||||
params: '{"some":"json"}'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const data = Buffer.alloc(4000)
|
||||
data.size = data.byteLength
|
||||
uppy.addFile({
|
||||
name: 'testfile',
|
||||
data
|
||||
}).then(() => {
|
||||
uppy.upload().then(t.fail, (err) => {
|
||||
t.ok(/The `params\.auth\.key` option is required/.test(err.message), 'should reject invalid dynamic params')
|
||||
t.end()
|
||||
})
|
||||
}, t.fail)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue