@@ -244,10 +244,11 @@ describe('ReactCompositeComponent', () => {
244244 ReactDOM . unmountComponentAtNode ( container ) ;
245245
246246 expect ( ( ) => instance . forceUpdate ( ) ) . toWarnDev (
247- 'Can only update a mounted or mounting component. This usually means ' +
248- 'you called setState, replaceState, or forceUpdate on an unmounted ' +
249- 'component. This is a no-op.\n\nPlease check the code for the ' +
250- 'Component component.' ,
247+ "Warning: Can't call setState (or forceUpdate) on an unmounted " +
248+ 'component. This is a no-op, but it indicates a memory leak in your ' +
249+ 'application. To fix, cancel all subscriptions and asynchronous ' +
250+ 'tasks in the componentWillUnmount method.\n' +
251+ ' in Component (at **)' ,
251252 ) ;
252253
253254 // No additional warning should be recorded
@@ -269,26 +270,33 @@ describe('ReactCompositeComponent', () => {
269270 }
270271 }
271272
272- let instance = < Component /> ;
273- expect ( instance . setState ) . not . toBeDefined ( ) ;
274-
275- instance = ReactDOM . render ( instance , container ) ;
273+ let instance ;
274+ ReactDOM . render (
275+ < div >
276+ < span >
277+ < Component ref = { c => ( instance = c || instance ) } />
278+ </ span >
279+ </ div > ,
280+ container ,
281+ ) ;
276282
277283 expect ( renders ) . toBe ( 1 ) ;
278284
279285 instance . setState ( { value : 1 } ) ;
280286
281287 expect ( renders ) . toBe ( 2 ) ;
282288
283- ReactDOM . unmountComponentAtNode ( container ) ;
289+ ReactDOM . render ( < div /> , container ) ;
284290
285291 expect ( ( ) => {
286292 instance . setState ( { value : 2 } ) ;
287293 } ) . toWarnDev (
288- 'Can only update a mounted or mounting component. This usually means ' +
289- 'you called setState, replaceState, or forceUpdate on an unmounted ' +
290- 'component. This is a no-op.\n\nPlease check the code for the ' +
291- 'Component component.' ,
294+ "Warning: Can't call setState (or forceUpdate) on an unmounted " +
295+ 'component. This is a no-op, but it indicates a memory leak in your ' +
296+ 'application. To fix, cancel all subscriptions and asynchronous ' +
297+ 'tasks in the componentWillUnmount method.\n' +
298+ ' in Component (at **)\n' +
299+ ' in span' ,
292300 ) ;
293301
294302 expect ( renders ) . toBe ( 2 ) ;
0 commit comments