Skip to content

Commit

Permalink
Add another update to both tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Nov 6, 2018
1 parent 37f90fb commit 65091a9
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ describe('ReactLazy', () => {
<LazyClass num={2} />
</Suspense>,
);

expect(root).toFlushAndYield([
'getDerivedStateFromProps: A',
'shouldComponentUpdate: A -> A',
Expand All @@ -373,6 +372,20 @@ describe('ReactLazy', () => {
'componentDidUpdate: A -> A',
]);
expect(root).toMatchRenderedOutput('A2');

root.update(
<Suspense fallback={<Text text="Loading..." />}>
<LazyClass num={3} />
</Suspense>,
);
expect(root).toFlushAndYield([
'getDerivedStateFromProps: A',
'shouldComponentUpdate: A -> A',
'A3',
'getSnapshotBeforeUpdate: A -> A',
'componentDidUpdate: A -> A',
]);
expect(root).toMatchRenderedOutput('A3');
});

it('sets defaultProps for legacy lifecycles', async () => {
Expand Down Expand Up @@ -424,7 +437,6 @@ describe('ReactLazy', () => {
<LazyClass num={2} />
</Suspense>,
);

expect(ReactTestRenderer).toHaveYielded([
'UNSAFE_componentWillMount: A',
'A1',
Expand All @@ -434,6 +446,19 @@ describe('ReactLazy', () => {
]);
expect(root).toFlushAndYield([]);
expect(root).toMatchRenderedOutput('A2');

root.update(
<Suspense fallback={<Text text="Loading..." />}>
<LazyClass num={3} />
</Suspense>,
);
expect(ReactTestRenderer).toHaveYielded([
'UNSAFE_componentWillReceiveProps: A -> A',
'UNSAFE_componentWillUpdate: A -> A',
'A3',
]);
expect(root).toFlushAndYield([]);
expect(root).toMatchRenderedOutput('A3');
});

it('includes lazy-loaded component in warning stack', async () => {
Expand Down

0 comments on commit 65091a9

Please sign in to comment.