Skip to content

Commit 86b9f20

Browse files
authored
test(*/useMutationState): rename the built 'mutation' to 'existingMutation' to avoid shadowing the 'select' parameter (#12294)
1 parent d09972b commit 86b9f20

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

‎packages/lit-query/src/__tests__/useMutationState.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe('useMutationState', () => {
8888

8989
it('should not request another update when mutation cache emits with unchanged selected state', async () => {
9090
const mutationKey = createKey()
91-
const mutation = queryClient.getMutationCache().build(queryClient, {
91+
const existingMutation = queryClient.getMutationCache().build(queryClient, {
9292
mutationKey,
9393
})
9494

@@ -127,7 +127,7 @@ describe('useMutationState', () => {
127127
for (let i = 0; i < 5; i += 1) {
128128
queryClient.getMutationCache().notify({
129129
type: 'updated',
130-
mutation,
130+
mutation: existingMutation,
131131
action: { type: 'pause' } as never,
132132
})
133133
await vi.advanceTimersByTimeAsync(0)

‎packages/preact-query/src/__tests__/useMutationState.test.tsx‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,11 @@ describe('useMutationState', () => {
308308
const queryClient = new QueryClient()
309309
const key = createKey()
310310
const cache = queryClient.getMutationCache()
311-
const mutation = cache.build(queryClient, {
311+
const existingMutation = cache.build(queryClient, {
312312
mutationKey: key,
313313
meta: { time: 0 },
314314
})
315-
const state = mutation.state
315+
const state = existingMutation.state
316316
const filters = { mutationKey: key }
317317
const select = (mutation: Mutation) =>
318318
resultType === 'Date'
@@ -336,7 +336,10 @@ describe('useMutationState', () => {
336336
),
337337
).toBeInTheDocument()
338338

339-
mutation.setOptions({ ...mutation.options, meta: { time: 1000 } })
339+
existingMutation.setOptions({
340+
...existingMutation.options,
341+
meta: { time: 1000 },
342+
})
340343
rendered.rerender(<Page />)
341344
expect(
342345
rendered.getByText(
@@ -345,7 +348,7 @@ describe('useMutationState', () => {
345348
: 'result: [{"time":1000}]',
346349
),
347350
).toBeInTheDocument()
348-
expect(mutation.state).toBe(state)
351+
expect(existingMutation.state).toBe(state)
349352
expect(onCacheChange).not.toHaveBeenCalled()
350353
unsubscribe()
351354
},

‎packages/react-query/src/__tests__/useMutationState.test.tsx‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,11 @@ describe('useMutationState', () => {
308308
const queryClient = new QueryClient()
309309
const key = createKey()
310310
const cache = queryClient.getMutationCache()
311-
const mutation = cache.build(queryClient, {
311+
const existingMutation = cache.build(queryClient, {
312312
mutationKey: key,
313313
meta: { time: 0 },
314314
})
315-
const state = mutation.state
315+
const state = existingMutation.state
316316
const filters = { mutationKey: key }
317317
const select = (mutation: Mutation) =>
318318
resultType === 'Date'
@@ -336,7 +336,10 @@ describe('useMutationState', () => {
336336
),
337337
).toBeInTheDocument()
338338

339-
mutation.setOptions({ ...mutation.options, meta: { time: 1000 } })
339+
existingMutation.setOptions({
340+
...existingMutation.options,
341+
meta: { time: 1000 },
342+
})
340343
rendered.rerender(<Page />)
341344
expect(
342345
rendered.getByText(
@@ -345,7 +348,7 @@ describe('useMutationState', () => {
345348
: 'result: [{"time":1000}]',
346349
),
347350
).toBeInTheDocument()
348-
expect(mutation.state).toBe(state)
351+
expect(existingMutation.state).toBe(state)
349352
expect(onCacheChange).not.toHaveBeenCalled()
350353
unsubscribe()
351354
},

0 commit comments

Comments
 (0)