@samitouri / QOS-React-2 / commits / 3cf67ab859

Harden the tests and fix Flow

Dan Abramov committed Apr 16, 2019 at 17:02 UTC 3cf67ab859b10f7d1f4b5d939ed980ba98a49775
1 file changed +59 -5
src/__tests__/store-test.js
+59 -5
@@ -4,7 +4,7 @@ describe('Store', () => {
4 let React;
5 let ReactDOM;
6 let TestUtils;
7 - // let bridge;
7 + let bridge;
8 let store;
9 let print;
10
@@ -16,7 +16,7 @@ describe('Store', () => {
16 };
17
18 beforeEach(() => {
19 - // bridge = global.bridge;
19 + bridge = global.bridge;
20 store = global.store;
21
22 React = require('react');
@@ -549,6 +549,18 @@ describe('Store', () => {
549 );
550 // Verify the successful transition to steps[j].
551 expect(print(store)).toEqual(snapshots[j]);
552 + // Check that we can transition back again.
553 + act(() =>
554 + ReactDOM.render(
555 + <Root>
556 + <X />
557 + <React.Suspense fallback={z}>{steps[i]}</React.Suspense>
558 + <Y />
559 + </Root>,
560 + container
561 + )
562 + );
563 + expect(print(store)).toEqual(snapshots[i]);
564 // Clean up after every iteration.
565 act(() => ReactDOM.unmountComponentAtNode(container));
566 expect(print(store)).toBe('');
@@ -592,6 +604,22 @@ describe('Store', () => {
604 );
605 // Verify the successful transition to steps[j].
606 expect(print(store)).toEqual(snapshots[j]);
607 + // Check that we can transition back again.
608 + act(() =>
609 + ReactDOM.render(
610 + <Root>
611 + <X />
612 + <React.Suspense fallback={steps[i]}>
613 + <Z />
614 + <Never />
615 + <Z />
616 + </React.Suspense>
617 + <Y />
618 + </Root>,
619 + container
620 + )
621 + );
622 + expect(print(store)).toEqual(snapshots[i]);
623 // Clean up after every iteration.
624 act(() => ReactDOM.unmountComponentAtNode(container));
625 expect(print(store)).toBe('');
@@ -631,6 +659,18 @@ describe('Store', () => {
659 );
660 // Verify the successful transition to steps[j].
661 expect(print(store)).toEqual(snapshots[j]);
662 + // Check that we can transition back again.
663 + act(() =>
664 + ReactDOM.render(
665 + <Root>
666 + <X />
667 + <React.Suspense fallback={z}>{steps[i]}</React.Suspense>
668 + <Y />
669 + </Root>,
670 + container
671 + )
672 + );
673 + expect(print(store)).toEqual(snapshots[i]);
674 // Clean up after every iteration.
675 act(() => ReactDOM.unmountComponentAtNode(container));
676 expect(print(store)).toBe('');
@@ -670,6 +710,22 @@ describe('Store', () => {
710 );
711 // Verify the successful transition to steps[j].
712 expect(print(store)).toEqual(snapshots[j]);
713 + // Check that we can transition back again.
714 + act(() =>
715 + ReactDOM.render(
716 + <Root>
717 + <X />
718 + <React.Suspense fallback={steps[i]}>
719 + <Z />
720 + <Never />
721 + <Z />
722 + </React.Suspense>
723 + <Y />
724 + </Root>,
725 + container
726 + )
727 + );
728 + expect(print(store)).toEqual(snapshots[i]);
729 // Clean up after every iteration.
730 act(() => ReactDOM.unmountComponentAtNode(container));
731 expect(print(store)).toBe('');
@@ -777,8 +833,6 @@ describe('Store', () => {
833 expect(print(store)).toBe('');
834 }
835 }
780 -
781 - // TODO:
782 - // Test Concurrent Mode
836 + // TODO: Test Concurrent Mode
837 });
838 });