|
6 | 6 | actionsReducer, |
7 | 7 | setupApiStore, |
8 | 8 | useRenderCounter, |
| 9 | + waitForFakeTimer, |
9 | 10 | waitMs, |
10 | 11 | withProvider, |
11 | 12 | } from '@internal/tests/utils/helpers' |
@@ -46,7 +47,7 @@ interface Item { |
46 | 47 |
|
47 | 48 | const api = createApi({ |
48 | 49 | baseQuery: async (arg: any) => { |
49 | | - await waitMs(150) |
| 50 | + await waitForFakeTimer(150) |
50 | 51 | if (arg?.body && 'amount' in arg.body) { |
51 | 52 | amount += 1 |
52 | 53 | } |
@@ -774,7 +775,7 @@ describe('hooks tests', () => { |
774 | 775 | resPromise = refetch() |
775 | 776 | }) |
776 | 777 | expect(resPromise).toBeInstanceOf(Promise) |
777 | | - const res = await resPromise |
| 778 | + const res = await act(() => resPromise) |
778 | 779 | expect(res.data!.amount).toBeGreaterThan(originalAmount) |
779 | 780 | }) |
780 | 781 |
|
@@ -954,15 +955,15 @@ describe('hooks tests', () => { |
954 | 955 | // Allow at least three state effects to hit. |
955 | 956 | // Trying to see if any [true, false, true] occurs. |
956 | 957 | await act(async () => { |
957 | | - await waitMs(1) |
| 958 | + await waitForFakeTimer(150) |
958 | 959 | }) |
959 | 960 |
|
960 | 961 | await act(async () => { |
961 | | - await waitMs(1) |
| 962 | + await waitForFakeTimer(150) |
962 | 963 | }) |
963 | 964 |
|
964 | 965 | await act(async () => { |
965 | | - await waitMs(1) |
| 966 | + await waitForFakeTimer(150) |
966 | 967 | }) |
967 | 968 |
|
968 | 969 | // Find if at any time the isLoading state has reverted |
@@ -1723,7 +1724,8 @@ describe('hooks tests', () => { |
1723 | 1724 | expect(screen.getByTestId('isFetching').textContent).toBe('false'), |
1724 | 1725 | ) |
1725 | 1726 |
|
1726 | | - userEvent.hover(screen.getByTestId('highPriority')) |
| 1727 | + await userEvent.hover(screen.getByTestId('highPriority')) |
| 1728 | + |
1727 | 1729 | expect( |
1728 | 1730 | api.endpoints.getUser.select(USER_ID)(storeRef.store.getState() as any), |
1729 | 1731 | ).toEqual({ |
@@ -1860,7 +1862,7 @@ describe('hooks tests', () => { |
1860 | 1862 | await waitMs(400) |
1861 | 1863 |
|
1862 | 1864 | // This should run the query being that we're past the threshold |
1863 | | - userEvent.hover(screen.getByTestId('lowPriority')) |
| 1865 | + await userEvent.hover(screen.getByTestId('lowPriority')) |
1864 | 1866 | expect( |
1865 | 1867 | api.endpoints.getUser.select(USER_ID)(storeRef.store.getState() as any), |
1866 | 1868 | ).toEqual({ |
@@ -1960,7 +1962,7 @@ describe('hooks tests', () => { |
1960 | 1962 |
|
1961 | 1963 | render(<User />, { wrapper: storeRef.wrapper }) |
1962 | 1964 |
|
1963 | | - userEvent.hover(screen.getByTestId('lowPriority')) |
| 1965 | + await userEvent.hover(screen.getByTestId('lowPriority')) |
1964 | 1966 |
|
1965 | 1967 | expect( |
1966 | 1968 | api.endpoints.getUser.select(USER_ID)(storeRef.store.getState() as any), |
@@ -2852,6 +2854,11 @@ describe('skip behavior', () => { |
2852 | 2854 | await act(async () => { |
2853 | 2855 | rerender([1]) |
2854 | 2856 | }) |
| 2857 | + |
| 2858 | + await act(async () => { |
| 2859 | + await waitForFakeTimer(150) |
| 2860 | + }) |
| 2861 | + |
2855 | 2862 | expect(result.current).toMatchObject({ status: QueryStatus.fulfilled }) |
2856 | 2863 | await waitMs(1) |
2857 | 2864 | expect(getSubscriptionCount('getUser(1)')).toBe(1) |
@@ -2888,6 +2895,11 @@ describe('skip behavior', () => { |
2888 | 2895 | await act(async () => { |
2889 | 2896 | rerender([1]) |
2890 | 2897 | }) |
| 2898 | + |
| 2899 | + await act(async () => { |
| 2900 | + await waitForFakeTimer(150) |
| 2901 | + }) |
| 2902 | + |
2891 | 2903 | expect(result.current).toMatchObject({ status: QueryStatus.fulfilled }) |
2892 | 2904 | await waitMs(1) |
2893 | 2905 | expect(getSubscriptionCount('getUser(1)')).toBe(1) |
@@ -2916,7 +2928,7 @@ describe('skip behavior', () => { |
2916 | 2928 | ) |
2917 | 2929 |
|
2918 | 2930 | await act(async () => { |
2919 | | - await waitMs(1) |
| 2931 | + await waitForFakeTimer(150) |
2920 | 2932 | }) |
2921 | 2933 |
|
2922 | 2934 | // Normal fulfilled result, with both `data` and `currentData` |
|
0 commit comments