Modified propname to be data-test and added unit test for custom data-testid

Signed-off-by: Simon Edström <simon.edstrom@scania.com>
This commit is contained in:
Simon Edström
2024-07-03 12:20:45 +02:00
parent 73e43d2933
commit 25ff804274
2 changed files with 11 additions and 3 deletions
@@ -66,4 +66,12 @@ describe('<Select />', () => {
expect(getByTestId('select').textContent).toBe('All results');
});
it('should function correctly when a custom data-testid is provided', async () => {
const { getByTestId } = render(
<Select {...minProps} data-testid="custom-select" />,
);
const input = getByTestId('custom-select');
expect(input.textContent).toBe('All results');
});
});
@@ -136,7 +136,7 @@ export type SelectProps = {
native?: boolean;
disabled?: boolean;
margin?: 'dense' | 'none';
testid?: string;
'data-testid'?: string;
};
/** @public */
@@ -152,7 +152,7 @@ export function SelectComponent(props: SelectProps) {
native = false,
disabled = false,
margin,
testid = 'select',
'data-testid': dataTestId = 'select',
} = props;
const classes = useStyles();
const [value, setValue] = useState<SelectedItems>(
@@ -205,7 +205,7 @@ export function SelectComponent(props: SelectProps) {
value={value}
native={native}
disabled={disabled}
data-testid={testid}
data-testid={dataTestId}
displayEmpty
multiple={multiple}
margin={margin}