Remove unnecessary act() calls (#49326)

* refactor(tests): remove unnecessary act() calls

* chore: do npm test -- -u
This commit is contained in:
Kazuhiro Kumagai 2024-06-10 11:48:21 +09:00 committed by GitHub
parent 30babc686c
commit 6ea55a19dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 11 deletions

View File

@ -46989,7 +46989,7 @@ Array [
</div>
</div>,
<div
class="ant-picker-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up ant-picker-dropdown-placement-bottomLeft"
class="ant-picker-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up ant-picker-dropdown-placement-topLeft"
style="--arrow-x: 0px; --arrow-y: 0px; left: -1000vw; top: -1000vh; box-sizing: border-box;"
>
<div
@ -47643,7 +47643,7 @@ Array [
</span>
</div>,
<div
class="ant-picker-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up ant-picker-dropdown-range ant-picker-dropdown-placement-bottomLeft"
class="ant-picker-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up ant-picker-dropdown-range ant-picker-dropdown-placement-topLeft"
style="--arrow-x: 0px; --arrow-y: 0px; left: -1000vw; top: -1000vh; box-sizing: border-box;"
>
<div

View File

@ -10,7 +10,7 @@ import Form from '..';
import { resetWarned } from '../../_util/warning';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { act, fireEvent, pureRender, render, screen, waitFakeTimer } from '../../../tests/utils';
import { fireEvent, pureRender, render, screen, waitFakeTimer } from '../../../tests/utils';
import Button from '../../button';
import Cascader from '../../cascader';
import Checkbox from '../../checkbox';
@ -2262,9 +2262,8 @@ describe('Form', () => {
expect(container.querySelector('.ant-input-number-suffix')).toBeTruthy();
act(() => {
fireEvent.focus(input);
});
fireEvent.focus(input);
expect(container.querySelector('.ant-input-number-focused')).toBeTruthy();
fireEvent.change(input, {

View File

@ -3,7 +3,7 @@ import React, { useState } from 'react';
import { Col, Row } from '..';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { act, fireEvent, render } from '../../../tests/utils';
import { fireEvent, render } from '../../../tests/utils';
import useBreakpoint from '../hooks/useBreakpoint';
// Mock for `responsiveObserve` to test `unsubscribe` call
@ -227,9 +227,7 @@ describe('Grid', () => {
};
const { container } = render(<ReactiveTest />);
expect(container.innerHTML).toContain('ant-row-start');
act(() => {
fireEvent.click(container.querySelector('span')!);
});
fireEvent.click(container.querySelector('span')!);
expect(container.innerHTML).toContain('ant-row-end');
});

View File

@ -1341,7 +1341,7 @@ describe('Upload List', () => {
// Mock async update in a frame
const fileNames = ['light', 'bamboo', 'little'];
await act(() => {
act(() => {
uploadRef.current.onBatchStart(
fileNames.map((fileName) => {
const file = new File([], fileName);