Skip to content

Commit

Permalink
Added mockClear() to mockBaseQuery in failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
riqts committed Jan 24, 2024
1 parent e7fce61 commit 65a6ae3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/toolkit/src/query/tests/polling.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ describe('polling tests', () => {
})

it('respects skipPollOnFocusLost', async () => {
mockBaseQuery.mockClear()
storeRef.store.dispatch(
getPosts.initiate(1, {
subscriptionOptions: { pollingInterval: 10, skipPollOnFocusLost: true },
Expand All @@ -146,6 +147,7 @@ describe('polling tests', () => {

await delay(30)
const callsWithoutSkip = mockBaseQuery.mock.calls.length
console.log(callsWithSkip, callsWithoutSkip)

expect(callsWithSkip).toBe(1)
expect(callsWithoutSkip).toBeGreaterThan(2)
Expand Down Expand Up @@ -183,7 +185,7 @@ describe('polling tests', () => {
const { requestId, queryCacheKey, ...subscription } =
storeRef.store.dispatch(
getPosts.initiate(1, {
subscriptionOptions: { pollingInterval: 10 },
subscriptionOptions: { pollingInterval: 10, skipPollOnFocusLost: false },
subscribe: true,
})
)
Expand Down

0 comments on commit 65a6ae3

Please sign in to comment.