@@ -2520,7 +2520,7 @@ describe('DOMPluginEventSystem', () => {
2520
2520
} ) ;
2521
2521
2522
2522
// @gate www
2523
- it ( 'beforeblur and afterblur are called after a focused element is suspended' , ( ) => {
2523
+ it ( 'beforeblur and afterblur are called after a focused element is suspended' , async ( ) => {
2524
2524
const log = [ ] ;
2525
2525
// We have to persist here because we want to read relatedTarget later.
2526
2526
const onAfterBlur = jest . fn ( e => {
@@ -2575,7 +2575,7 @@ describe('DOMPluginEventSystem', () => {
2575
2575
2576
2576
const root = ReactDOMClient . createRoot ( container2 ) ;
2577
2577
2578
- act ( ( ) => {
2578
+ await act ( async ( ) => {
2579
2579
root . render ( < Component /> ) ;
2580
2580
} ) ;
2581
2581
jest . runAllTimers ( ) ;
@@ -2587,7 +2587,7 @@ describe('DOMPluginEventSystem', () => {
2587
2587
expect ( onAfterBlur ) . toHaveBeenCalledTimes ( 0 ) ;
2588
2588
2589
2589
suspend = true ;
2590
- act ( ( ) => {
2590
+ await act ( async ( ) => {
2591
2591
root . render ( < Component /> ) ;
2592
2592
} ) ;
2593
2593
jest . runAllTimers ( ) ;
@@ -2604,7 +2604,7 @@ describe('DOMPluginEventSystem', () => {
2604
2604
} ) ;
2605
2605
2606
2606
// @gate www
2607
- it ( 'beforeblur should skip handlers from a deleted subtree after the focused element is suspended' , ( ) => {
2607
+ it ( 'beforeblur should skip handlers from a deleted subtree after the focused element is suspended' , async ( ) => {
2608
2608
const onBeforeBlur = jest . fn ( ) ;
2609
2609
const innerRef = React . createRef ( ) ;
2610
2610
const innerRef2 = React . createRef ( ) ;
@@ -2661,7 +2661,7 @@ describe('DOMPluginEventSystem', () => {
2661
2661
2662
2662
const root = ReactDOMClient . createRoot ( container2 ) ;
2663
2663
2664
- act ( ( ) => {
2664
+ await act ( async ( ) => {
2665
2665
root . render ( < Component /> ) ;
2666
2666
} ) ;
2667
2667
jest . runAllTimers ( ) ;
@@ -2672,7 +2672,7 @@ describe('DOMPluginEventSystem', () => {
2672
2672
expect ( onBeforeBlur ) . toHaveBeenCalledTimes ( 0 ) ;
2673
2673
2674
2674
suspend = true ;
2675
- act ( ( ) => {
2675
+ await act ( async ( ) => {
2676
2676
root . render ( < Component /> ) ;
2677
2677
} ) ;
2678
2678
jest . runAllTimers ( ) ;
@@ -2684,17 +2684,17 @@ describe('DOMPluginEventSystem', () => {
2684
2684
} ) ;
2685
2685
2686
2686
// @gate www
2687
- it ( 'regression: does not fire beforeblur/afterblur if target is already hidden' , ( ) => {
2687
+ it ( 'regression: does not fire beforeblur/afterblur if target is already hidden' , async ( ) => {
2688
2688
const Suspense = React . Suspense ;
2689
2689
let suspend = false ;
2690
- const promise = Promise . resolve ( ) ;
2690
+ const fakePromise = { then ( ) { } } ;
2691
2691
const setBeforeBlurHandle =
2692
2692
ReactDOM . unstable_createEventHandle ( 'beforeblur' ) ;
2693
2693
const innerRef = React . createRef ( ) ;
2694
2694
2695
2695
function Child ( ) {
2696
2696
if ( suspend ) {
2697
- throw promise ;
2697
+ throw fakePromise ;
2698
2698
}
2699
2699
return < input ref = { innerRef } /> ;
2700
2700
}
@@ -2726,7 +2726,7 @@ describe('DOMPluginEventSystem', () => {
2726
2726
document . body . appendChild ( container2 ) ;
2727
2727
2728
2728
const root = ReactDOMClient . createRoot ( container2 ) ;
2729
- act ( ( ) => {
2729
+ await act ( async ( ) => {
2730
2730
root . render ( < Component /> ) ;
2731
2731
} ) ;
2732
2732
@@ -2737,7 +2737,7 @@ describe('DOMPluginEventSystem', () => {
2737
2737
2738
2738
// Suspend. This hides the input node, causing it to lose focus.
2739
2739
suspend = true ;
2740
- act ( ( ) => {
2740
+ await act ( async ( ) => {
2741
2741
root . render ( < Component /> ) ;
2742
2742
} ) ;
2743
2743
0 commit comments