Skip to content

Commit

Permalink
ESLint: Fix jest-dom/prefer-enabled-disabled rule violations (#44895)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla authored Oct 12, 2022
1 parent f5eaa4f commit a303682
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions packages/components/src/button/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe( 'Button', () => {
expect( button ).not.toHaveClass( 'is-large' );
expect( button ).not.toHaveClass( 'is-primary' );
expect( button ).not.toHaveClass( 'is-pressed' );
expect( button ).not.toHaveAttribute( 'disabled' );
expect( button ).toBeEnabled();
expect( button ).not.toHaveAttribute( 'aria-disabled' );
expect( button ).toHaveAttribute( 'type', 'button' );
} );
Expand Down Expand Up @@ -114,16 +114,14 @@ describe( 'Button', () => {
it( 'should add a disabled prop to the button', () => {
render( <Button disabled /> );

expect( screen.getByRole( 'button' ) ).toHaveAttribute(
'disabled'
);
expect( screen.getByRole( 'button' ) ).toBeDisabled();
} );

it( 'should add only aria-disabled attribute when disabled and isFocusable are true', () => {
render( <Button disabled __experimentalIsFocusable /> );
const button = screen.getByRole( 'button' );

expect( button ).not.toHaveAttribute( 'disabled' );
expect( button ).toBeEnabled();
expect( button ).toHaveAttribute( 'aria-disabled' );
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe( 'PostPreviewButton', () => {
it( 'should not be disabled if post is saveable.', async () => {
render( <PostPreviewButton isSaveable postId={ 123 } /> );

expect( screen.getByRole( 'button' ) ).not.toBeDisabled();
expect( screen.getByRole( 'button' ) ).toBeEnabled();
} );

it( 'should set `href` to `previewLink` if `previewLink` is specified.', async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/widgets/customizing-widgets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ test.describe( 'Widgets Customizer', () => {
// (2) We should still be in the "Block Settings" area
await expect(
page.locator( 'role=button[name="Publish"i]' )
).not.toBeDisabled();
).toBeEnabled();

// This fails on 539cea09 and earlier; we get kicked back to the widgets area.
// We expect to stay in block settings.
Expand Down

0 comments on commit a303682

Please sign in to comment.