@@ -26,7 +26,7 @@ describe('ReactHooksInspectionIntegration', () => {
26
26
ReactDebugTools = require ( 'react-debug-tools' ) ;
27
27
} ) ;
28
28
29
- it ( 'should inspect the current state of useState hooks' , ( ) => {
29
+ it ( 'should inspect the current state of useState hooks' , async ( ) => {
30
30
const useState = React . useState ;
31
31
function Foo ( props ) {
32
32
const [ state1 , setState1 ] = useState ( 'hello' ) ;
@@ -61,7 +61,7 @@ describe('ReactHooksInspectionIntegration', () => {
61
61
const { onMouseDown : setStateA , onMouseUp : setStateB } =
62
62
renderer . root . findByType ( 'div' ) . props ;
63
63
64
- act ( ( ) => setStateA ( 'Hi' ) ) ;
64
+ await act ( async ( ) => setStateA ( 'Hi' ) ) ;
65
65
66
66
childFiber = renderer . root . findByType ( Foo ) . _currentFiber ( ) ;
67
67
tree = ReactDebugTools . inspectHooksOfFiber ( childFiber ) ;
@@ -83,7 +83,7 @@ describe('ReactHooksInspectionIntegration', () => {
83
83
} ,
84
84
] ) ;
85
85
86
- act ( ( ) => setStateB ( 'world!' ) ) ;
86
+ await act ( async ( ) => setStateB ( 'world!' ) ) ;
87
87
88
88
childFiber = renderer . root . findByType ( Foo ) . _currentFiber ( ) ;
89
89
tree = ReactDebugTools . inspectHooksOfFiber ( childFiber ) ;
@@ -106,7 +106,7 @@ describe('ReactHooksInspectionIntegration', () => {
106
106
] ) ;
107
107
} ) ;
108
108
109
- it ( 'should inspect the current state of all stateful hooks' , ( ) => {
109
+ it ( 'should inspect the current state of all stateful hooks' , async ( ) => {
110
110
const outsideRef = React . createRef ( ) ;
111
111
function effect ( ) { }
112
112
function Foo ( props ) {
@@ -129,12 +129,8 @@ describe('ReactHooksInspectionIntegration', () => {
129
129
React . useMemo ( ( ) => state1 + state2 , [ state1 ] ) ;
130
130
131
131
function update ( ) {
132
- act ( ( ) => {
133
- setState ( 'A' ) ;
134
- } ) ;
135
- act ( ( ) => {
136
- dispatch ( { value : 'B' } ) ;
137
- } ) ;
132
+ setState ( 'A' ) ;
133
+ dispatch ( { value : 'B' } ) ;
138
134
ref . current = 'C' ;
139
135
}
140
136
const memoizedUpdate = React . useCallback ( update , [ ] ) ;
@@ -145,7 +141,7 @@ describe('ReactHooksInspectionIntegration', () => {
145
141
) ;
146
142
}
147
143
let renderer ;
148
- act ( ( ) => {
144
+ await act ( async ( ) => {
149
145
renderer = ReactTestRenderer . create ( < Foo prop = "prop" /> ) ;
150
146
} ) ;
151
147
@@ -207,7 +203,9 @@ describe('ReactHooksInspectionIntegration', () => {
207
203
} ,
208
204
] ) ;
209
205
210
- updateStates ( ) ;
206
+ await act ( async ( ) => {
207
+ updateStates ( ) ;
208
+ } ) ;
211
209
212
210
childFiber = renderer . root . findByType ( Foo ) . _currentFiber ( ) ;
213
211
tree = ReactDebugTools . inspectHooksOfFiber ( childFiber ) ;
@@ -266,7 +264,7 @@ describe('ReactHooksInspectionIntegration', () => {
266
264
] ) ;
267
265
} ) ;
268
266
269
- it ( 'should inspect the current state of all stateful hooks, including useInsertionEffect' , ( ) => {
267
+ it ( 'should inspect the current state of all stateful hooks, including useInsertionEffect' , async ( ) => {
270
268
const useInsertionEffect = React . useInsertionEffect ;
271
269
const outsideRef = React . createRef ( ) ;
272
270
function effect ( ) { }
@@ -290,13 +288,9 @@ describe('ReactHooksInspectionIntegration', () => {
290
288
291
289
React . useMemo ( ( ) => state1 + state2 , [ state1 ] ) ;
292
290
293
- function update ( ) {
294
- act ( ( ) => {
295
- setState ( 'A' ) ;
296
- } ) ;
297
- act ( ( ) => {
298
- dispatch ( { value : 'B' } ) ;
299
- } ) ;
291
+ async function update ( ) {
292
+ setState ( 'A' ) ;
293
+ dispatch ( { value : 'B' } ) ;
300
294
ref . current = 'C' ;
301
295
}
302
296
const memoizedUpdate = React . useCallback ( update , [ ] ) ;
@@ -307,7 +301,7 @@ describe('ReactHooksInspectionIntegration', () => {
307
301
) ;
308
302
}
309
303
let renderer ;
310
- act ( ( ) => {
304
+ await act ( async ( ) => {
311
305
renderer = ReactTestRenderer . create ( < Foo prop = "prop" /> ) ;
312
306
} ) ;
313
307
@@ -376,7 +370,9 @@ describe('ReactHooksInspectionIntegration', () => {
376
370
} ,
377
371
] ) ;
378
372
379
- updateStates ( ) ;
373
+ await act ( async ( ) => {
374
+ updateStates ( ) ;
375
+ } ) ;
380
376
381
377
childFiber = renderer . root . findByType ( Foo ) . _currentFiber ( ) ;
382
378
tree = ReactDebugTools . inspectHooksOfFiber ( childFiber ) ;
@@ -967,7 +963,7 @@ describe('ReactHooksInspectionIntegration', () => {
967
963
968
964
// This test case is based on an open source bug report:
969
965
// https://github.com/facebookincubator/redux-react-hook/issues/34#issuecomment-466693787
970
- it ( 'should properly advance the current hook for useContext' , ( ) => {
966
+ it ( 'should properly advance the current hook for useContext' , async ( ) => {
971
967
const MyContext = React . createContext ( 1 ) ;
972
968
973
969
let incrementCount ;
0 commit comments