Skip to content

Commit

Permalink
Revert "Remove overly specific unit test that does not seem necessary"
Browse files Browse the repository at this point in the history
This reverts commit c056aa8.
  • Loading branch information
corneliusroemer committed Jun 29, 2024
1 parent c062e83 commit ac52700
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,36 @@ describe('AutoCompleteField', () => {
expect(screen.getByText('No options available')).toBeInTheDocument();
});

it('calls setAFieldValue, when an option is selected', async () => {
mockUseAggregated.mockReturnValue({
data: {
data: [
{ testField: 'Option 1', count: 10 },
{ testField: 'Option 2', count: 20 },
],
},
isLoading: false,
error: null,
mutate: vi.fn(),
});
render(
<AutoCompleteField
field={field}
setAFieldValue={setAFieldValue}
lapisUrl={lapisUrl}
lapisSearchParameters={lapisSearchParameters}
/>,
);

const input = screen.getByLabelText('Test Field');
fireEvent.focus(input);

const options = await screen.findAllByRole('option');
fireEvent.click(options[0]);

expect(setAFieldValue).toHaveBeenCalledWith('testField', 'Option 1');
});

it('clears input value on clear button click', async () => {
mockUseAggregated.mockReturnValue({
data: {
Expand Down

0 comments on commit ac52700

Please sign in to comment.