diff --git a/packages/enzyme-test-suite/test/shared/methods/debug.jsx b/packages/enzyme-test-suite/test/shared/methods/debug.jsx index 9bcd1281a..7b126463b 100644 --- a/packages/enzyme-test-suite/test/shared/methods/debug.jsx +++ b/packages/enzyme-test-suite/test/shared/methods/debug.jsx @@ -12,6 +12,7 @@ import { is } from '../../_helpers/version'; import { createClass, memo, + useCallback, } from '../../_helpers/react-compat'; export default function describeDebug({ @@ -70,46 +71,104 @@ export default function describeDebug({ }); describeIf(is('>= 16.6'), 'React.memo', () => { - function Add({ a, b, c }) { - return
{String(a)}|{String(b)}|{String(c)}
; - } - Add.defaultProps = { - b: 2, - c: 3, - }; - const MemoAdd = memo && memo(Add); - - it('applies defaultProps to the component', () => { - const wrapper = WrapRendered(); - expect(wrapper.debug()).to.equal(`
+ describe('defaultProps', () => { + function Add({ a, b, c }) { + return
{String(a)}|{String(b)}|{String(c)}
; + } + Add.defaultProps = { + b: 2, + c: 3, + }; + const MemoAdd = memo && memo(Add); + + it('applies defaultProps to the component', () => { + const wrapper = WrapRendered(); + expect(wrapper.debug()).to.equal(`
undefined | 2 | 3
`); - }); + }); - it('applies defaultProps to the memoized component', () => { - const wrapper = WrapRendered(); - expect(wrapper.debug()).to.equal(`
+ it('applies defaultProps to the memoized component', () => { + const wrapper = WrapRendered(); + expect(wrapper.debug()).to.equal(`
undefined | 2 | 3
`); - }); + }); - it('applies defaultProps to the memoized component and does not override real props', () => { - const wrapper = WrapRendered(); - expect(wrapper.debug()).to.equal(`
+ it('applies defaultProps to the memoized component and does not override real props', () => { + const wrapper = WrapRendered(); + expect(wrapper.debug()).to.equal(`
10 | 20 | 3
`); + }); + }); + + describe('full tree', () => { + function TransitionGroup({ children }) { return children; } + function CSSTransition({ children }) { return children; } + function Body({ imageToShow, switchImage }) { + const handlerClick = useCallback( + () => { + if (imageToShow === 1) { + return switchImage(2); + } + + return switchImage(1); + }, + [imageToShow, switchImage], + ); + + return ( +
+ +
+ ); + } + const BodyMemo = memo && memo(Body); + + it('shows everything when not memoized', () => { + const wrapper = WrapRendered( {}} />); + expect(wrapper.debug()).to.equal(`
+ +
`); + }); + + it('shows everything when memoized', () => { + const wrapper = WrapRendered( {}} />); + expect(wrapper.debug()).to.equal(`
+ +
`); + }); }); }); });