/
index.test-d.ts
92 lines (87 loc) · 2.13 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
80
81
82
83
84
85
86
87
88
89
90
91
92
import { expectType, expectError } from 'tsd'
import Uppy from '@uppy/core'
import Dashboard from '..'
{
const uppy = new Uppy()
uppy.use(Dashboard, {
target: 'body',
})
const plugin = uppy.getPlugin<Dashboard>('Dashboard') ?? ({} as never)
plugin.openModal()
expectType<boolean>(plugin.isModalOpen())
plugin.closeModal()
}
{
const uppy = new Uppy()
uppy.use(Dashboard, {
width: '100%',
height: 700,
metaFields: [
{ id: 'caption', name: 'Caption' },
{
id: 'license',
name: 'License',
placeholder: 'Creative Commons, Apache 2.0, ...',
},
{
id: 'public',
name: 'Public',
render ({ value, onChange }, h) {
expectType<string>(value)
expectType<(val: string) => void>(onChange)
// `h` should be the Preact `h`
expectError(h([], 'error'))
/* Currently `h` typings are limited because of a JSX type conflict between React and Preact.
return h('input', {
type: 'checkbox',
checked: value === 'yes',
onChange: (event) => {
expectType<Event>(event)
onChange((event.target as HTMLInputElement).checked ? 'yes' : 'no')
}
})
*/
},
},
],
onDragOver: (event) => event.clientX,
onDrop: (event) => event.clientX,
onDragLeave: (event) => event.clientX,
})
uppy.on('dashboard:file-edit-state', (file) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const fileName = file?.name
})
}
{
const uppy = new Uppy()
uppy.use(Dashboard, {
locale: {
strings: {
// Dashboard string
addMoreFiles: 'yaddayadda',
// StatusBar string
uploading: '^^^^',
},
},
})
expectError(uppy.use(Dashboard, {
locale: {
strings: {
somethingThatDoesNotExist: 'wrong',
},
},
}))
const wrongType = 1234
expectError(uppy.use(Dashboard, {
locale: {
strings: {
addMoreFiles: wrongType,
},
},
}))
}
{
const uppy = new Uppy()
expectError(uppy.use(Dashboard, { height: {} }))
}