Skip to content
Open
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
23 changes: 23 additions & 0 deletions packages/query-core/src/__tests__/mutationCache.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -445,4 +445,27 @@ describe('mutationCache', () => {
expect(onSuccess).toHaveBeenCalledTimes(1)
})
})

describe('remove', () => {
test('should remove only the target mutation from scope when multiple scoped mutations exist', () => {
const testCache = new MutationCache()
const testClient = new QueryClient({ mutationCache: testCache })

const mutation1 = testCache.build(testClient, {
scope: { id: 'scope1' },
mutationFn: () => Promise.resolve('data1'),
})
const mutation2 = testCache.build(testClient, {
scope: { id: 'scope1' },
mutationFn: () => Promise.resolve('data2'),
})

expect(testCache.getAll()).toHaveLength(2)

testCache.remove(mutation1)

expect(testCache.getAll()).toHaveLength(1)
expect(testCache.getAll()).toEqual([mutation2])
})
})
})
Loading