Skip to content

Commit

Permalink
Compose: Refactor withInstanceId HoC tests to @testing-library/react (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla authored Sep 7, 2022
1 parent d04c71b commit e61b89d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/compose/src/higher-order/with-instance-id/test/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { render } from 'enzyme';
import { render, screen } from '@testing-library/react';

/**
* Internal dependencies
Expand All @@ -10,13 +10,17 @@ import withInstanceId from '../';

describe( 'withInstanceId', () => {
const DumpComponent = withInstanceId( ( { instanceId } ) => {
return <div>{ instanceId }</div>;
return <div data-testid="wrapper">{ instanceId }</div>;
} );

it( 'should generate a new instanceId for each instance', () => {
const dumb1 = render( <DumpComponent /> );
const dumb2 = render( <DumpComponent /> );
// Unrendered element.
expect( dumb1.text() ).not.toBe( dumb2.text() );
render( <DumpComponent /> );
render( <DumpComponent /> );

const elements = screen.getAllByTestId( 'wrapper' );

expect( elements[ 0 ] ).not.toHaveTextContent(
elements[ 1 ].textContent
);
} );
} );

0 comments on commit e61b89d

Please sign in to comment.