Skip to content

Commit

Permalink
Compose: Refactor useInstanceId tests to RTL (#44818)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla authored Oct 10, 2022
1 parent dbd48b6 commit 5f9c676
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions packages/compose/src/hooks/use-instance-id/test/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { create, act } from 'react-test-renderer';
import { render } from '@testing-library/react';

/**
* Internal dependencies
Expand All @@ -14,23 +14,16 @@ describe( 'useInstanceId', () => {
};

it( 'should manage ids', async () => {
let test0;
const { container, rerender } = render( <TestComponent /> );

await act( async () => {
test0 = create( <TestComponent /> );
} );
expect( container ).toHaveTextContent( '0' );

expect( test0.toJSON() ).toBe( '0' );
rerender(
<div>
<TestComponent />
</div>
);

let test1;

await act( async () => {
test1 = create( <TestComponent /> );
} );

expect( test1.toJSON() ).toBe( '1' );

test0.unmount();
test1.unmount();
expect( container ).toHaveTextContent( '1' );
} );
} );

0 comments on commit 5f9c676

Please sign in to comment.