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:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user