Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fix act errors in PopoverDropdown test #21361

Merged
merged 2 commits into from
Sep 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ const defaultProps: PopoverDropdownProps = {
onChange: jest.fn(),
};

test('renders with default props', () => {
test('renders with default props', async () => {
render(<PopoverDropdown {...defaultProps} />);
expect(screen.getByRole('button')).toBeInTheDocument();
expect(await screen.findByRole('button')).toBeInTheDocument();
expect(screen.getByRole('button')).toHaveTextContent('Option 1');
});

test('renders the menu on click', () => {
test('renders the menu on click', async () => {
render(<PopoverDropdown {...defaultProps} />);
userEvent.click(screen.getByRole('button'));
expect(screen.getByRole('menu')).toBeInTheDocument();
expect(await screen.findByRole('menu')).toBeInTheDocument();
});

test('renders with custom button', () => {
test('renders with custom button', async () => {
render(
<PopoverDropdown
{...defaultProps}
Expand All @@ -59,10 +59,10 @@ test('renders with custom button', () => {
)}
/>,
);
expect(screen.getByText('Custom Option 1')).toBeInTheDocument();
expect(await screen.findByText('Custom Option 1')).toBeInTheDocument();
});

test('renders with custom option', () => {
test('renders with custom option', async () => {
render(
<PopoverDropdown
{...defaultProps}
Expand All @@ -74,13 +74,13 @@ test('renders with custom option', () => {
/>,
);
userEvent.click(screen.getByRole('button'));
expect(screen.getByText('Custom Option 1')).toBeInTheDocument();
expect(await screen.findByText('Custom Option 1')).toBeInTheDocument();
});

test('triggers onChange', () => {
test('triggers onChange', async () => {
render(<PopoverDropdown {...defaultProps} />);
userEvent.click(screen.getByRole('button'));
expect(screen.getByText('Option 2')).toBeInTheDocument();
expect(await screen.findByText('Option 2')).toBeInTheDocument();
userEvent.click(screen.getByText('Option 2'));
expect(defaultProps.onChange).toHaveBeenCalled();
});