@@ -8,29 +8,30 @@ import {
8
8
getActiveElement ,
9
9
calculateNewValue ,
10
10
setSelectionRangeIfNecessary ,
11
- wrapInEventWrapper ,
12
11
} from './utils'
13
12
import { click } from './click'
14
13
15
14
function wait ( time ) {
16
15
return new Promise ( resolve => setTimeout ( ( ) => resolve ( ) , time ) )
17
16
}
18
17
19
- // this needs to be wrapped in the asyncWrapper for React's act and angular's change detection
20
- // but only if it's actually going to be async.
18
+ // this needs to be wrapped in the event/ asyncWrapper for React's act and angular's change detection
19
+ // depending on whether it will be async.
21
20
async function type ( element , text , { delay = 0 , ...options } = { } ) {
22
21
// we do not want to wrap in the asyncWrapper if we're not
23
22
// going to actually be doing anything async, so we only wrap
24
23
// if the delay is greater than 0
24
+ let result
25
25
if ( delay > 0 ) {
26
- let result
27
26
await getDOMTestingLibraryConfig ( ) . asyncWrapper ( async ( ) => {
28
27
result = await typeImpl ( element , text , { delay, ...options } )
29
28
} )
30
- return result
31
29
} else {
32
- return typeImpl ( element , text , { delay, ...options } )
30
+ getDOMTestingLibraryConfig ( ) . eventWrapper ( ( ) => {
31
+ result = typeImpl ( element , text , { delay, ...options } )
32
+ } )
33
33
}
34
+ return result
34
35
}
35
36
36
37
async function typeImpl (
@@ -530,7 +531,6 @@ function getEventCallbackMap({
530
531
}
531
532
}
532
533
}
533
- type = wrapInEventWrapper ( type )
534
534
535
535
export { type }
536
536
0 commit comments