From 8161fa26a419860efe8336a2d847d6c0a45184cd Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Thu, 25 Jun 2020 14:03:23 -0600 Subject: [PATCH] fix(type): correct wrapping (#388) Closes #387 --- src/type.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/type.js b/src/type.js index 0bee11ed..dac1343e 100644 --- a/src/type.js +++ b/src/type.js @@ -8,7 +8,6 @@ import { getActiveElement, calculateNewValue, setSelectionRangeIfNecessary, - wrapInEventWrapper, } from './utils' import {click} from './click' @@ -16,21 +15,23 @@ function wait(time) { return new Promise(resolve => setTimeout(() => resolve(), time)) } -// this needs to be wrapped in the asyncWrapper for React's act and angular's change detection -// but only if it's actually going to be async. +// this needs to be wrapped in the event/asyncWrapper for React's act and angular's change detection +// depending on whether it will be async. async function type(element, text, {delay = 0, ...options} = {}) { // we do not want to wrap in the asyncWrapper if we're not // going to actually be doing anything async, so we only wrap // if the delay is greater than 0 + let result if (delay > 0) { - let result await getDOMTestingLibraryConfig().asyncWrapper(async () => { result = await typeImpl(element, text, {delay, ...options}) }) - return result } else { - return typeImpl(element, text, {delay, ...options}) + getDOMTestingLibraryConfig().eventWrapper(() => { + result = typeImpl(element, text, {delay, ...options}) + }) } + return result } async function typeImpl( @@ -530,7 +531,6 @@ function getEventCallbackMap({ } } } -type = wrapInEventWrapper(type) export {type}