UNPKG

1.94 kBPlain TextView Raw
1import { expectType, expectError } from 'tsd'
2import Uppy = require('@uppy/core')
3import Dashboard = require('../')
4
5{
6 const uppy = Uppy<Uppy.StrictTypes>()
7 uppy.use(Dashboard, {
8 target: 'body'
9 })
10
11 const plugin = uppy.getPlugin('Dashboard') as Dashboard
12 plugin.openModal()
13 expectType<boolean>(plugin.isModalOpen())
14 plugin.closeModal()
15}
16
17{
18 const uppy = Uppy<Uppy.StrictTypes>()
19 uppy.use(Dashboard, {
20 width: '100%',
21 height: 700,
22 metaFields: [
23 { id: 'caption', name: 'Caption' },
24 {
25 id: 'license',
26 name: 'License',
27 placeholder: 'Creative Commons, Apache 2.0, ...'
28 },
29 {
30 id: 'public',
31 name: 'Public',
32 render ({ value, onChange }, h) {
33 expectType<string>(value)
34 expectType<(val: string) => void>(onChange)
35 // `h` should be the Preact `h`
36 expectError(h([], 'error'))
37 /* Currently `h` typings are limited because of a JSX type conflict between React and Preact.
38 return h('input', {
39 type: 'checkbox',
40 checked: value === 'yes',
41 onChange: (event) => {
42 expectType<Event>(event)
43 onChange((event.target as HTMLInputElement).checked ? 'yes' : 'no')
44 }
45 })
46 */
47 }
48 }
49 ]
50 })
51}
52
53{
54 const uppy = Uppy<Uppy.StrictTypes>()
55 uppy.use(Dashboard, {
56 locale: {
57 strings: {
58 // Dashboard string
59 addMoreFiles: 'yaddayadda',
60 // StatusBar string
61 uploading: '^^^^'
62 }
63 }
64 })
65 expectError(uppy.use(Dashboard, {
66 locale: {
67 strings: {
68 somethingThatDoesNotExist: 'wrong'
69 }
70 }
71 }))
72 const wrongType = 1234
73 expectError(uppy.use(Dashboard, {
74 locale: {
75 strings: {
76 addMoreFiles: wrongType
77 }
78 }
79 }))
80}
81{
82 const uppy = Uppy<Uppy.StrictTypes>()
83 expectError(uppy.use(Dashboard, { height: {} }))
84}