diff --git a/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx b/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx index 9411f1d56..abc064bfc 100644 --- a/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx +++ b/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx @@ -28,6 +28,7 @@ import { memo, Profiler, Suspense, + useCallback, } from './_helpers/react-compat'; import { describeIf, @@ -2031,6 +2032,46 @@ describe('shallow', () => { }); }); }); + + // TODO: fix in v16.6 and v16.7 + describeIf(is('>= 16.8'), 'avoids regressing #2200', () => { + const Home = lazy && lazy(() => new Promise(() => {})); + + const PageSwitchFallback = memo ? memo(() =>
) : {}; + PageSwitchFallback.displayName = 'PageSwitchFallback'; + + const PageSwitch = memo && memo(({ pageData }) => { + const renderPageComponent = useCallback ? useCallback(() => { + if (pageData === 'NOT_FOUND') return null; + + switch (pageData.key) { + case 'home': + return ; + default: + return null; + } + }, [pageData]) : () => {}; + + return ( + }> + {renderPageComponent()} + + ); + }); + PageSwitch.displayName = 'PageSwitch'; + + it('works with suspenseFallback: true', () => { + const wrapper = shallow(, { suspenseFallback: true }); + expect(wrapper.find(PageSwitchFallback)).to.have.lengthOf(1); + expect(wrapper.find(Home)).to.have.lengthOf(0); + }); + + it('works with suspenseFallback: false', () => { + const wrapper = shallow(, { suspenseFallback: false }); + expect(wrapper.find(PageSwitchFallback)).to.have.lengthOf(0); + expect(wrapper.find(Home)).to.have.lengthOf(1); + }); + }); }); describe('lifecycle methods', () => {