Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Button size violations in misc. unit tests #68154

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading