mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 10:35:11 +00:00
fix breaking changes for user-event v14
This commit is contained in:
committed by
David Lechner
parent
4299b36e6c
commit
883807b4b4
@@ -2,23 +2,22 @@
|
||||
// Copyright (c) 2021-2022 The Pybricks Authors
|
||||
|
||||
import { getByLabelText, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
import { testRender } from '../../test';
|
||||
import AboutDialog from './AboutDialog';
|
||||
|
||||
it('should close when the button is clicked', () => {
|
||||
it('should close when the button is clicked', async () => {
|
||||
const close = jest.fn();
|
||||
|
||||
const [dialog] = testRender(<AboutDialog isOpen={true} onClose={close} />);
|
||||
const [user, dialog] = testRender(<AboutDialog isOpen={true} onClose={close} />);
|
||||
|
||||
userEvent.click(dialog.getByLabelText('Close'));
|
||||
await user.click(dialog.getByLabelText('Close'));
|
||||
|
||||
expect(close).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should manage license dialog open/close', async () => {
|
||||
const [dialog] = testRender(
|
||||
const [user, dialog] = testRender(
|
||||
<AboutDialog isOpen={true} onClose={() => undefined} />,
|
||||
);
|
||||
|
||||
@@ -26,7 +25,7 @@ it('should manage license dialog open/close', async () => {
|
||||
dialog.queryByRole('dialog', { name: 'Open Source Software Licenses' }),
|
||||
).toBeNull();
|
||||
|
||||
userEvent.click(dialog.getByText('Software Licenses'));
|
||||
await user.click(dialog.getByText('Software Licenses'));
|
||||
|
||||
const licenseDialog = dialog.getByRole('dialog', {
|
||||
name: 'Open Source Software Licenses',
|
||||
@@ -34,7 +33,7 @@ it('should manage license dialog open/close', async () => {
|
||||
|
||||
expect(licenseDialog).toBeVisible();
|
||||
|
||||
userEvent.click(getByLabelText(licenseDialog, 'Close'));
|
||||
await user.click(getByLabelText(licenseDialog, 'Close'));
|
||||
|
||||
await waitFor(() => expect(licenseDialog).not.toBeVisible());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user