mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 18:46:17 +00:00
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:
committed by
David Lechner
parent
78290eb927
commit
d88ce8998f
@@ -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 { bluetoothNotAvailable } from './BluetoothNotAvailable';
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
@@ -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 { missingService } from './MissingService';
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
@@ -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 { noGatt } from './NoGatt';
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
@@ -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 { noHub } from './NoHub';
|
||||
@@ -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');
|
||||
});
|
||||
@@ -23,7 +24,7 @@ it('should flash firmware when button is clicked', async () => {
|
||||
|
||||
const [user, message] = testRender(<Toast {...toast} />);
|
||||
|
||||
await user.click(message.getByRole('button', { name: /firmware/i }));
|
||||
await act(() => user.click(message.getByRole('button', { name: /firmware/i })));
|
||||
|
||||
expect(callback).toHaveBeenCalledWith('flashFirmware');
|
||||
});
|
||||
|
||||
@@ -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 { noWebBluetooth } from './NoWebBluetooth';
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
@@ -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 { oldFirmware } from './OldFirmware';
|
||||
@@ -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');
|
||||
});
|
||||
@@ -23,7 +24,7 @@ it('should flash firmware when button is clicked', async () => {
|
||||
|
||||
const [user, message] = testRender(<Toast {...toast} />);
|
||||
|
||||
await user.click(message.getByRole('button', { name: /firmware/i }));
|
||||
await act(() => user.click(message.getByRole('button', { name: /firmware/i })));
|
||||
|
||||
expect(callback).toHaveBeenCalledWith('flashFirmware');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user