@@ -119,6 +119,18 @@ const eventTypes = [
119
119
elementType : 'div' ,
120
120
} ,
121
121
]
122
+
123
+ const mockFile = ( {
124
+ name,
125
+ size = 0 ,
126
+ type = 'text/plain' ,
127
+ lastModified = new Date ( )
128
+ } ) => {
129
+ const blob = new Blob ( [ '0' . repeat ( size ) ] , { type } ) ;
130
+ blob . lastModifiedDate = lastModified ;
131
+ return new File ( [ blob ] , name ) ;
132
+ } ;
133
+
122
134
beforeEach ( ( ) => {
123
135
jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } )
124
136
} )
@@ -215,6 +227,25 @@ test('fireEvent.update does not trigger warning messages', async () => {
215
227
expect ( console . warn ) . not . toHaveBeenCalled ( )
216
228
} )
217
229
230
+ test ( 'fireEvent.update should not crash with input file' , async ( ) => {
231
+ const inputSpy = jest . fn ( ) ;
232
+ const changeSpy = jest . fn ( ) ;
233
+
234
+ const { getByTestId} = render ( {
235
+ template : `<input type="file" @change="$emit('change', $event)" @input="$emit('input, $event)" data-testid=test-update></input>` ,
236
+ } , {
237
+ on : {
238
+ input : inputSpy ,
239
+ change : changeSpy
240
+ }
241
+ } )
242
+
243
+ // should expect a array of list since it's a fileList
244
+ await fireEvent . update ( getByTestId ( 'test-update' ) , [ mockFile ( { name : 'random.txt' , size : 524288 } ) ] )
245
+
246
+ expect ( console . warn ) . not . toHaveBeenCalled ( )
247
+ } )
248
+
218
249
test ( 'fireEvent.update does not crash if non-input element is passed in' , async ( ) => {
219
250
const { getByText} = render ( {
220
251
template : `<div>Hi</div>` ,
0 commit comments