Skip to content

Commit 5dd9d9a

Browse files
authored
test(query-core/queryClient): add test for 'getMutationDefaults' matching only relevant mutation defaults (#10099)
1 parent 33679a1 commit 5dd9d9a

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

packages/query-core/src/__tests__/queryClient.test.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,5 +2114,21 @@ describe('queryClient', () => {
21142114
mutationOptions2,
21152115
)
21162116
})
2117+
2118+
test('should return only matching defaults when multiple mutation defaults are set', () => {
2119+
const key1 = queryKey()
2120+
const key2 = queryKey()
2121+
const mutationOptions1 = { retry: 1 }
2122+
const mutationOptions2 = { retry: 2 }
2123+
queryClient.setMutationDefaults(key1, mutationOptions1)
2124+
queryClient.setMutationDefaults(key2, mutationOptions2)
2125+
2126+
expect(queryClient.getMutationDefaults(key1)).toMatchObject(
2127+
mutationOptions1,
2128+
)
2129+
expect(queryClient.getMutationDefaults(key2)).toMatchObject(
2130+
mutationOptions2,
2131+
)
2132+
})
21172133
})
21182134
})

0 commit comments

Comments
 (0)