From f1421f68b062160bcddc8234b9ea2112034d44ad Mon Sep 17 00:00:00 2001 From: try Date: Tue, 31 Dec 2024 16:22:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DuseAntdTable=E5=9C=A8m?= =?UTF-8?q?anual=3Dtrue=E6=97=B6=EF=BC=8C=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E4=BB=8D=E7=84=B6=E5=8F=91=E8=B5=B7=E8=AF=B7=E6=B1=82=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hooks/src/createDeepCompareEffect/__tests__/index.test.ts | 4 ++-- .../hooks/src/createUseStorageState/__tests__/index.test.ts | 3 ++- packages/hooks/src/useAntdTable/__tests__/index.test.ts | 3 ++- packages/hooks/src/useAntdTable/index.tsx | 4 +++- packages/hooks/src/useAsyncEffect/__tests__/index.test.ts | 4 ++-- packages/hooks/src/useBoolean/__tests__/index.test.ts | 3 ++- .../hooks/src/useControllableValue/__tests__/index.test.ts | 3 ++- packages/hooks/src/useCookieState/__tests__/index.test.tsx | 3 ++- packages/hooks/src/useCountDown/__tests__/index.test.ts | 3 ++- packages/hooks/src/useCounter/__tests__/index.test.ts | 3 ++- packages/hooks/src/useCreation/__tests__/index.test.ts | 3 ++- packages/hooks/src/useDebounce/__tests__/index.test.ts | 3 ++- packages/hooks/src/useDebounceEffect/__tests__/index.test.ts | 3 ++- packages/hooks/src/useDebounceFn/__tests__/index.test.ts | 3 ++- .../hooks/src/useDeepCompareEffect/__tests__/index.test.ts | 3 ++- .../src/useDeepCompareLayoutEffect/__tests__/index.test.ts | 3 ++- .../hooks/src/useDocumentVisibility/__tests__/index.test.ts | 3 ++- packages/hooks/src/useDynamicList/__tests__/index.test.ts | 3 ++- packages/hooks/src/useEventEmitter/__tests__/index.test.ts | 3 ++- packages/hooks/src/useEventTarget/__tests__/index.test.ts | 3 ++- packages/hooks/src/useExternal/__tests__/index.test.ts | 3 ++- packages/hooks/src/useFullscreen/__tests__/index.test.ts | 3 ++- packages/hooks/src/useFusionTable/__tests__/index.test.ts | 3 ++- packages/hooks/src/useGetState/__tests__/index.test.ts | 3 ++- packages/hooks/src/useHistoryTravel/__tests__/index.test.ts | 3 ++- packages/hooks/src/useHover/__tests__/index.test.tsx | 3 ++- packages/hooks/src/useInViewport/__tests__/index.test.ts | 3 ++- packages/hooks/src/useInfiniteScroll/__tests__/index.test.ts | 3 ++- .../hooks/src/useLocalStorageState/__tests__/index.test.ts | 3 ++- packages/hooks/src/useLockFn/__tests__/index.test.ts | 3 ++- packages/hooks/src/useMap/__tests__/index.test.ts | 3 ++- packages/hooks/src/useMemoizedFn/__tests__/index.test.ts | 3 ++- packages/hooks/src/useNetwork/__tests__/index.test.ts | 3 ++- packages/hooks/src/useRafState/__tests__/index.test.ts | 3 ++- packages/hooks/src/useReactive/__tests__/index.test.tsx | 4 ++-- .../hooks/src/useRequest/__tests__/useAutoRunPlugin.test.ts | 3 ++- .../hooks/src/useRequest/__tests__/useCachePlugin.test.tsx | 3 ++- .../hooks/src/useRequest/__tests__/useDebouncePlugin.test.ts | 3 ++- .../src/useRequest/__tests__/useLoadingDelayPlugin.test.ts | 3 ++- .../hooks/src/useRequest/__tests__/usePollingPlugin.test.ts | 3 ++- .../__tests__/useRefreshOnWindowFocusPlugin.test.ts | 4 ++-- .../hooks/src/useRequest/__tests__/useRetryPlugin.test.ts | 3 ++- .../hooks/src/useRequest/__tests__/useThrottlePlugin.test.ts | 3 ++- packages/hooks/src/useResetState/__tests__/index.test.ts | 3 ++- packages/hooks/src/useResponsive/__tests__/index.test.ts | 3 ++- packages/hooks/src/useSafeState/__tests__/index.test.ts | 3 ++- packages/hooks/src/useSelections/__tests__/index.test.ts | 3 ++- .../hooks/src/useSessionStorageState/__tests__/index.test.ts | 3 ++- packages/hooks/src/useSet/__tests__/index.test.ts | 3 ++- packages/hooks/src/useSetState/__tests__/index.test.ts | 3 ++- packages/hooks/src/useSize/__tests__/index.test.tsx | 4 ++-- packages/hooks/src/useTextSelection/__tests__/index.test.ts | 3 ++- packages/hooks/src/useTheme/__test__/index.test.ts | 3 ++- packages/hooks/src/useThrottle/__tests__/index.test.ts | 3 ++- packages/hooks/src/useThrottleEffect/__tests__/index.test.ts | 3 ++- packages/hooks/src/useThrottleFn/__tests__/index.test.ts | 3 ++- packages/hooks/src/useTitle/__tests__/index.test.ts | 3 ++- packages/hooks/src/useToggle/__tests__/index.test.ts | 3 ++- packages/hooks/src/useUpdate/__tests__/index.test.ts | 3 ++- packages/hooks/src/useVirtualList/__tests__/index.test.ts | 3 ++- packages/hooks/src/useWebSocket/__tests__/index.test.ts | 3 ++- packages/hooks/src/useWhyDidYouUpdate/__tests__/index.test.ts | 4 ++-- 62 files changed, 125 insertions(+), 68 deletions(-) diff --git a/packages/hooks/src/createDeepCompareEffect/__tests__/index.test.ts b/packages/hooks/src/createDeepCompareEffect/__tests__/index.test.ts index 15447471c8..8cb2ac8873 100644 --- a/packages/hooks/src/createDeepCompareEffect/__tests__/index.test.ts +++ b/packages/hooks/src/createDeepCompareEffect/__tests__/index.test.ts @@ -1,5 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; -import { useEffect, useLayoutEffect, useState } from 'react'; +import { renderHook } from '@testing-library/react'; +import { useEffect, useLayoutEffect, useState, act } from 'react'; import { createDeepCompareEffect } from '../index'; describe('createDeepCompareEffect', () => { diff --git a/packages/hooks/src/createUseStorageState/__tests__/index.test.ts b/packages/hooks/src/createUseStorageState/__tests__/index.test.ts index c115b3424f..178a9b4759 100644 --- a/packages/hooks/src/createUseStorageState/__tests__/index.test.ts +++ b/packages/hooks/src/createUseStorageState/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import type { Options } from '../index'; import { createUseStorageState } from '../index'; diff --git a/packages/hooks/src/useAntdTable/__tests__/index.test.ts b/packages/hooks/src/useAntdTable/__tests__/index.test.ts index 17e77f45ff..231d73e9ab 100644 --- a/packages/hooks/src/useAntdTable/__tests__/index.test.ts +++ b/packages/hooks/src/useAntdTable/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook, waitFor } from '@testing-library/react'; +import { renderHook, waitFor } from '@testing-library/react'; +import { act } from 'react'; import { sleep } from '../../utils/testingHelpers'; import useAntdTable from '../index'; diff --git a/packages/hooks/src/useAntdTable/index.tsx b/packages/hooks/src/useAntdTable/index.tsx index 55a9de2c45..42b63f4211 100644 --- a/packages/hooks/src/useAntdTable/index.tsx +++ b/packages/hooks/src/useAntdTable/index.tsx @@ -211,7 +211,9 @@ const useAntdTable = ( if (ready) { allFormDataRef.current = defaultParams?.[1] || {}; restoreForm(); - _submit(defaultParams?.[0]); + if(!manual) { + _submit(defaultParams?.[0]); + } } }, []); diff --git a/packages/hooks/src/useAsyncEffect/__tests__/index.test.ts b/packages/hooks/src/useAsyncEffect/__tests__/index.test.ts index 93918680de..270fe6a547 100644 --- a/packages/hooks/src/useAsyncEffect/__tests__/index.test.ts +++ b/packages/hooks/src/useAsyncEffect/__tests__/index.test.ts @@ -1,6 +1,6 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; import useAsyncEffect from '../index'; -import { useState } from 'react'; +import { useState, act } from 'react'; import { sleep } from '../../utils/testingHelpers'; describe('useAsyncEffect', () => { diff --git a/packages/hooks/src/useBoolean/__tests__/index.test.ts b/packages/hooks/src/useBoolean/__tests__/index.test.ts index 78b04adb37..2bbc492712 100644 --- a/packages/hooks/src/useBoolean/__tests__/index.test.ts +++ b/packages/hooks/src/useBoolean/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useBoolean from '../index'; const setUp = (defaultValue?: boolean) => renderHook(() => useBoolean(defaultValue)); diff --git a/packages/hooks/src/useControllableValue/__tests__/index.test.ts b/packages/hooks/src/useControllableValue/__tests__/index.test.ts index 5db8d92b93..244f71680d 100644 --- a/packages/hooks/src/useControllableValue/__tests__/index.test.ts +++ b/packages/hooks/src/useControllableValue/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useControllableValue, { Options, Props } from '../index'; describe('useControllableValue', () => { diff --git a/packages/hooks/src/useCookieState/__tests__/index.test.tsx b/packages/hooks/src/useCookieState/__tests__/index.test.tsx index 07d9932ac3..de10cf9c80 100644 --- a/packages/hooks/src/useCookieState/__tests__/index.test.tsx +++ b/packages/hooks/src/useCookieState/__tests__/index.test.tsx @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useCookieState from '../index'; import type { Options } from '../index'; import Cookies from 'js-cookie'; diff --git a/packages/hooks/src/useCountDown/__tests__/index.test.ts b/packages/hooks/src/useCountDown/__tests__/index.test.ts index 5a8365d37a..715200bc21 100644 --- a/packages/hooks/src/useCountDown/__tests__/index.test.ts +++ b/packages/hooks/src/useCountDown/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import type { Options } from '../index'; import useCountDown from '../index'; diff --git a/packages/hooks/src/useCounter/__tests__/index.test.ts b/packages/hooks/src/useCounter/__tests__/index.test.ts index 78bf1913e9..360099e4d9 100644 --- a/packages/hooks/src/useCounter/__tests__/index.test.ts +++ b/packages/hooks/src/useCounter/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useCounter, { Options } from '../index'; const setUp = (init?: number, options?: Options) => renderHook(() => useCounter(init, options)); diff --git a/packages/hooks/src/useCreation/__tests__/index.test.ts b/packages/hooks/src/useCreation/__tests__/index.test.ts index d8a74c4876..a36c113204 100644 --- a/packages/hooks/src/useCreation/__tests__/index.test.ts +++ b/packages/hooks/src/useCreation/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import { useState } from 'react'; import useCreation from '../index'; diff --git a/packages/hooks/src/useDebounce/__tests__/index.test.ts b/packages/hooks/src/useDebounce/__tests__/index.test.ts index f9fdf318a2..4f4b1fb316 100644 --- a/packages/hooks/src/useDebounce/__tests__/index.test.ts +++ b/packages/hooks/src/useDebounce/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useDebounce from '../index'; import { sleep } from '../../utils/testingHelpers'; diff --git a/packages/hooks/src/useDebounceEffect/__tests__/index.test.ts b/packages/hooks/src/useDebounceEffect/__tests__/index.test.ts index 381806430a..b95ee3701d 100644 --- a/packages/hooks/src/useDebounceEffect/__tests__/index.test.ts +++ b/packages/hooks/src/useDebounceEffect/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useDebounceEffect from '../index'; import { sleep } from '../../utils/testingHelpers'; diff --git a/packages/hooks/src/useDebounceFn/__tests__/index.test.ts b/packages/hooks/src/useDebounceFn/__tests__/index.test.ts index 3d9e0636d8..8dfcae4c09 100644 --- a/packages/hooks/src/useDebounceFn/__tests__/index.test.ts +++ b/packages/hooks/src/useDebounceFn/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import { sleep } from '../../utils/testingHelpers'; import useDebounceFn from '../index'; diff --git a/packages/hooks/src/useDeepCompareEffect/__tests__/index.test.ts b/packages/hooks/src/useDeepCompareEffect/__tests__/index.test.ts index d3fbecdcdf..cf73492c45 100644 --- a/packages/hooks/src/useDeepCompareEffect/__tests__/index.test.ts +++ b/packages/hooks/src/useDeepCompareEffect/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import { useState } from 'react'; import useDeepCompareEffect from '../index'; diff --git a/packages/hooks/src/useDeepCompareLayoutEffect/__tests__/index.test.ts b/packages/hooks/src/useDeepCompareLayoutEffect/__tests__/index.test.ts index 9c90903fee..0361812788 100644 --- a/packages/hooks/src/useDeepCompareLayoutEffect/__tests__/index.test.ts +++ b/packages/hooks/src/useDeepCompareLayoutEffect/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import { useState } from 'react'; import useDeepCompareLayoutEffect from '../index'; diff --git a/packages/hooks/src/useDocumentVisibility/__tests__/index.test.ts b/packages/hooks/src/useDocumentVisibility/__tests__/index.test.ts index 0bc4a1ae75..aa9da27828 100644 --- a/packages/hooks/src/useDocumentVisibility/__tests__/index.test.ts +++ b/packages/hooks/src/useDocumentVisibility/__tests__/index.test.ts @@ -1,5 +1,6 @@ import useDocumentVisibility from '../index'; -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; const mockIsBrowser = jest.fn(); const mockDocumentVisibilityState = jest.spyOn(document, 'visibilityState', 'get'); diff --git a/packages/hooks/src/useDynamicList/__tests__/index.test.ts b/packages/hooks/src/useDynamicList/__tests__/index.test.ts index e6509cfb1d..7fbf4ea760 100644 --- a/packages/hooks/src/useDynamicList/__tests__/index.test.ts +++ b/packages/hooks/src/useDynamicList/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useDynamicList from '../index'; describe('useDynamicList', () => { diff --git a/packages/hooks/src/useEventEmitter/__tests__/index.test.ts b/packages/hooks/src/useEventEmitter/__tests__/index.test.ts index fedefffba5..1d29a31055 100644 --- a/packages/hooks/src/useEventEmitter/__tests__/index.test.ts +++ b/packages/hooks/src/useEventEmitter/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import { useState } from 'react'; import useEventEmitter from '../index'; diff --git a/packages/hooks/src/useEventTarget/__tests__/index.test.ts b/packages/hooks/src/useEventTarget/__tests__/index.test.ts index edee4a4705..da77e036a2 100644 --- a/packages/hooks/src/useEventTarget/__tests__/index.test.ts +++ b/packages/hooks/src/useEventTarget/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useEventTarget from '../index'; describe('useEventTarget', () => { diff --git a/packages/hooks/src/useExternal/__tests__/index.test.ts b/packages/hooks/src/useExternal/__tests__/index.test.ts index 20853341d0..697416c4fb 100644 --- a/packages/hooks/src/useExternal/__tests__/index.test.ts +++ b/packages/hooks/src/useExternal/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useExternal, { Options } from '../index'; import { fireEvent } from '@testing-library/react'; diff --git a/packages/hooks/src/useFullscreen/__tests__/index.test.ts b/packages/hooks/src/useFullscreen/__tests__/index.test.ts index c453317175..90bbe4a407 100644 --- a/packages/hooks/src/useFullscreen/__tests__/index.test.ts +++ b/packages/hooks/src/useFullscreen/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useFullscreen from '../index'; import type { Options } from '../index'; import type { BasicTarget } from '../../utils/domTarget'; diff --git a/packages/hooks/src/useFusionTable/__tests__/index.test.ts b/packages/hooks/src/useFusionTable/__tests__/index.test.ts index 3e6bb5e980..2319113a60 100644 --- a/packages/hooks/src/useFusionTable/__tests__/index.test.ts +++ b/packages/hooks/src/useFusionTable/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useFusionTable from '../index'; import { sleep } from '../../utils/testingHelpers'; diff --git a/packages/hooks/src/useGetState/__tests__/index.test.ts b/packages/hooks/src/useGetState/__tests__/index.test.ts index 096a3a498a..7c0f84a27b 100644 --- a/packages/hooks/src/useGetState/__tests__/index.test.ts +++ b/packages/hooks/src/useGetState/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useGetState from '../index'; describe('useGetState', () => { diff --git a/packages/hooks/src/useHistoryTravel/__tests__/index.test.ts b/packages/hooks/src/useHistoryTravel/__tests__/index.test.ts index a9be55d558..6664baa6d5 100644 --- a/packages/hooks/src/useHistoryTravel/__tests__/index.test.ts +++ b/packages/hooks/src/useHistoryTravel/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useHistoryTravel from '../index'; describe('useHistoryTravel', () => { diff --git a/packages/hooks/src/useHover/__tests__/index.test.tsx b/packages/hooks/src/useHover/__tests__/index.test.tsx index a9a6e652e8..f626850a6d 100644 --- a/packages/hooks/src/useHover/__tests__/index.test.tsx +++ b/packages/hooks/src/useHover/__tests__/index.test.tsx @@ -1,6 +1,7 @@ // write your test cases here import React from 'react'; -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import { render, fireEvent } from '@testing-library/react'; import useHover from '../index'; diff --git a/packages/hooks/src/useInViewport/__tests__/index.test.ts b/packages/hooks/src/useInViewport/__tests__/index.test.ts index 97aa9c6bbd..d6f305a0d7 100644 --- a/packages/hooks/src/useInViewport/__tests__/index.test.ts +++ b/packages/hooks/src/useInViewport/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useInViewport from '../index'; const targetEl = document.createElement('div'); diff --git a/packages/hooks/src/useInfiniteScroll/__tests__/index.test.ts b/packages/hooks/src/useInfiniteScroll/__tests__/index.test.ts index 1c3e8ce882..99c49fa66d 100644 --- a/packages/hooks/src/useInfiniteScroll/__tests__/index.test.ts +++ b/packages/hooks/src/useInfiniteScroll/__tests__/index.test.ts @@ -1,5 +1,6 @@ import { useState } from 'react'; -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useInfiniteScroll from '..'; import type { Data, Service, InfiniteScrollOptions } from '../types'; import { sleep } from '../../utils/testingHelpers'; diff --git a/packages/hooks/src/useLocalStorageState/__tests__/index.test.ts b/packages/hooks/src/useLocalStorageState/__tests__/index.test.ts index 1368ebe922..406455415b 100644 --- a/packages/hooks/src/useLocalStorageState/__tests__/index.test.ts +++ b/packages/hooks/src/useLocalStorageState/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import type { Options } from '../../createUseStorageState'; import useLocalStorageState from '../index'; diff --git a/packages/hooks/src/useLockFn/__tests__/index.test.ts b/packages/hooks/src/useLockFn/__tests__/index.test.ts index a91f3499f4..a950e05321 100644 --- a/packages/hooks/src/useLockFn/__tests__/index.test.ts +++ b/packages/hooks/src/useLockFn/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import { useRef, useCallback, useState } from 'react'; import useLockFn from '../index'; import { sleep } from '../../utils/testingHelpers'; diff --git a/packages/hooks/src/useMap/__tests__/index.test.ts b/packages/hooks/src/useMap/__tests__/index.test.ts index 019c8b0893..0911276046 100644 --- a/packages/hooks/src/useMap/__tests__/index.test.ts +++ b/packages/hooks/src/useMap/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useMap from '../index'; const setup = (initialMap?: Iterable<[any, any]>) => renderHook(() => useMap(initialMap)); diff --git a/packages/hooks/src/useMemoizedFn/__tests__/index.test.ts b/packages/hooks/src/useMemoizedFn/__tests__/index.test.ts index 86636d506c..e96a1f293a 100644 --- a/packages/hooks/src/useMemoizedFn/__tests__/index.test.ts +++ b/packages/hooks/src/useMemoizedFn/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import { useState } from 'react'; import useMemoizedFn from '../'; diff --git a/packages/hooks/src/useNetwork/__tests__/index.test.ts b/packages/hooks/src/useNetwork/__tests__/index.test.ts index 54a1a6e421..eec1d3f282 100644 --- a/packages/hooks/src/useNetwork/__tests__/index.test.ts +++ b/packages/hooks/src/useNetwork/__tests__/index.test.ts @@ -1,5 +1,6 @@ import useNetwork from '../index'; -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; describe('useNetwork', () => { it('toggle network state', () => { diff --git a/packages/hooks/src/useRafState/__tests__/index.test.ts b/packages/hooks/src/useRafState/__tests__/index.test.ts index 9dc1bfc72f..e7543036d5 100644 --- a/packages/hooks/src/useRafState/__tests__/index.test.ts +++ b/packages/hooks/src/useRafState/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useRafState from '../index'; describe('useRafState', () => { diff --git a/packages/hooks/src/useReactive/__tests__/index.test.tsx b/packages/hooks/src/useReactive/__tests__/index.test.tsx index 954d3b71ec..5e450c8549 100644 --- a/packages/hooks/src/useReactive/__tests__/index.test.tsx +++ b/packages/hooks/src/useReactive/__tests__/index.test.tsx @@ -1,5 +1,5 @@ -import { fireEvent, render, renderHook, act } from '@testing-library/react'; -import React from 'react'; +import { fireEvent, render, renderHook } from '@testing-library/react'; +import React, { act } from 'react'; import useReactive from '../'; const Demo = () => { diff --git a/packages/hooks/src/useRequest/__tests__/useAutoRunPlugin.test.ts b/packages/hooks/src/useRequest/__tests__/useAutoRunPlugin.test.ts index ea40d5012c..52e340bf9a 100644 --- a/packages/hooks/src/useRequest/__tests__/useAutoRunPlugin.test.ts +++ b/packages/hooks/src/useRequest/__tests__/useAutoRunPlugin.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook, waitFor } from '@testing-library/react'; +import { renderHook, waitFor } from '@testing-library/react'; +import { act } from 'react'; import useRequest from '../index'; import { request } from '../../utils/testingHelpers'; diff --git a/packages/hooks/src/useRequest/__tests__/useCachePlugin.test.tsx b/packages/hooks/src/useRequest/__tests__/useCachePlugin.test.tsx index aec3e5926d..02d6ad9fee 100644 --- a/packages/hooks/src/useRequest/__tests__/useCachePlugin.test.tsx +++ b/packages/hooks/src/useRequest/__tests__/useCachePlugin.test.tsx @@ -1,5 +1,6 @@ -import { act, renderHook, waitFor } from '@testing-library/react'; +import { renderHook, waitFor } from '@testing-library/react'; import { render } from '@testing-library/react'; +import { act } from 'react'; import useRequest, { clearCache } from '../index'; import { request } from '../../utils/testingHelpers'; import React, { useState } from 'react'; diff --git a/packages/hooks/src/useRequest/__tests__/useDebouncePlugin.test.ts b/packages/hooks/src/useRequest/__tests__/useDebouncePlugin.test.ts index f3f9597310..19c6fc5b80 100644 --- a/packages/hooks/src/useRequest/__tests__/useDebouncePlugin.test.ts +++ b/packages/hooks/src/useRequest/__tests__/useDebouncePlugin.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook, waitFor } from '@testing-library/react'; +import { renderHook, waitFor } from '@testing-library/react'; +import { act } from 'react'; import useRequest from '../index'; import { request } from '../../utils/testingHelpers'; diff --git a/packages/hooks/src/useRequest/__tests__/useLoadingDelayPlugin.test.ts b/packages/hooks/src/useRequest/__tests__/useLoadingDelayPlugin.test.ts index cd58c81e25..75e40e7aae 100644 --- a/packages/hooks/src/useRequest/__tests__/useLoadingDelayPlugin.test.ts +++ b/packages/hooks/src/useRequest/__tests__/useLoadingDelayPlugin.test.ts @@ -1,5 +1,6 @@ -import { act, renderHook, waitFor } from '@testing-library/react'; +import { renderHook, waitFor } from '@testing-library/react'; import type { RenderHookResult } from '@testing-library/react'; +import { act } from 'react'; import useRequest from '../index'; import { request } from '../../utils/testingHelpers'; diff --git a/packages/hooks/src/useRequest/__tests__/usePollingPlugin.test.ts b/packages/hooks/src/useRequest/__tests__/usePollingPlugin.test.ts index b7a01c4e9f..8beacf317c 100644 --- a/packages/hooks/src/useRequest/__tests__/usePollingPlugin.test.ts +++ b/packages/hooks/src/useRequest/__tests__/usePollingPlugin.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook, waitFor } from '@testing-library/react'; +import { renderHook, waitFor } from '@testing-library/react'; +import { act } from 'react'; import useRequest from '../index'; import { request } from '../../utils/testingHelpers'; diff --git a/packages/hooks/src/useRequest/__tests__/useRefreshOnWindowFocusPlugin.test.ts b/packages/hooks/src/useRequest/__tests__/useRefreshOnWindowFocusPlugin.test.ts index 2924291d0d..ca5cde8618 100644 --- a/packages/hooks/src/useRequest/__tests__/useRefreshOnWindowFocusPlugin.test.ts +++ b/packages/hooks/src/useRequest/__tests__/useRefreshOnWindowFocusPlugin.test.ts @@ -1,5 +1,5 @@ -import { act, renderHook, waitFor } from '@testing-library/react'; -import { fireEvent } from '@testing-library/react'; +import { fireEvent , renderHook, waitFor } from '@testing-library/react'; +import { act } from 'react'; import useRequest from '../index'; import { request } from '../../utils/testingHelpers'; diff --git a/packages/hooks/src/useRequest/__tests__/useRetryPlugin.test.ts b/packages/hooks/src/useRequest/__tests__/useRetryPlugin.test.ts index e4e969938c..85f689587a 100644 --- a/packages/hooks/src/useRequest/__tests__/useRetryPlugin.test.ts +++ b/packages/hooks/src/useRequest/__tests__/useRetryPlugin.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook, waitFor } from '@testing-library/react'; +import { renderHook, waitFor } from '@testing-library/react'; +import { act } from 'react'; import useRequest from '../index'; import { request } from '../../utils/testingHelpers'; diff --git a/packages/hooks/src/useRequest/__tests__/useThrottlePlugin.test.ts b/packages/hooks/src/useRequest/__tests__/useThrottlePlugin.test.ts index 149de55f64..7f3b0780eb 100644 --- a/packages/hooks/src/useRequest/__tests__/useThrottlePlugin.test.ts +++ b/packages/hooks/src/useRequest/__tests__/useThrottlePlugin.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useRequest from '../index'; import { request } from '../../utils/testingHelpers'; diff --git a/packages/hooks/src/useResetState/__tests__/index.test.ts b/packages/hooks/src/useResetState/__tests__/index.test.ts index b4fa76640b..c06fa2adde 100644 --- a/packages/hooks/src/useResetState/__tests__/index.test.ts +++ b/packages/hooks/src/useResetState/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useResetState from '../index'; describe('useResetState', () => { diff --git a/packages/hooks/src/useResponsive/__tests__/index.test.ts b/packages/hooks/src/useResponsive/__tests__/index.test.ts index 0ece26a151..71b665efa2 100644 --- a/packages/hooks/src/useResponsive/__tests__/index.test.ts +++ b/packages/hooks/src/useResponsive/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '../../utils/tests'; +import { renderHook } from '../../utils/tests'; +import { act } from 'react'; import useResponsive from '../'; describe('useResponsive', () => { diff --git a/packages/hooks/src/useSafeState/__tests__/index.test.ts b/packages/hooks/src/useSafeState/__tests__/index.test.ts index a74d32911b..bd7e0fb3a4 100644 --- a/packages/hooks/src/useSafeState/__tests__/index.test.ts +++ b/packages/hooks/src/useSafeState/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook, RenderHookResult } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useSafeState from '../index'; describe('useSetState', () => { diff --git a/packages/hooks/src/useSelections/__tests__/index.test.ts b/packages/hooks/src/useSelections/__tests__/index.test.ts index 07088485f0..d6f555053a 100644 --- a/packages/hooks/src/useSelections/__tests__/index.test.ts +++ b/packages/hooks/src/useSelections/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import { useState } from 'react'; import useSelections from '../index'; import type { Options } from '../index'; diff --git a/packages/hooks/src/useSessionStorageState/__tests__/index.test.ts b/packages/hooks/src/useSessionStorageState/__tests__/index.test.ts index d7fab6d2c1..936b7e77f1 100644 --- a/packages/hooks/src/useSessionStorageState/__tests__/index.test.ts +++ b/packages/hooks/src/useSessionStorageState/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useSessionStorageState from '../index'; describe('useSessionStorageState', () => { diff --git a/packages/hooks/src/useSet/__tests__/index.test.ts b/packages/hooks/src/useSet/__tests__/index.test.ts index 50ed21ff53..ae284ac4e0 100644 --- a/packages/hooks/src/useSet/__tests__/index.test.ts +++ b/packages/hooks/src/useSet/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useSet from '../index'; const setUp = (initialSet?: Iterable) => renderHook(() => useSet(initialSet)); diff --git a/packages/hooks/src/useSetState/__tests__/index.test.ts b/packages/hooks/src/useSetState/__tests__/index.test.ts index 57d28480b5..e6fdb0ac2d 100644 --- a/packages/hooks/src/useSetState/__tests__/index.test.ts +++ b/packages/hooks/src/useSetState/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useSetState from '../index'; describe('useSetState', () => { diff --git a/packages/hooks/src/useSize/__tests__/index.test.tsx b/packages/hooks/src/useSize/__tests__/index.test.tsx index a7458da33c..d227f3d1ae 100644 --- a/packages/hooks/src/useSize/__tests__/index.test.tsx +++ b/packages/hooks/src/useSize/__tests__/index.test.tsx @@ -1,5 +1,5 @@ -import React, { useRef } from 'react'; -import { renderHook, act, render, screen } from '@testing-library/react'; +import React, { useRef ,act } from 'react'; +import { renderHook, render, screen } from '@testing-library/react'; import useSize from '../index'; let callback; diff --git a/packages/hooks/src/useTextSelection/__tests__/index.test.ts b/packages/hooks/src/useTextSelection/__tests__/index.test.ts index 39342d87ad..d5aa7019fd 100644 --- a/packages/hooks/src/useTextSelection/__tests__/index.test.ts +++ b/packages/hooks/src/useTextSelection/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useTextSelection from '../index'; // test about Resize Observer see https://github.com/que-etc/resize-observer-polyfill/tree/master/tests diff --git a/packages/hooks/src/useTheme/__test__/index.test.ts b/packages/hooks/src/useTheme/__test__/index.test.ts index 3343269439..e965dc52f4 100644 --- a/packages/hooks/src/useTheme/__test__/index.test.ts +++ b/packages/hooks/src/useTheme/__test__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useTheme from '../index'; describe('useTheme', () => { diff --git a/packages/hooks/src/useThrottle/__tests__/index.test.ts b/packages/hooks/src/useThrottle/__tests__/index.test.ts index 8938dd6766..5ab6011212 100644 --- a/packages/hooks/src/useThrottle/__tests__/index.test.ts +++ b/packages/hooks/src/useThrottle/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useThrottle from '../index'; import { sleep } from '../../utils/testingHelpers'; diff --git a/packages/hooks/src/useThrottleEffect/__tests__/index.test.ts b/packages/hooks/src/useThrottleEffect/__tests__/index.test.ts index 75b1a54439..061b734c02 100644 --- a/packages/hooks/src/useThrottleEffect/__tests__/index.test.ts +++ b/packages/hooks/src/useThrottleEffect/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useThrottleEffect from '../index'; import { sleep } from '../../utils/testingHelpers'; diff --git a/packages/hooks/src/useThrottleFn/__tests__/index.test.ts b/packages/hooks/src/useThrottleFn/__tests__/index.test.ts index e991d886b3..8e0048d45a 100644 --- a/packages/hooks/src/useThrottleFn/__tests__/index.test.ts +++ b/packages/hooks/src/useThrottleFn/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useThrottleFn from '../index'; import { sleep } from '../../utils/testingHelpers'; diff --git a/packages/hooks/src/useTitle/__tests__/index.test.ts b/packages/hooks/src/useTitle/__tests__/index.test.ts index 894b613e48..b1af955922 100644 --- a/packages/hooks/src/useTitle/__tests__/index.test.ts +++ b/packages/hooks/src/useTitle/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useTitle from '../index'; describe('useTitle', () => { diff --git a/packages/hooks/src/useToggle/__tests__/index.test.ts b/packages/hooks/src/useToggle/__tests__/index.test.ts index ba196142b1..83db362382 100644 --- a/packages/hooks/src/useToggle/__tests__/index.test.ts +++ b/packages/hooks/src/useToggle/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useToggle from '../index'; const callToggle = (hook: any) => { diff --git a/packages/hooks/src/useUpdate/__tests__/index.test.ts b/packages/hooks/src/useUpdate/__tests__/index.test.ts index 577d21790c..a02412c501 100644 --- a/packages/hooks/src/useUpdate/__tests__/index.test.ts +++ b/packages/hooks/src/useUpdate/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useUpdate from '..'; import useMemoizedFn from '../../useMemoizedFn'; diff --git a/packages/hooks/src/useVirtualList/__tests__/index.test.ts b/packages/hooks/src/useVirtualList/__tests__/index.test.ts index 86a9bf3b14..56d62e7b05 100644 --- a/packages/hooks/src/useVirtualList/__tests__/index.test.ts +++ b/packages/hooks/src/useVirtualList/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import useVirtualList, { Options } from '../index'; describe('useVirtualList', () => { diff --git a/packages/hooks/src/useWebSocket/__tests__/index.test.ts b/packages/hooks/src/useWebSocket/__tests__/index.test.ts index ad6949577b..73e574b58c 100644 --- a/packages/hooks/src/useWebSocket/__tests__/index.test.ts +++ b/packages/hooks/src/useWebSocket/__tests__/index.test.ts @@ -1,4 +1,5 @@ -import { act, renderHook } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; +import { act } from 'react'; import WS from 'jest-websocket-mock'; import { sleep } from '../../utils/testingHelpers'; import useWebSocket, { ReadyState } from '../index'; diff --git a/packages/hooks/src/useWhyDidYouUpdate/__tests__/index.test.ts b/packages/hooks/src/useWhyDidYouUpdate/__tests__/index.test.ts index b110c23db6..87af9c098c 100644 --- a/packages/hooks/src/useWhyDidYouUpdate/__tests__/index.test.ts +++ b/packages/hooks/src/useWhyDidYouUpdate/__tests__/index.test.ts @@ -1,6 +1,6 @@ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; import useWhyDidYouUpdate from '../index'; -import { useState } from 'react'; +import { useState, act } from 'react'; describe('useWhyDidYouUpdate', () => { it('should work', () => {