|
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(10) |
50 | 51 | if (arg?.body && 'amount' in arg.body) { |
51 | 52 | amount += 1 |
52 | 53 | } |
@@ -942,15 +943,15 @@ describe('hooks tests', () => { |
942 | 943 | // Allow at least three state effects to hit. |
943 | 944 | // Trying to see if any [true, false, true] occurs. |
944 | 945 | await act(async () => { |
945 | | - await waitMs(1) |
| 946 | + await waitForFakeTimer(10) |
946 | 947 | }) |
947 | 948 |
|
948 | 949 | await act(async () => { |
949 | | - await waitMs(1) |
| 950 | + await waitForFakeTimer(10) |
950 | 951 | }) |
951 | 952 |
|
952 | 953 | await act(async () => { |
953 | | - await waitMs(1) |
| 954 | + await waitForFakeTimer(10) |
954 | 955 | }) |
955 | 956 |
|
956 | 957 | // Find if at any time the isLoading state has reverted |
@@ -1669,7 +1670,8 @@ describe('hooks tests', () => { |
1669 | 1670 | expect(screen.getByTestId('isFetching').textContent).toBe('false'), |
1670 | 1671 | ) |
1671 | 1672 |
|
1672 | | - userEvent.hover(screen.getByTestId('highPriority')) |
| 1673 | + await userEvent.hover(screen.getByTestId('highPriority')) |
| 1674 | + |
1673 | 1675 | expect( |
1674 | 1676 | api.endpoints.getUser.select(USER_ID)(storeRef.store.getState() as any), |
1675 | 1677 | ).toEqual({ |
@@ -1806,7 +1808,7 @@ describe('hooks tests', () => { |
1806 | 1808 | await waitMs(400) |
1807 | 1809 |
|
1808 | 1810 | // This should run the query being that we're past the threshold |
1809 | | - userEvent.hover(screen.getByTestId('lowPriority')) |
| 1811 | + await userEvent.hover(screen.getByTestId('lowPriority')) |
1810 | 1812 | expect( |
1811 | 1813 | api.endpoints.getUser.select(USER_ID)(storeRef.store.getState() as any), |
1812 | 1814 | ).toEqual({ |
@@ -1906,7 +1908,7 @@ describe('hooks tests', () => { |
1906 | 1908 |
|
1907 | 1909 | render(<User />, { wrapper: storeRef.wrapper }) |
1908 | 1910 |
|
1909 | | - userEvent.hover(screen.getByTestId('lowPriority')) |
| 1911 | + await userEvent.hover(screen.getByTestId('lowPriority')) |
1910 | 1912 |
|
1911 | 1913 | expect( |
1912 | 1914 | api.endpoints.getUser.select(USER_ID)(storeRef.store.getState() as any), |
@@ -2798,6 +2800,11 @@ describe('skip behavior', () => { |
2798 | 2800 | await act(async () => { |
2799 | 2801 | rerender([1]) |
2800 | 2802 | }) |
| 2803 | + |
| 2804 | + await act(async () => { |
| 2805 | + await waitForFakeTimer(10) |
| 2806 | + }) |
| 2807 | + |
2801 | 2808 | expect(result.current).toMatchObject({ status: QueryStatus.fulfilled }) |
2802 | 2809 | await waitMs(1) |
2803 | 2810 | expect(getSubscriptionCount('getUser(1)')).toBe(1) |
@@ -2834,6 +2841,11 @@ describe('skip behavior', () => { |
2834 | 2841 | await act(async () => { |
2835 | 2842 | rerender([1]) |
2836 | 2843 | }) |
| 2844 | + |
| 2845 | + await act(async () => { |
| 2846 | + await waitForFakeTimer(10) |
| 2847 | + }) |
| 2848 | + |
2837 | 2849 | expect(result.current).toMatchObject({ status: QueryStatus.fulfilled }) |
2838 | 2850 | await waitMs(1) |
2839 | 2851 | expect(getSubscriptionCount('getUser(1)')).toBe(1) |
@@ -2862,7 +2874,7 @@ describe('skip behavior', () => { |
2862 | 2874 | ) |
2863 | 2875 |
|
2864 | 2876 | await act(async () => { |
2865 | | - await waitMs(1) |
| 2877 | + await waitForFakeTimer(10) |
2866 | 2878 | }) |
2867 | 2879 |
|
2868 | 2880 | // Normal fulfilled result, with both `data` and `currentData` |
|
0 commit comments