Skip to content
Merged
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
18 changes: 18 additions & 0 deletions packages/query-core/src/__tests__/queryClient.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,24 @@ describe('queryClient', () => {
})
})

describe('isMutating', () => {
test('should return length of mutating', async () => {
expect(queryClient.isMutating()).toBe(0)
new MutationObserver(queryClient, {
mutationFn: () => sleep(10).then(() => 'data'),
}).mutate()
expect(queryClient.isMutating()).toBe(1)
new MutationObserver(queryClient, {
mutationFn: () => sleep(5).then(() => 'data'),
}).mutate()
expect(queryClient.isMutating()).toBe(2)
await vi.advanceTimersByTimeAsync(5)
expect(queryClient.isMutating()).toEqual(1)
await vi.advanceTimersByTimeAsync(5)
expect(queryClient.isMutating()).toEqual(0)
})
})

describe('getQueryData', () => {
test('should return the query data if the query is found', () => {
const key = queryKey()
Expand Down
Loading