From f804f0413aa51d1b3a86efad6cc40635a4d18638 Mon Sep 17 00:00:00 2001 From: David Calhoun <438664+dcalhoun@users.noreply.github.com> Date: Wed, 14 Sep 2022 11:03:15 -0500 Subject: [PATCH] refactor: Update new tests to match updated testing approach The tests were authored prior to these new practices were established. --- .../src/components/use-select/test/index.js | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/packages/data/src/components/use-select/test/index.js b/packages/data/src/components/use-select/test/index.js index d38fd683958ca..41c4defa92384 100644 --- a/packages/data/src/components/use-select/test/index.js +++ b/packages/data/src/components/use-select/test/index.js @@ -439,7 +439,7 @@ describe( 'useSelect', () => { registry.registerStore( 'store-2', counterStore ); registry.registerStore( 'store-3', counterStore ); - let renderer, childShouldDispatch, setChildShouldDispatch; + let childShouldDispatch, setChildShouldDispatch; const selectCount1AndDep = jest.fn(); class ChildComponent extends Component { @@ -459,9 +459,8 @@ describe( 'useSelect', () => { } const TestComponent = jest.fn( () => { - [ childShouldDispatch, setChildShouldDispatch ] = useState( - false - ); + [ childShouldDispatch, setChildShouldDispatch ] = + useState( false ); const state = useSelect( ( select ) => selectCount1AndDep() || { @@ -472,7 +471,7 @@ describe( 'useSelect', () => { return ( <> -
+
count1:{ state.count1 }
@@ -480,24 +479,20 @@ describe( 'useSelect', () => { ); } ); - act( () => { - renderer = TestRenderer.create( - - - - ); - } ); + const rendered = render( + + + + ); act( () => { setChildShouldDispatch( true ); } ); - const testInstance = renderer.root; - expect( selectCount1AndDep ).toHaveBeenCalledTimes( 3 ); - expect( testInstance.findByType( 'div' ).props.data ).toEqual( { - count1: 1, - } ); + expect( rendered.getByRole( 'status' ) ).toHaveTextContent( + 'count1:1' + ); } ); it( 'handles registry selectors', () => {