Skip to content

Commit

Permalink
Fix Button size violations in misc. unit tests (WordPress#68154)
Browse files Browse the repository at this point in the history
Co-authored-by: mirka <[email protected]>
Co-authored-by: ciampo <[email protected]>
Co-authored-by: tyxla <[email protected]>
  • Loading branch information
4 people authored Dec 20, 2024
1 parent 0adbeba commit a9f93d8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
11 changes: 9 additions & 2 deletions packages/components/src/button/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,26 @@ import { render, screen } from '@testing-library/react';
/**
* WordPress dependencies
*/
import { createRef } from '@wordpress/element';
import { createRef, forwardRef } from '@wordpress/element';
import { plusCircle } from '@wordpress/icons';

/**
* Internal dependencies
*/
import Button from '..';
import _Button from '..';
import Tooltip from '../../tooltip';
import cleanupTooltip from '../../tooltip/test/utils';
import { press } from '@ariakit/test';

jest.mock( '../../icon', () => () => <div data-testid="test-icon" /> );

const Button = forwardRef(
(
props: React.ComponentProps< typeof _Button >,
ref: React.ForwardedRef< unknown >
) => <_Button __next40pxDefaultSize { ...props } ref={ ref } />
);

describe( 'Button', () => {
describe( 'basic rendering', () => {
it( 'should render a button element with only one class', () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/components/src/navigator/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function CustomNavigatorButton( {
} ) {
return (
<Navigator.Button
__next40pxDefaultSize
onClick={ () => {
// Used to spy on the values passed to `navigator.goTo`.
onClick?.( { type: 'goTo', path } );
Expand All @@ -95,6 +96,7 @@ function CustomNavigatorGoToBackButton( {
const { goTo } = useNavigator();
return (
<Button
__next40pxDefaultSize
onClick={ () => {
goTo( path, { isBack: true } );
// Used to spy on the values passed to `navigator.goTo`.
Expand All @@ -115,6 +117,7 @@ function CustomNavigatorGoToSkipFocusButton( {
const { goTo } = useNavigator();
return (
<Button
__next40pxDefaultSize
onClick={ () => {
goTo( path, { skipFocus: true } );
// Used to spy on the values passed to `navigator.goTo`.
Expand All @@ -136,6 +139,7 @@ function CustomNavigatorBackButton( {
} ) {
return (
<Navigator.BackButton
__next40pxDefaultSize
onClick={ () => {
// Used to spy on the values passed to `navigator.goBack`.
onClick?.( { type: 'goBack' } );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ exports[`ToggleGroupControl controlled should render correctly with icons 1`] =
</div>
</div>
<button
class="components-button"
class="components-button is-next-40px-default-size"
type="button"
>
Reset
Expand Down Expand Up @@ -626,7 +626,7 @@ exports[`ToggleGroupControl controlled should render correctly with text options
</div>
</div>
<button
class="components-button"
class="components-button is-next-40px-default-size"
type="button"
>
Reset
Expand Down
8 changes: 7 additions & 1 deletion packages/components/src/toggle-group-control/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,15 @@ const ControlledToggleGroupControl = ( {
} }
value={ value }
/>
<Button onClick={ () => setValue( undefined ) }>Reset</Button>
<Button
onClick={ () => setValue( undefined ) }
__next40pxDefaultSize
>
Reset
</Button>
{ extraButtonOptions?.map( ( obj ) => (
<Button
__next40pxDefaultSize
key={ obj.value }
onClick={ () => setValue( obj.value ) }
>
Expand Down

0 comments on commit a9f93d8

Please sign in to comment.