Skip to content

Commit 8161fa2

Browse files
authored
fix(type): correct wrapping (testing-library#388)
Closes testing-library#387
1 parent 8889776 commit 8161fa2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/type.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,30 @@ import {
88
getActiveElement,
99
calculateNewValue,
1010
setSelectionRangeIfNecessary,
11-
wrapInEventWrapper,
1211
} from './utils'
1312
import {click} from './click'
1413

1514
function wait(time) {
1615
return new Promise(resolve => setTimeout(() => resolve(), time))
1716
}
1817

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.
2120
async function type(element, text, {delay = 0, ...options} = {}) {
2221
// we do not want to wrap in the asyncWrapper if we're not
2322
// going to actually be doing anything async, so we only wrap
2423
// if the delay is greater than 0
24+
let result
2525
if (delay > 0) {
26-
let result
2726
await getDOMTestingLibraryConfig().asyncWrapper(async () => {
2827
result = await typeImpl(element, text, {delay, ...options})
2928
})
30-
return result
3129
} else {
32-
return typeImpl(element, text, {delay, ...options})
30+
getDOMTestingLibraryConfig().eventWrapper(() => {
31+
result = typeImpl(element, text, {delay, ...options})
32+
})
3333
}
34+
return result
3435
}
3536

3637
async function typeImpl(
@@ -530,7 +531,6 @@ function getEventCallbackMap({
530531
}
531532
}
532533
}
533-
type = wrapInEventWrapper(type)
534534

535535
export {type}
536536

0 commit comments

Comments
 (0)