@@ -152,21 +152,6 @@ describe('ReactCompositeComponent-state', () => {
152152 root . render ( < TestComponent /> ) ;
153153 } ) ;
154154
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-
170155 assertLog ( [
171156 // there is no state when getInitialState() is called
172157 'getInitialState undefined' ,
@@ -198,6 +183,13 @@ describe('ReactCompositeComponent-state', () => {
198183 'componentDidUpdate-prevState orange' ,
199184 'setState-yellow yellow' ,
200185 'commit yellow' ,
186+ ] ) ;
187+
188+ await act ( ( ) => {
189+ root . render ( < TestComponent nextColor = "green" /> ) ;
190+ } ) ;
191+
192+ assertLog ( [
201193 'componentWillReceiveProps-start yellow' ,
202194 // setState({color:'green'}) only enqueues a pending state.
203195 'componentWillReceiveProps-end yellow' ,
@@ -216,6 +208,13 @@ describe('ReactCompositeComponent-state', () => {
216208 'componentDidUpdate-prevState yellow' ,
217209 'setState-receiveProps green' ,
218210 'commit green' ,
211+ ] ) ;
212+
213+ await act ( ( ) => {
214+ testComponentInstance . setFavoriteColor ( 'blue' ) ;
215+ } ) ;
216+
217+ assertLog ( [
219218 // setFavoriteColor('blue')
220219 'shouldComponentUpdate-currentState green' ,
221220 'shouldComponentUpdate-nextState blue' ,
@@ -226,6 +225,13 @@ describe('ReactCompositeComponent-state', () => {
226225 'componentDidUpdate-prevState green' ,
227226 'setFavoriteColor blue' ,
228227 'commit blue' ,
228+ ] ) ;
229+ await act ( ( ) => {
230+ testComponentInstance . forceUpdate (
231+ testComponentInstance . peekAtCallback ( 'forceUpdate' ) ,
232+ ) ;
233+ } ) ;
234+ assertLog ( [
229235 // forceUpdate()
230236 'componentWillUpdate-currentState blue' ,
231237 'componentWillUpdate-nextState blue' ,
@@ -234,7 +240,12 @@ describe('ReactCompositeComponent-state', () => {
234240 'componentDidUpdate-prevState blue' ,
235241 'forceUpdate blue' ,
236242 'commit blue' ,
237- // unmountComponent()
243+ ] ) ;
244+
245+ root . unmount ( ) ;
246+
247+ assertLog ( [
248+ // unmount()
238249 // state is available within `componentWillUnmount()`
239250 'componentWillUnmount blue' ,
240251 ] ) ;
@@ -375,13 +386,13 @@ describe('ReactCompositeComponent-state', () => {
375386 await act ( ( ) => {
376387 root . render ( < Parent /> ) ;
377388 } ) ;
389+
390+ assertLog ( [ 'parent render one' , 'child render one' ] ) ;
378391 await act ( ( ) => {
379392 root . render ( < Parent /> ) ;
380393 } ) ;
381394
382395 assertLog ( [
383- 'parent render one' ,
384- 'child render one' ,
385396 'parent render one' ,
386397 'child componentWillReceiveProps one' ,
387398 'child componentWillReceiveProps done one' ,
0 commit comments