Skip to content

Commit

Permalink
Migrated SelectArrayInput
Browse files Browse the repository at this point in the history
  • Loading branch information
djhi committed Jun 19, 2019
1 parent d954c91 commit 5e7fa46
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/ra-ui-materialui/src/input/SelectArrayInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,15 @@ export class SelectArrayInput extends Component {
source,
optionText,
optionValue,
helperText,
...rest
} = this.props;
if (typeof meta === 'undefined') {
throw new Error(
"The SelectInput component wasn't called within a redux-form <Field>. Did you decorate it and forget to add the addField prop to your component? See https://marmelab.com/react-admin/Inputs.html#writing-your-own-input-component for details."
);
}
const { touched, error, helperText = false } = meta;
const { touched, error } = meta;

return (
<FormControl
Expand Down
11 changes: 4 additions & 7 deletions packages/ra-ui-materialui/src/input/SelectArrayInput.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('<SelectArrayInput />', () => {
const { queryByTestId } = render(
<SelectArrayInput {...defaultProps} input={{}} />
);
expect(queryByTestId('selectArray')).not.toBeNull();
expect(queryByTestId('selectArray')).toBeDefined();
});

it('should use the input parameter value as the initial input value', () => {
Expand Down Expand Up @@ -153,12 +153,9 @@ describe('<SelectArrayInput />', () => {

it('should displayed helperText if prop is present in meta', () => {
const { queryByText } = render(
<SelectArrayInput
{...defaultProps}
meta={{ helperText: 'Can I help you?' }}
/>
<SelectArrayInput {...defaultProps} helperText="Can I help you?" />
);
expect(queryByText('Can I help you?')).not.toBeNull();
expect(queryByText('Can I help you?')).toBeDefined();
});

describe('error message', () => {
Expand Down Expand Up @@ -186,10 +183,10 @@ describe('<SelectArrayInput />', () => {
const { queryByText } = render(
<SelectArrayInput
{...defaultProps}
helperText="Can I help you?"
meta={{
touched: true,
error: 'Required field.',
helperText: 'Can I help you?',
}}
/>
);
Expand Down

0 comments on commit 5e7fa46

Please sign in to comment.