Skip to content

Commit

Permalink
test: add test for fetching once in searchPanelControl
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Stoehr committed Nov 28, 2024
1 parent 5291b35 commit 76f18b8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion __tests__/src/components/SearchPanelControls.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,23 @@ describe('SearchPanelControls', () => {
await user.keyboard('somestring');
await user.click(await screen.findByText('somestring 12345'));
expect(fetchSearch).toHaveBeenCalledWith('window', 'cw', 'http://example.com/search?q=somestring+12345', 'somestring 12345');

fetch.resetMocks();
});
it('should fetch result only once', async () => {
const fetchSearch = jest.fn();
const user = userEvent.setup();

createWrapper({
autocompleteService: { id: 'http://example.com/autocomplete' },
fetchSearch,
searchService: { id: 'http://example.com/search', options: { resource: { id: 'abc' } } },
});

await user.click(screen.getByRole('combobox'));
await user.keyboard('somestring');
await user.keyboard('{Enter}');
expect(fetchSearch).toHaveBeenCalledTimes(1);
});

it('renders a text input through the renderInput prop', () => {
createWrapper();
Expand Down

0 comments on commit 76f18b8

Please sign in to comment.