@@ -152,21 +152,6 @@ describe('ReactCompositeComponent-state', () => {
152
152
root . render ( < TestComponent /> ) ;
153
153
} ) ;
154
154
155
- await act ( ( ) => {
156
- root . render ( < TestComponent nextColor = "green" /> ) ;
157
- } ) ;
158
-
159
- await act ( ( ) => {
160
- testComponentInstance . setFavoriteColor ( 'blue' ) ;
161
- } ) ;
162
- await act ( ( ) => {
163
- testComponentInstance . forceUpdate (
164
- testComponentInstance . peekAtCallback ( 'forceUpdate' ) ,
165
- ) ;
166
- } ) ;
167
-
168
- root . unmount ( ) ;
169
-
170
155
assertLog ( [
171
156
// there is no state when getInitialState() is called
172
157
'getInitialState undefined' ,
@@ -198,6 +183,13 @@ describe('ReactCompositeComponent-state', () => {
198
183
'componentDidUpdate-prevState orange' ,
199
184
'setState-yellow yellow' ,
200
185
'commit yellow' ,
186
+ ] ) ;
187
+
188
+ await act ( ( ) => {
189
+ root . render ( < TestComponent nextColor = "green" /> ) ;
190
+ } ) ;
191
+
192
+ assertLog ( [
201
193
'componentWillReceiveProps-start yellow' ,
202
194
// setState({color:'green'}) only enqueues a pending state.
203
195
'componentWillReceiveProps-end yellow' ,
@@ -216,6 +208,13 @@ describe('ReactCompositeComponent-state', () => {
216
208
'componentDidUpdate-prevState yellow' ,
217
209
'setState-receiveProps green' ,
218
210
'commit green' ,
211
+ ] ) ;
212
+
213
+ await act ( ( ) => {
214
+ testComponentInstance . setFavoriteColor ( 'blue' ) ;
215
+ } ) ;
216
+
217
+ assertLog ( [
219
218
// setFavoriteColor('blue')
220
219
'shouldComponentUpdate-currentState green' ,
221
220
'shouldComponentUpdate-nextState blue' ,
@@ -226,6 +225,13 @@ describe('ReactCompositeComponent-state', () => {
226
225
'componentDidUpdate-prevState green' ,
227
226
'setFavoriteColor blue' ,
228
227
'commit blue' ,
228
+ ] ) ;
229
+ await act ( ( ) => {
230
+ testComponentInstance . forceUpdate (
231
+ testComponentInstance . peekAtCallback ( 'forceUpdate' ) ,
232
+ ) ;
233
+ } ) ;
234
+ assertLog ( [
229
235
// forceUpdate()
230
236
'componentWillUpdate-currentState blue' ,
231
237
'componentWillUpdate-nextState blue' ,
@@ -234,7 +240,12 @@ describe('ReactCompositeComponent-state', () => {
234
240
'componentDidUpdate-prevState blue' ,
235
241
'forceUpdate blue' ,
236
242
'commit blue' ,
237
- // unmountComponent()
243
+ ] ) ;
244
+
245
+ root . unmount ( ) ;
246
+
247
+ assertLog ( [
248
+ // unmount()
238
249
// state is available within `componentWillUnmount()`
239
250
'componentWillUnmount blue' ,
240
251
] ) ;
@@ -375,13 +386,13 @@ describe('ReactCompositeComponent-state', () => {
375
386
await act ( ( ) => {
376
387
root . render ( < Parent /> ) ;
377
388
} ) ;
389
+
390
+ assertLog ( [ 'parent render one' , 'child render one' ] ) ;
378
391
await act ( ( ) => {
379
392
root . render ( < Parent /> ) ;
380
393
} ) ;
381
394
382
395
assertLog ( [
383
- 'parent render one' ,
384
- 'child render one' ,
385
396
'parent render one' ,
386
397
'child componentWillReceiveProps one' ,
387
398
'child componentWillReceiveProps done one' ,
0 commit comments