From 35946ab332716d38b272347cb804912d22beea57 Mon Sep 17 00:00:00 2001 From: Darren Ethier Date: Sun, 8 Jul 2018 13:56:28 -0400 Subject: [PATCH] convert all tests to use React.TestRenderer This switches all tests in `viewport/test/if-viewport-matches.js` from using enzyme.mount to `React.TestRenderer`. This is because `enzyme` does not fully support React 16.3+ (and movement to do so is really slow). This will fix issues with breakage due to the enzyme incompatibility as components receive React 16.3+ features (such as `forwardRef` usage in #7557). --- viewport/test/if-viewport-matches.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/viewport/test/if-viewport-matches.js b/viewport/test/if-viewport-matches.js index d1f2c1a247d49..5cd88fc6161bd 100644 --- a/viewport/test/if-viewport-matches.js +++ b/viewport/test/if-viewport-matches.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { mount } from 'enzyme'; +import renderer from 'react-test-renderer'; /** * WordPress dependencies @@ -20,9 +20,9 @@ describe( 'ifViewportMatches()', () => { it( 'should not render if query does not match', () => { dispatch( 'core/viewport' ).setIsMatching( { '> wide': false } ); const EnhancedComponent = ifViewportMatches( '> wide' )( Component ); - const wrapper = mount( ); + const wrapper = renderer.create( ); - expect( wrapper.find( Component ) ).toHaveLength( 0 ); + expect( wrapper.root.findAllByType( Component ) ).toHaveLength( 0 ); wrapper.unmount(); } ); @@ -30,9 +30,8 @@ describe( 'ifViewportMatches()', () => { it( 'should render if query does match', () => { dispatch( 'core/viewport' ).setIsMatching( { '> wide': true } ); const EnhancedComponent = ifViewportMatches( '> wide' )( Component ); - const wrapper = mount( ); - - expect( wrapper.find( Component ).childAt( 0 ).type() ).toBe( 'div' ); + const wrapper = renderer.create( ); + expect( wrapper.root.findByType( Component ).children[ 0 ].type ).toBe( 'div' ); wrapper.unmount(); } );