Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions packages/lit-query/src/__tests__/useMutationState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('useMutationState', () => {

it('should not request another update when mutation cache emits with unchanged selected state', async () => {
const mutationKey = createKey()
const mutation = queryClient.getMutationCache().build(queryClient, {
const existingMutation = queryClient.getMutationCache().build(queryClient, {
mutationKey,
})

Expand Down Expand Up @@ -127,7 +127,7 @@ describe('useMutationState', () => {
for (let i = 0; i < 5; i += 1) {
queryClient.getMutationCache().notify({
type: 'updated',
mutation,
mutation: existingMutation,
action: { type: 'pause' } as never,
})
await vi.advanceTimersByTimeAsync(0)
Expand Down
11 changes: 7 additions & 4 deletions packages/preact-query/src/__tests__/useMutationState.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ describe('useMutationState', () => {
const queryClient = new QueryClient()
const key = createKey()
const cache = queryClient.getMutationCache()
const mutation = cache.build(queryClient, {
const existingMutation = cache.build(queryClient, {
mutationKey: key,
meta: { time: 0 },
})
const state = mutation.state
const state = existingMutation.state
const filters = { mutationKey: key }
const select = (mutation: Mutation) =>
resultType === 'Date'
Expand All @@ -336,7 +336,10 @@ describe('useMutationState', () => {
),
).toBeInTheDocument()

mutation.setOptions({ ...mutation.options, meta: { time: 1000 } })
existingMutation.setOptions({
...existingMutation.options,
meta: { time: 1000 },
})
rendered.rerender(<Page />)
expect(
rendered.getByText(
Expand All @@ -345,7 +348,7 @@ describe('useMutationState', () => {
: 'result: [{"time":1000}]',
),
).toBeInTheDocument()
expect(mutation.state).toBe(state)
expect(existingMutation.state).toBe(state)
expect(onCacheChange).not.toHaveBeenCalled()
unsubscribe()
},
Expand Down
11 changes: 7 additions & 4 deletions packages/react-query/src/__tests__/useMutationState.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ describe('useMutationState', () => {
const queryClient = new QueryClient()
const key = createKey()
const cache = queryClient.getMutationCache()
const mutation = cache.build(queryClient, {
const existingMutation = cache.build(queryClient, {
mutationKey: key,
meta: { time: 0 },
})
const state = mutation.state
const state = existingMutation.state
const filters = { mutationKey: key }
const select = (mutation: Mutation) =>
resultType === 'Date'
Expand All @@ -336,7 +336,10 @@ describe('useMutationState', () => {
),
).toBeInTheDocument()

mutation.setOptions({ ...mutation.options, meta: { time: 1000 } })
existingMutation.setOptions({
...existingMutation.options,
meta: { time: 1000 },
})
rendered.rerender(<Page />)
expect(
rendered.getByText(
Expand All @@ -345,7 +348,7 @@ describe('useMutationState', () => {
: 'result: [{"time":1000}]',
),
).toBeInTheDocument()
expect(mutation.state).toBe(state)
expect(existingMutation.state).toBe(state)
expect(onCacheChange).not.toHaveBeenCalled()
unsubscribe()
},
Expand Down
Loading