From 6ea55a19dc01a7bba0ce85a63ec56bf35d6b6ce4 Mon Sep 17 00:00:00 2001 From: Kazuhiro Kumagai <78473460+cidkumagai@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:48:21 +0900 Subject: [PATCH] Remove unnecessary act() calls (#49326) * refactor(tests): remove unnecessary act() calls * chore: do npm test -- -u --- .../__tests__/__snapshots__/demo-extend.test.ts.snap | 4 ++-- components/form/__tests__/index.test.tsx | 7 +++---- components/grid/__tests__/index.test.tsx | 6 ++---- components/upload/__tests__/uploadlist.test.tsx | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/components/date-picker/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/date-picker/__tests__/__snapshots__/demo-extend.test.ts.snap index e9f3730b89..fd69e75906 100644 --- a/components/date-picker/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/date-picker/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -46989,7 +46989,7 @@ Array [ ,
,
{ 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, { diff --git a/components/grid/__tests__/index.test.tsx b/components/grid/__tests__/index.test.tsx index 05929511e8..8faf4312a2 100644 --- a/components/grid/__tests__/index.test.tsx +++ b/components/grid/__tests__/index.test.tsx @@ -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(); 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'); }); diff --git a/components/upload/__tests__/uploadlist.test.tsx b/components/upload/__tests__/uploadlist.test.tsx index 2a4aab7343..7dcc6072bc 100644 --- a/components/upload/__tests__/uploadlist.test.tsx +++ b/components/upload/__tests__/uploadlist.test.tsx @@ -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);