Skip to content

Commit

Permalink
ESLint: Update eslint-plugin-testing-library to v6 (#54910)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla authored Sep 28, 2023
1 parent 20843c0 commit 744a230
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 35 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
"eslint-plugin-prettier": "5.0.0",
"eslint-plugin-ssr-friendly": "1.0.6",
"eslint-plugin-storybook": "0.6.13",
"eslint-plugin-testing-library": "5.7.2",
"eslint-plugin-testing-library": "6.0.2",
"execa": "4.0.2",
"fast-glob": "3.2.7",
"filenamify": "4.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/cover/test/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ describe( 'Cover block', () => {
} )
);
expect(
within( screen.queryByLabelText( 'Block: Cover' ) ).queryByRole(
within( screen.getByLabelText( 'Block: Cover' ) ).queryByRole(
'img'
)
).not.toBeInTheDocument();
Expand Down
13 changes: 6 additions & 7 deletions packages/components/src/combobox-control/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ const getOption = ( name: string ) => screen.getByRole( 'option', { name } );
const getAllOptions = () => screen.getAllByRole( 'option' );
const getOptionSearchString = ( option: ComboboxControlOption ) =>
option.label.substring( 0, 11 );
const setupUser = () => userEvent.setup();

const ControlledComboboxControl = ( {
value: valueProp,
Expand Down Expand Up @@ -112,7 +111,7 @@ describe.each( [
} );

it( 'should render with the correct options', async () => {
const user = setupUser();
const user = await userEvent.setup();
render(
<Component options={ timezones } label={ defaultLabelText } />
);
Expand All @@ -133,7 +132,7 @@ describe.each( [
} );

it( 'should select the correct option via click events', async () => {
const user = setupUser();
const user = await userEvent.setup();
const targetOption = timezones[ 2 ];
const onChangeSpy = jest.fn();
render(
Expand All @@ -157,7 +156,7 @@ describe.each( [
} );

it( 'should select the correct option via keypress events', async () => {
const user = setupUser();
const user = await userEvent.setup();
const targetIndex = 4;
const targetOption = timezones[ targetIndex ];
const onChangeSpy = jest.fn();
Expand Down Expand Up @@ -187,7 +186,7 @@ describe.each( [
} );

it( 'should select the correct option from a search', async () => {
const user = setupUser();
const user = await userEvent.setup();
const targetOption = timezones[ 13 ];
const onChangeSpy = jest.fn();
render(
Expand All @@ -214,7 +213,7 @@ describe.each( [
} );

it( 'should render aria-live announcement upon selection', async () => {
const user = setupUser();
const user = await userEvent.setup();
const targetOption = timezones[ 9 ];
const onChangeSpy = jest.fn();
render(
Expand Down Expand Up @@ -242,7 +241,7 @@ describe.each( [
} );

it( 'should process multiple entries in a single session', async () => {
const user = setupUser();
const user = await userEvent.setup();
const unmatchedString = 'Mordor';
const targetOption = timezones[ 6 ];
const onChangeSpy = jest.fn();
Expand Down
10 changes: 4 additions & 6 deletions packages/components/src/external-link/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import userEvent from '@testing-library/user-event';
*/
import { ExternalLink } from '..';

const setupUser = () => userEvent.setup();

describe( 'ExternalLink', () => {
test( 'should call function passed in onClick handler when clicking the link', async () => {
const user = setupUser();
const user = await userEvent.setup();
const onClickMock = jest.fn();

render(
Expand All @@ -32,7 +30,7 @@ describe( 'ExternalLink', () => {
} );

test( 'should prevent default action when clicking an internal anchor link without passing onClick prop', async () => {
const user = setupUser();
const user = await userEvent.setup();

render(
<ExternalLink href="#test">I&apos;m an anchor link!</ExternalLink>
Expand All @@ -55,7 +53,7 @@ describe( 'ExternalLink', () => {
} );

test( 'should call function passed in onClick handler and prevent default action when clicking an internal anchor link', async () => {
const user = setupUser();
const user = await userEvent.setup();
const onClickMock = jest.fn();

render(
Expand All @@ -76,7 +74,7 @@ describe( 'ExternalLink', () => {
} );

test( 'should not prevent default action when clicking a non anchor link without passing onClick prop', async () => {
const user = setupUser();
const user = await userEvent.setup();

render(
<ExternalLink href="https://wordpress.org">
Expand Down
12 changes: 5 additions & 7 deletions packages/components/src/input-control/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import { useState } from '@wordpress/element';
*/
import BaseInputControl from '../';

const setupUser = () => userEvent.setup();

const getInput = () => screen.getByTestId( 'input' );

describe( 'InputControl', () => {
Expand Down Expand Up @@ -70,7 +68,7 @@ describe( 'InputControl', () => {

describe( 'Ensurance of focus for number inputs', () => {
it( 'should focus its input on mousedown events', async () => {
const user = setupUser();
const user = await userEvent.setup();
const spy = jest.fn();
render( <InputControl type="number" onFocus={ spy } /> );
const target = getInput();
Expand All @@ -87,7 +85,7 @@ describe( 'InputControl', () => {

describe( 'Value', () => {
it( 'should update value onChange', async () => {
const user = setupUser();
const user = await userEvent.setup();
const spy = jest.fn();
render(
<InputControl value="Hello" onChange={ ( v ) => spy( v ) } />
Expand All @@ -102,7 +100,7 @@ describe( 'InputControl', () => {
} );

it( 'should work as a controlled component given normal, falsy or nullish values', async () => {
const user = setupUser();
const user = await userEvent.setup();
const spy = jest.fn();
const heldKeySet = new Set();
const Example = () => {
Expand Down Expand Up @@ -173,7 +171,7 @@ describe( 'InputControl', () => {
} );

it( 'should not commit value until blurred when isPressEnterToChange is true', async () => {
const user = setupUser();
const user = await userEvent.setup();
const spy = jest.fn();
render(
<InputControl
Expand All @@ -193,7 +191,7 @@ describe( 'InputControl', () => {
} );

it( 'should commit value when blurred if value is invalid', async () => {
const user = setupUser();
const user = await userEvent.setup();
const spyChange = jest.fn();
render(
<InputControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import userEvent from '@testing-library/user-event';
*/
import SelectControl from '..';

const setupUser = () => userEvent.setup();

describe( 'SelectControl', () => {
it( 'should not render when no options or children are provided', () => {
render( <SelectControl /> );
Expand All @@ -20,7 +18,7 @@ describe( 'SelectControl', () => {
} );

it( 'should not render its children', async () => {
const user = setupUser();
const user = await userEvent.setup();
const handleChangeMock = jest.fn();

render(
Expand Down Expand Up @@ -49,7 +47,7 @@ describe( 'SelectControl', () => {
} );

it( 'should not render its options', async () => {
const user = setupUser();
const user = await userEvent.setup();
const handleChangeMock = jest.fn();

render(
Expand Down
1 change: 1 addition & 0 deletions packages/plugins/src/components/test/plugin-area.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* External dependencies
*/
// eslint-disable-next-line testing-library/no-manual-cleanup
import { act, render, cleanup } from '@testing-library/react';

/**
Expand Down

0 comments on commit 744a230

Please sign in to comment.