Skip to content

Commit 8f6f923

Browse files
authored
test(query-persist-client-core/retryStrategies): add test for 'removeOldestQuery' preserving mutations (TanStack#10869)
1 parent b6b9d1a commit 8f6f923

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

packages/query-persist-client-core/src/__tests__/retryStrategies.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,27 @@ describe('removeOldestQuery', () => {
8585

8686
expect(result).toBeUndefined()
8787
})
88+
89+
it('should preserve mutations when removing the oldest query', () => {
90+
queryClient.getMutationCache().build(queryClient, {
91+
mutationFn: () => Promise.resolve('data'),
92+
})
93+
const { mutations } = dehydrate(queryClient, {
94+
shouldDehydrateMutation: () => true,
95+
})
96+
97+
const persistedClient = createPersistedClient(
98+
[createQuery('a', 10)],
99+
mutations,
100+
)
101+
102+
const result = removeOldestQuery({
103+
persistedClient,
104+
error: new Error('full'),
105+
errorCount: 1,
106+
})
107+
108+
expect(result?.clientState.queries).toEqual([])
109+
expect(result?.clientState.mutations).toEqual(mutations)
110+
})
88111
})

0 commit comments

Comments
 (0)