fix breaking changes for user-event v14

This commit is contained in:
David Lechner
2022-06-02 18:45:28 -05:00
committed by David Lechner
parent 4299b36e6c
commit 883807b4b4
21 changed files with 289 additions and 280 deletions
+6 -7
View File
@@ -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());
});