From 142620be800d10d6f852dd91dd0875749dea12c8 Mon Sep 17 00:00:00 2001 From: Marin Atanasov <8436925+tyxla@users.noreply.github.com> Date: Tue, 18 Oct 2022 09:20:19 +0200 Subject: [PATCH] Components: Refactor `withFocusReturn` tests to RTL (#45012) * Components: Refactor withFocusReturn tests to RTL * Add a CHANGELOG entry * Remove unnecessary fireEvent * Click into the textarea to focus it --- packages/components/CHANGELOG.md | 1 + .../with-focus-return/test/index.js | 58 ++++++++++--------- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 1ff727b29145db..203d2c2a2526bc 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -18,6 +18,7 @@ - `Sandbox`: Use `toString` to create observe and resize script string ([#42872](https://github.com/WordPress/gutenberg/pull/42872)). - `Navigator`: refactor unit tests to TypeScript and to `user-event` ([#44970](https://github.com/WordPress/gutenberg/pull/44970)). - `Navigator`: Refactor Storybook code to TypeScript and controls ([#44979](https://github.com/WordPress/gutenberg/pull/44979)). +- `withFocusReturn`: Refactor tests to `@testing-library/react` ([#45012](https://github.com/WordPress/gutenberg/pull/45012)). ## 21.2.0 (2022-10-05) diff --git a/packages/components/src/higher-order/with-focus-return/test/index.js b/packages/components/src/higher-order/with-focus-return/test/index.js index 9b32ae72dd7905..2f5dea414c34bb 100644 --- a/packages/components/src/higher-order/with-focus-return/test/index.js +++ b/packages/components/src/higher-order/with-focus-return/test/index.js @@ -1,8 +1,8 @@ /** * External dependencies */ -import renderer from 'react-test-renderer'; -import { render, fireEvent } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; /** * WordPress dependencies @@ -16,9 +16,14 @@ import withFocusReturn from '../'; class Test extends Component { render() { + const { className, focusHistory } = this.props; return ( -
-