Skip to content

Commit

Permalink
fix failing test by using userEvent.click instead of fireEvent.click
Browse files Browse the repository at this point in the history
  • Loading branch information
corneliusroemer committed Jun 29, 2024
1 parent ac52700 commit f22fbf4
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { render, screen, fireEvent } from '@testing-library/react';
import { render, screen, fireEvent, act } from '@testing-library/react';
import { describe, it, expect, beforeEach, vi } from 'vitest';

import { AutoCompleteField } from './AutoCompleteField';
import { lapisClientHooks } from '../../../services/serviceHooks.ts';
import { type MetadataFilter } from '../../../types/config.ts';
import userEvent from '@testing-library/user-event';

vi.mock('../../../services/serviceHooks.ts');
vi.mock('../../../clientLogger.ts', () => ({
Expand Down Expand Up @@ -167,10 +168,10 @@ describe('AutoCompleteField', () => {
);

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

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

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

0 comments on commit f22fbf4

Please sign in to comment.