@samitouri / QOS-React / commits / ae4fa9ad94

Demonstrate failing test when resuming mount of class component

Andrew Clark committed May 1, 2017 at 15:47 UTC ae4fa9ad9437cc6d48bf448c36ca70b4491e4ef9
1 file changed +41
src/renderers/shared/fiber/__tests__/ReactIncremental-test.js
+41
@@ -452,6 +452,47 @@ describe('ReactIncremental', () => {
452 expect(ops).toEqual(['Foo', 'Bar', 'Bar']);
453 });
454
455 + it('can resume mounting a class component', () => {
456 + let ops = [];
457 + let foo;
458 + class Parent extends React.Component {
459 + shouldComponentUpdate() {
460 + return false;
461 + }
462 + render() {
463 + return <Foo prop={this.props.prop} />;
464 + }
465 + }
466 +
467 + class Foo extends React.Component {
468 + constructor(props) {
469 + super(props);
470 + // Test based on a www bug where props was null on resume
471 + ops.push('Foo constructor: ' + props.prop);
472 + }
473 + render() {
474 + foo = this;
475 + ops.push('Foo');
476 + return <Bar />;
477 + }
478 + }
479 +
480 + function Bar() {
481 + ops.push('Bar');
482 + return <div />;
483 + }
484 +
485 + ReactNoop.render(<Parent prop="foo" />);
486 + ReactNoop.flushDeferredPri(20);
487 + expect(ops).toEqual(['Foo constructor: foo', 'Foo']);
488 +
489 + foo.setState({value: 'bar'});
490 +
491 + ops = [];
492 + ReactNoop.flush();
493 + expect(ops).toEqual(['Foo constructor: foo', 'Foo', 'Bar']);
494 + });
495 +
496 it('can reuse work done after being preempted', () => {
497 var ops = [];
498