1 | import { expectType, expectError } from 'tsd'
|
2 | import Uppy = require('@uppy/core')
|
3 | import 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 |
|
36 | expectError(h([], 'error'))
|
37 | |
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
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 |
|
59 | addMoreFiles: 'yaddayadda',
|
60 |
|
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 | }
|