test: wrap all user calls in act()

Some user events trigger react dom changes. These need to be wrapped in
act() to avoid a warning printed to the console. To be save, we wrap
all instances.
This commit is contained in:
David Lechner
2023-03-10 18:16:27 -06:00
committed by David Lechner
parent 78290eb927
commit d88ce8998f
42 changed files with 212 additions and 172 deletions
+2 -1
View File
@@ -2,6 +2,7 @@
// Copyright (c) 2022-2023 The Pybricks Authors
import { Toast } from '@blueprintjs/core';
import { act } from '@testing-library/react';
import React from 'react';
import { testRender } from '../../../test';
import { updateServerFailure } from './UpdateServerFailure';
@@ -12,7 +13,7 @@ it('should dismiss when close is clicked', async () => {
const [user, message] = testRender(<Toast {...toast} />);
await user.click(message.getByRole('button', { name: /close/i }));
await act(() => user.click(message.getByRole('button', { name: /close/i })));
expect(callback).toHaveBeenCalledWith('dismiss');
});