@@ -29,12 +29,13 @@ test('change file input', async () => {
29
29
input[value=""] - pointerup
30
30
input[value=""] - mouseup: primary
31
31
input[value=""] - click: primary
32
+ "{CURSOR}" -> "C:\\\\fakepath\\\\hello.png{CURSOR}C:\\\\fakepath\\\\hello.png"
32
33
input[value=""] - blur
33
34
input[value=""] - focusout
34
- input[value=""] - focus
35
- input[value=""] - focusin
36
35
input[value="C:\\\\fakepath\\\\hello.png"] - input
37
36
input[value="C:\\\\fakepath\\\\hello.png"] - change
37
+ input[value="C:\\\\fakepath\\\\hello.png"] - focus
38
+ input[value="C:\\\\fakepath\\\\hello.png"] - focusin
38
39
` )
39
40
} )
40
41
@@ -63,15 +64,32 @@ test('relay click/upload on label to file input', async () => {
63
64
label[for="element"] - pointerup
64
65
label[for="element"] - mouseup: primary
65
66
label[for="element"] - click: primary
66
- input#element[value=""] - click: primary
67
67
input#element[value=""] - focusin
68
+ input#element[value=""] - click: primary
68
69
input#element[value=""] - focusout
69
- input#element[value=""] - focusin
70
70
input#element[value="C:\\\\fakepath\\\\hello.png"] - input
71
71
input#element[value="C:\\\\fakepath\\\\hello.png"] - change
72
+ input#element[value="C:\\\\fakepath\\\\hello.png"] - focusin
72
73
` )
73
74
} )
74
75
76
+ test ( 'prevent file dialog per click event handler' , async ( ) => {
77
+ const file = new File ( [ 'hello' ] , 'hello.png' , { type : 'image/png' } )
78
+
79
+ const {
80
+ elements : [ label , input ] ,
81
+ eventWasFired,
82
+ } = setup < [ HTMLLabelElement ] > ( `
83
+ <label for="element">Element</label>
84
+ <input type="file" id="element" />
85
+ ` )
86
+ input . addEventListener ( 'click' , e => e . preventDefault ( ) )
87
+
88
+ await userEvent . upload ( label , file )
89
+
90
+ expect ( eventWasFired ( 'input' ) ) . toBe ( false )
91
+ } )
92
+
75
93
test ( 'upload multiple files' , async ( ) => {
76
94
const files = [
77
95
new File ( [ 'hello' ] , 'hello.png' , { type : 'image/png' } ) ,
0 commit comments