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__/mutationObserver.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -476,4 +476,27 @@ describe('mutationObserver', () => {
unsubscribe()
})
})

test('should not notify cache when setOptions is called with same options', () => {
const mutationObserver = new MutationObserver(queryClient, {
mutationFn: (text: string) => Promise.resolve(text),
})

const notifySpy = vi.spyOn(queryClient.getMutationCache(), 'notify')

const unsubscribe = mutationObserver.subscribe(() => undefined)

notifySpy.mockClear()

// Call setOptions with the same options
mutationObserver.setOptions({
mutationFn: mutationObserver.options.mutationFn,
})

expect(notifySpy).not.toHaveBeenCalledWith(
expect.objectContaining({ type: 'observerOptionsUpdated' }),
)

unsubscribe()
})
})
Loading