Skip to content

Commit

Permalink
Improve naming consistency in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Mar 26, 2024
1 parent a64759c commit bf056b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Expand Up @@ -12,7 +12,7 @@ import { useState } from '@wordpress/element';
/**
* Internal dependencies
*/
import UncontrolledCustomSelect from '..';
import UncontrolledCustomSelectControl from '..';

const customClass = 'amber-skies';

Expand Down Expand Up @@ -48,14 +48,14 @@ const legacyProps = {
],
};

const LegacyControlledCustomSelect = ( {
const ControlledCustomSelectControl = ( {
options,
onChange,
...restProps
}: React.ComponentProps< typeof UncontrolledCustomSelect > ) => {
}: React.ComponentProps< typeof UncontrolledCustomSelectControl > ) => {
const [ value, setValue ] = useState( options[ 0 ] );
return (
<UncontrolledCustomSelect
<UncontrolledCustomSelectControl
{ ...restProps }
options={ options }
onChange={ ( args: any ) => {
Expand All @@ -70,8 +70,8 @@ const LegacyControlledCustomSelect = ( {
};

describe.each( [
[ 'Uncontrolled', UncontrolledCustomSelect ],
[ 'Controlled', LegacyControlledCustomSelect ],
[ 'Uncontrolled', UncontrolledCustomSelectControl ],
[ 'Controlled', ControlledCustomSelectControl ],
] )( 'CustomSelectControl (%s)', ( ...modeAndComponent ) => {
const [ , Component ] = modeAndComponent;

Expand Down
24 changes: 12 additions & 12 deletions packages/components/src/custom-select-control-v2/test/index.tsx
Expand Up @@ -12,7 +12,7 @@ import { useState } from '@wordpress/element';
/**
* Internal dependencies
*/
import UncontrolledCustomSelectControl from '..';
import UncontrolledCustomSelectControlV2 from '..';
import type { CustomSelectProps } from '../types';

const items = [
Expand Down Expand Up @@ -41,14 +41,14 @@ const items = [
const defaultProps = {
label: 'label!',
children: items.map( ( { value, key } ) => (
<UncontrolledCustomSelectControl.Item value={ value } key={ key } />
<UncontrolledCustomSelectControlV2.Item value={ value } key={ key } />
) ),
};

const ControlledCustomSelectControl = ( props: CustomSelectProps ) => {
const [ value, setValue ] = useState< string | string[] >();
return (
<UncontrolledCustomSelectControl
<UncontrolledCustomSelectControlV2
{ ...props }
onChange={ ( nextValue: string | string[] ) => {
setValue( nextValue );
Expand All @@ -60,7 +60,7 @@ const ControlledCustomSelectControl = ( props: CustomSelectProps ) => {
};

describe.each( [
[ 'Uncontrolled', UncontrolledCustomSelectControl ],
[ 'Uncontrolled', UncontrolledCustomSelectControlV2 ],
[ 'Controlled', ControlledCustomSelectControl ],
] )( 'CustomSelectControlV2 (%s)', ( ...modeAndComponent ) => {
const [ , Component ] = modeAndComponent;
Expand Down Expand Up @@ -257,12 +257,12 @@ describe.each( [
'rose blush',
'ultraviolet morning light',
].map( ( item ) => (
<UncontrolledCustomSelectControl.Item
<UncontrolledCustomSelectControlV2.Item
key={ item }
value={ item }
>
{ item }
</UncontrolledCustomSelectControl.Item>
</UncontrolledCustomSelectControlV2.Item>
) ) }
</Component>
);
Expand Down Expand Up @@ -329,12 +329,12 @@ describe.each( [
render(
<Component defaultValue={ defaultValues } label="Multi-select">
{ defaultValues.map( ( item ) => (
<UncontrolledCustomSelectControl.Item
<UncontrolledCustomSelectControlV2.Item
key={ item }
value={ item }
>
{ item }
</UncontrolledCustomSelectControl.Item>
</UncontrolledCustomSelectControlV2.Item>
) ) }
</Component>
);
Expand Down Expand Up @@ -384,12 +384,12 @@ describe.each( [

render(
<Component label="Rendered" renderSelectedValue={ renderValue }>
<UncontrolledCustomSelectControl.Item value="april-29">
<UncontrolledCustomSelectControlV2.Item value="april-29">
{ renderValue( 'april-29' ) }
</UncontrolledCustomSelectControl.Item>
<UncontrolledCustomSelectControl.Item value="july-9">
</UncontrolledCustomSelectControlV2.Item>
<UncontrolledCustomSelectControlV2.Item value="july-9">
{ renderValue( 'july-9' ) }
</UncontrolledCustomSelectControl.Item>
</UncontrolledCustomSelectControlV2.Item>
</Component>
);

Expand Down

0 comments on commit bf056b6

Please sign in to comment.