|
6 | 6 | actionsReducer,
|
7 | 7 | setupApiStore,
|
8 | 8 | useRenderCounter,
|
| 9 | + waitForFakeTimer, |
9 | 10 | waitMs,
|
10 | 11 | withProvider,
|
11 | 12 | } from '@internal/tests/utils/helpers'
|
@@ -47,7 +48,7 @@ interface Item {
|
47 | 48 |
|
48 | 49 | const api = createApi({
|
49 | 50 | baseQuery: async (arg: any) => {
|
50 |
| - await waitMs(150) |
| 51 | + await waitForFakeTimer(150) |
51 | 52 | if (arg?.body && 'amount' in arg.body) {
|
52 | 53 | amount += 1
|
53 | 54 | }
|
@@ -915,7 +916,7 @@ describe('hooks tests', () => {
|
915 | 916 | resPromise = refetch()
|
916 | 917 | })
|
917 | 918 | expect(resPromise).toBeInstanceOf(Promise)
|
918 |
| - const res = await resPromise |
| 919 | + const res = await act(() => resPromise) |
919 | 920 | expect(res.data!.amount).toBeGreaterThan(originalAmount)
|
920 | 921 | })
|
921 | 922 |
|
@@ -1095,15 +1096,15 @@ describe('hooks tests', () => {
|
1095 | 1096 | // Allow at least three state effects to hit.
|
1096 | 1097 | // Trying to see if any [true, false, true] occurs.
|
1097 | 1098 | await act(async () => {
|
1098 |
| - await waitMs(1) |
| 1099 | + await waitForFakeTimer(150) |
1099 | 1100 | })
|
1100 | 1101 |
|
1101 | 1102 | await act(async () => {
|
1102 |
| - await waitMs(1) |
| 1103 | + await waitForFakeTimer(150) |
1103 | 1104 | })
|
1104 | 1105 |
|
1105 | 1106 | await act(async () => {
|
1106 |
| - await waitMs(1) |
| 1107 | + await waitForFakeTimer(150) |
1107 | 1108 | })
|
1108 | 1109 |
|
1109 | 1110 | // Find if at any time the isLoading state has reverted
|
@@ -1864,7 +1865,8 @@ describe('hooks tests', () => {
|
1864 | 1865 | expect(screen.getByTestId('isFetching').textContent).toBe('false'),
|
1865 | 1866 | )
|
1866 | 1867 |
|
1867 |
| - userEvent.hover(screen.getByTestId('highPriority')) |
| 1868 | + await userEvent.hover(screen.getByTestId('highPriority')) |
| 1869 | + |
1868 | 1870 | expect(
|
1869 | 1871 | api.endpoints.getUser.select(USER_ID)(storeRef.store.getState() as any),
|
1870 | 1872 | ).toEqual({
|
@@ -2001,7 +2003,7 @@ describe('hooks tests', () => {
|
2001 | 2003 | await waitMs(400)
|
2002 | 2004 |
|
2003 | 2005 | // This should run the query being that we're past the threshold
|
2004 |
| - userEvent.hover(screen.getByTestId('lowPriority')) |
| 2006 | + await userEvent.hover(screen.getByTestId('lowPriority')) |
2005 | 2007 | expect(
|
2006 | 2008 | api.endpoints.getUser.select(USER_ID)(storeRef.store.getState() as any),
|
2007 | 2009 | ).toEqual({
|
@@ -2101,7 +2103,7 @@ describe('hooks tests', () => {
|
2101 | 2103 |
|
2102 | 2104 | render(<User />, { wrapper: storeRef.wrapper })
|
2103 | 2105 |
|
2104 |
| - userEvent.hover(screen.getByTestId('lowPriority')) |
| 2106 | + await userEvent.hover(screen.getByTestId('lowPriority')) |
2105 | 2107 |
|
2106 | 2108 | expect(
|
2107 | 2109 | api.endpoints.getUser.select(USER_ID)(storeRef.store.getState() as any),
|
@@ -2993,6 +2995,11 @@ describe('skip behavior', () => {
|
2993 | 2995 | await act(async () => {
|
2994 | 2996 | rerender([1])
|
2995 | 2997 | })
|
| 2998 | + |
| 2999 | + await act(async () => { |
| 3000 | + await waitForFakeTimer(150) |
| 3001 | + }) |
| 3002 | + |
2996 | 3003 | expect(result.current).toMatchObject({ status: QueryStatus.fulfilled })
|
2997 | 3004 | await waitMs(1)
|
2998 | 3005 | expect(getSubscriptionCount('getUser(1)')).toBe(1)
|
@@ -3030,6 +3037,11 @@ describe('skip behavior', () => {
|
3030 | 3037 | await act(async () => {
|
3031 | 3038 | rerender([1])
|
3032 | 3039 | })
|
| 3040 | + |
| 3041 | + await act(async () => { |
| 3042 | + await waitForFakeTimer(150) |
| 3043 | + }) |
| 3044 | + |
3033 | 3045 | expect(result.current).toMatchObject({ status: QueryStatus.fulfilled })
|
3034 | 3046 | await waitMs(1)
|
3035 | 3047 | expect(getSubscriptionCount('getUser(1)')).toBe(1)
|
@@ -3059,7 +3071,7 @@ describe('skip behavior', () => {
|
3059 | 3071 | )
|
3060 | 3072 |
|
3061 | 3073 | await act(async () => {
|
3062 |
| - await waitMs(1) |
| 3074 | + await waitForFakeTimer(150) |
3063 | 3075 | })
|
3064 | 3076 |
|
3065 | 3077 | // Normal fulfilled result, with both `data` and `currentData`
|
|
0 commit comments