From 4f8a148c002c65c7dcf2d0f2c3b1136edd6b30a5 Mon Sep 17 00:00:00 2001 From: Marin Atanasov Date: Mon, 10 Oct 2022 15:17:18 +0300 Subject: [PATCH] Compose: Refactor useInstanceId tests to RTL --- .../src/hooks/use-instance-id/test/index.js | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/packages/compose/src/hooks/use-instance-id/test/index.js b/packages/compose/src/hooks/use-instance-id/test/index.js index 5dc89e089c78f2..2b28224b3def82 100644 --- a/packages/compose/src/hooks/use-instance-id/test/index.js +++ b/packages/compose/src/hooks/use-instance-id/test/index.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { create, act } from 'react-test-renderer'; +import { render } from '@testing-library/react'; /** * Internal dependencies @@ -14,23 +14,16 @@ describe( 'useInstanceId', () => { }; it( 'should manage ids', async () => { - let test0; + const { container, rerender } = render( ); - await act( async () => { - test0 = create( ); - } ); + expect( container ).toHaveTextContent( '0' ); - expect( test0.toJSON() ).toBe( '0' ); + rerender( +
+ +
+ ); - let test1; - - await act( async () => { - test1 = create( ); - } ); - - expect( test1.toJSON() ).toBe( '1' ); - - test0.unmount(); - test1.unmount(); + expect( container ).toHaveTextContent( '1' ); } ); } );