Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/query-core/src/__tests__/queryCache.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,22 @@ describe('queryCache', () => {
})
})

describe('QueryCache.remove', () => {
it('should only delete the instance currently stored under its queryHash', () => {
const key = queryKey()

const staleQuery = queryCache.build(queryClient, { queryKey: key })
queryCache.remove(staleQuery)

const currentQuery = queryCache.build(queryClient, { queryKey: key })
expect(currentQuery).not.toBe(staleQuery)

queryCache.remove(staleQuery)

expect(queryCache.get(hashKey(key))).toBe(currentQuery)
})
})

describe('QueryCache.add', () => {
it('should not try to add a query already added to the cache', async () => {
const key = queryKey()
Expand Down
Loading