Skip to content

Commit

Permalink
Added test to verify that the event object is properly passed to the …
Browse files Browse the repository at this point in the history
…onBlur handler of the `AutocompleteInput`
  • Loading branch information
yanchesky committed Mar 18, 2024
1 parent 08b241b commit bc137d0
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/ra-ui-materialui/src/input/AutocompleteInput.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,30 @@ describe('<AutocompleteInput />', () => {
});
});

it('should pass the event object to the onBlur callback', async () => {
const onBlur = jest.fn();
render(
<AdminContext dataProvider={testDataProvider()}>
<SimpleForm onSubmit={jest.fn()}>
<AutocompleteInput
{...defaultProps}
choices={[{ id: 0, name: 'foo' }]}
onBlur={onBlur}
/>
</SimpleForm>
</AdminContext>
);
const input = screen.getByLabelText(
'resources.users.fields.role'
) as HTMLInputElement;

fireEvent.blur(input);

expect(onBlur).toHaveBeenCalledWith(
expect.objectContaining({ type: 'blur' })
);
});

describe('Inside <ReferenceInput>', () => {
it('should work inside a ReferenceInput field', async () => {
render(<InsideReferenceInput />);
Expand Down

0 comments on commit bc137d0

Please sign in to comment.