/
index.test-d.ts
79 lines (73 loc) · 1.84 KB
/
index.test-d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { expectError, expectType } from 'tsd'
import Uppy from '@uppy/core'
import type { UppyFile } from '@uppy/core'
import Transloadit, { COMPANION_ALLOWED_HOSTS, COMPANION_URL } from '..'
expectType<string>(Transloadit.COMPANION)
expectType<string>(COMPANION_URL)
expectType<RegExp>(Transloadit.COMPANION_PATTERN)
expectType<RegExp>(COMPANION_ALLOWED_HOSTS)
const validParams = {
auth: { key: 'not so secret key' },
}
{
const uppy = new Uppy()
uppy.use(Transloadit, {
getAssemblyOptions (file) {
expectType<UppyFile>(file)
return { params: validParams }
},
waitForEncoding: false,
waitForMetadata: true,
importFromUploadURLs: false,
params: {
auth: { key: 'abc' },
steps: {},
},
})
// Access to both transloadit events and core events
uppy.on('transloadit:assembly-created', (assembly) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const status = assembly.ok
})
uppy.on('complete', (result) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const success = result.successful
})
}
{
const uppy = new Uppy()
// must be bools
expectError(
uppy.use(Transloadit, { waitForEncoding: null, params: validParams }),
)
expectError(
uppy.use(Transloadit, { waitForMetadata: null, params: validParams }),
)
}
{
const uppy = new Uppy()
// params.auth.key must be string
expectError(uppy.use(Transloadit, { params: {} }))
expectError(uppy.use(Transloadit, { params: { auth: {} } }))
expectError(
uppy.use(Transloadit, {
params: {
auth: { key: null },
},
}),
)
expectError(
uppy.use(Transloadit, {
params: {
auth: { key: 'abc' },
steps: 'test',
},
}),
)
uppy.use(Transloadit, {
params: {
auth: { key: 'abc' },
steps: { name: {} },
},
})
}