File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -24,25 +24,23 @@ export async function clear(this: UserEventInstance, element: ReactTestInstance)
24
24
dispatchEvent ( element , 'focus' , EventBuilder . Common . focus ( ) ) ;
25
25
26
26
// 2. Select all
27
- const previousText = element . props . value ?? element . props . defaultValue ?? '' ;
27
+ const textToClear = element . props . value ?? element . props . defaultValue ?? '' ;
28
28
const selectionRange = {
29
29
start : 0 ,
30
- end : previousText . length ,
30
+ end : textToClear . length ,
31
31
} ;
32
32
dispatchEvent ( element , 'selectionChange' , EventBuilder . TextInput . selectionChange ( selectionRange ) ) ;
33
33
34
34
// 3. Press backspace with selected text
35
- const finalText = '' ;
35
+ const textAfterClear = '' ;
36
36
await emitTypingEvents ( element , {
37
37
config : this . config ,
38
38
key : 'Backspace' ,
39
- text : finalText ,
40
- previousText,
39
+ text : textAfterClear ,
41
40
} ) ;
42
41
43
42
// 4. Exit element
44
43
await wait ( this . config ) ;
45
- dispatchEvent ( element , 'endEditing' , EventBuilder . TextInput . endEditing ( finalText ) ) ;
46
-
44
+ dispatchEvent ( element , 'endEditing' , EventBuilder . TextInput . endEditing ( textAfterClear ) ) ;
47
45
dispatchEvent ( element , 'blur' , EventBuilder . Common . blur ( ) ) ;
48
46
}
You can’t perform that action at this time.
0 commit comments