@@ -11,15 +11,16 @@ import { EditorProvider, Theme } from '../src'
11
11
12
12
afterEach ( cleanup )
13
13
14
- if ( global . document ) {
15
- document . createRange = ( ) => ( {
16
- setStart : ( ) => { } ,
17
- setEnd : ( ) => { } ,
18
- commonAncestorContainer : {
19
- nodeName : 'BODY' ,
20
- ownerDocument : document ,
21
- } ,
22
- } )
14
+ if ( ( global as any ) . document ) {
15
+ document . createRange = ( ) =>
16
+ ( ( {
17
+ setStart : ( ) => { } ,
18
+ setEnd : ( ) => { } ,
19
+ commonAncestorContainer : {
20
+ nodeName : 'BODY' ,
21
+ ownerDocument : document ,
22
+ } ,
23
+ } as unknown ) as Range )
23
24
}
24
25
25
26
const theme = {
@@ -53,7 +54,7 @@ test('edits theme.colors', async () => {
53
54
let context
54
55
const GetContext = props => {
55
56
context = useThemeUI ( )
56
- return false
57
+ return null
57
58
}
58
59
const tree = render (
59
60
< EditorProvider theme = { theme } >
@@ -63,26 +64,26 @@ test('edits theme.colors', async () => {
63
64
)
64
65
const swatch = tree . getByText ( 'text' )
65
66
fireEvent . click ( swatch )
66
- const [ input ] = await waitForElement ( ( ) => tree . getAllByPlaceholderText ( 'hex' ) )
67
+ const [ input ] = await waitForElement ( ( ) =>
68
+ tree . getAllByPlaceholderText ( 'hex' )
69
+ )
67
70
fireEvent . change ( input , {
68
71
target : {
69
- value : '#ff0000'
70
- }
72
+ value : '#ff0000' ,
73
+ } ,
71
74
} )
72
75
expect ( context . theme . colors . text ) . toBe ( '#ff0000' )
73
76
} )
74
77
75
78
test ( 'edits theme.colors within a color mode' , async ( ) => {
76
79
let context
77
- const GetContext = props => {
80
+ const GetContext = ( ) => {
78
81
context = useThemeUI ( )
79
- return false
82
+ return null
80
83
}
81
84
const tree = render (
82
- < Context . Provider
83
- value = { {
84
- colorMode : 'dark' ,
85
- } } >
85
+ // TODO: Remove any after @theme -ui/color-mode was transformed to TypeScript
86
+ < Context . Provider value = { { colorMode : 'dark' } as any } >
86
87
< EditorProvider theme = { theme } >
87
88
< Theme . Colors />
88
89
< GetContext />
@@ -91,20 +92,22 @@ test('edits theme.colors within a color mode', async () => {
91
92
)
92
93
const swatch = tree . getByText ( 'text' )
93
94
fireEvent . click ( swatch )
94
- const [ input ] = await waitForElement ( ( ) => tree . getAllByPlaceholderText ( 'hex' ) )
95
+ const [ input ] = await waitForElement ( ( ) =>
96
+ tree . getAllByPlaceholderText ( 'hex' )
97
+ )
95
98
fireEvent . change ( input , {
96
99
target : {
97
- value : '#ff0000'
98
- }
100
+ value : '#ff0000' ,
101
+ } ,
99
102
} )
100
103
expect ( context . theme . colors . modes . dark . text ) . toBe ( '#ff0000' )
101
104
} )
102
105
103
106
test ( 'edits theme.fontSizes' , async ( ) => {
104
107
let context
105
- const GetContext = props => {
108
+ const GetContext = ( ) => {
106
109
context = useThemeUI ( )
107
- return false
110
+ return null
108
111
}
109
112
const tree = render (
110
113
< EditorProvider theme = { theme } >
@@ -115,8 +118,8 @@ test('edits theme.fontSizes', async () => {
115
118
const input = await waitForElement ( ( ) => tree . getByLabelText ( '0' ) )
116
119
fireEvent . change ( input , {
117
120
target : {
118
- value : '11'
119
- }
121
+ value : '11' ,
122
+ } ,
120
123
} )
121
124
expect ( context . theme . fontSizes [ 0 ] ) . toBe ( 11 )
122
125
} )
@@ -125,7 +128,7 @@ test('supports non-array theme.fontSizes objects', async () => {
125
128
let context
126
129
const GetContext = props => {
127
130
context = useThemeUI ( )
128
- return false
131
+ return null
129
132
}
130
133
const tree = render (
131
134
< EditorProvider
@@ -134,7 +137,7 @@ test('supports non-array theme.fontSizes objects', async () => {
134
137
small : 12 ,
135
138
normal : 16 ,
136
139
large : 24 ,
137
- }
140
+ } ,
138
141
} } >
139
142
< Theme . FontSizes />
140
143
< GetContext />
@@ -143,8 +146,8 @@ test('supports non-array theme.fontSizes objects', async () => {
143
146
const input = await waitForElement ( ( ) => tree . getByLabelText ( 'small' ) )
144
147
fireEvent . change ( input , {
145
148
target : {
146
- value : '11'
147
- }
149
+ value : '11' ,
150
+ } ,
148
151
} )
149
152
expect ( context . theme . fontSizes . small ) . toBe ( 11 )
150
153
} )
@@ -153,7 +156,7 @@ test('renders without a theme', () => {
153
156
let context
154
157
const GetContext = props => {
155
158
context = useThemeUI ( )
156
- return false
159
+ return null
157
160
}
158
161
const tree = render (
159
162
< EditorProvider >
@@ -172,7 +175,7 @@ test('edits theme.fontWeights', async () => {
172
175
let context
173
176
const GetContext = props => {
174
177
context = useThemeUI ( )
175
- return false
178
+ return null
176
179
}
177
180
const tree = render (
178
181
< EditorProvider theme = { theme } >
@@ -183,8 +186,8 @@ test('edits theme.fontWeights', async () => {
183
186
const input = await waitForElement ( ( ) => tree . getByLabelText ( 'body' ) )
184
187
fireEvent . change ( input , {
185
188
target : {
186
- value : '500'
187
- }
189
+ value : '500' ,
190
+ } ,
188
191
} )
189
192
expect ( context . theme . fontWeights . body ) . toBe ( '500' )
190
193
} )
@@ -193,7 +196,7 @@ test('edits theme.lineHeights', async () => {
193
196
let context
194
197
const GetContext = props => {
195
198
context = useThemeUI ( )
196
- return false
199
+ return null
197
200
}
198
201
const tree = render (
199
202
< EditorProvider theme = { theme } >
@@ -204,8 +207,8 @@ test('edits theme.lineHeights', async () => {
204
207
const input = await waitForElement ( ( ) => tree . getByLabelText ( 'body' ) )
205
208
fireEvent . change ( input , {
206
209
target : {
207
- value : '1.625'
208
- }
210
+ value : '1.625' ,
211
+ } ,
209
212
} )
210
213
expect ( context . theme . lineHeights . body ) . toBe ( 1.625 )
211
214
} )
@@ -214,7 +217,7 @@ test('edits theme.fonts', async () => {
214
217
let context
215
218
const GetContext = props => {
216
219
context = useThemeUI ( )
217
- return false
220
+ return null
218
221
}
219
222
const tree = render (
220
223
< EditorProvider theme = { theme } >
@@ -225,8 +228,8 @@ test('edits theme.fonts', async () => {
225
228
const input = await waitForElement ( ( ) => tree . getByLabelText ( 'body' ) )
226
229
fireEvent . change ( input , {
227
230
target : {
228
- value : 'Georgia'
229
- }
231
+ value : 'Georgia' ,
232
+ } ,
230
233
} )
231
234
expect ( context . theme . fonts . body ) . toBe ( 'Georgia' )
232
235
expect ( context . theme . fonts . heading ) . toBe ( 'Georgia, serif' )
@@ -236,7 +239,7 @@ test('edits theme.space', async () => {
236
239
let context
237
240
const GetContext = props => {
238
241
context = useThemeUI ( )
239
- return false
242
+ return null
240
243
}
241
244
const tree = render (
242
245
< EditorProvider theme = { theme } >
@@ -247,8 +250,8 @@ test('edits theme.space', async () => {
247
250
const input = await waitForElement ( ( ) => tree . getByLabelText ( '0' ) )
248
251
fireEvent . change ( input , {
249
252
target : {
250
- value : '2'
251
- }
253
+ value : '2' ,
254
+ } ,
252
255
} )
253
256
expect ( context . theme . space [ 0 ] ) . toBe ( 2 )
254
257
expect ( context . theme . space [ 1 ] ) . toBe ( 4 )
@@ -258,7 +261,7 @@ test('supports non-array theme.space objects', async () => {
258
261
let context
259
262
const GetContext = props => {
260
263
context = useThemeUI ( )
261
- return false
264
+ return null
262
265
}
263
266
const tree = render (
264
267
< EditorProvider
@@ -267,7 +270,7 @@ test('supports non-array theme.space objects', async () => {
267
270
small : 4 ,
268
271
normal : 8 ,
269
272
large : 16 ,
270
- }
273
+ } ,
271
274
} } >
272
275
< Theme . Space />
273
276
< GetContext />
@@ -276,9 +279,8 @@ test('supports non-array theme.space objects', async () => {
276
279
const input = await waitForElement ( ( ) => tree . getByLabelText ( 'small' ) )
277
280
fireEvent . change ( input , {
278
281
target : {
279
- value : '3'
280
- }
282
+ value : '3' ,
283
+ } ,
281
284
} )
282
285
expect ( context . theme . space . small ) . toBe ( 3 )
283
286
} )
284
-
0 commit comments