File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
packages/query-core/src/__tests__ Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -445,4 +445,27 @@ describe('mutationCache', () => {
445445 expect ( onSuccess ) . toHaveBeenCalledTimes ( 1 )
446446 } )
447447 } )
448+
449+ describe ( 'remove' , ( ) => {
450+ test ( 'should remove only the target mutation from scope when multiple scoped mutations exist' , ( ) => {
451+ const testCache = new MutationCache ( )
452+ const testClient = new QueryClient ( { mutationCache : testCache } )
453+
454+ const mutation1 = testCache . build ( testClient , {
455+ scope : { id : 'scope1' } ,
456+ mutationFn : ( ) => Promise . resolve ( 'data1' ) ,
457+ } )
458+ const mutation2 = testCache . build ( testClient , {
459+ scope : { id : 'scope1' } ,
460+ mutationFn : ( ) => Promise . resolve ( 'data2' ) ,
461+ } )
462+
463+ expect ( testCache . getAll ( ) ) . toHaveLength ( 2 )
464+
465+ testCache . remove ( mutation1 )
466+
467+ expect ( testCache . getAll ( ) ) . toHaveLength ( 1 )
468+ expect ( testCache . getAll ( ) ) . toEqual ( [ mutation2 ] )
469+ } )
470+ } )
448471} )
You can’t perform that action at this time.
0 commit comments