Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

mutationCache.test.ts

39 lines1.0 KB

1import { beforeAll, describe, expect, test, vi } from 'vitest'
2import { ref } from 'vue-demi'
3import { MutationCache as MutationCacheOrigin } from '@tanstack/query-core'
4import { MutationCache } from '../mutationCache'
5​
6describe('MutationCache', () => {
7 beforeAll(() => {
8 vi.spyOn(MutationCacheOrigin.prototype, 'find')
9 vi.spyOn(MutationCacheOrigin.prototype, 'findAll')
10 })
11​
12 describe('find', () => {
13 test('should properly unwrap parameters', () => {
14 const mutationCache = new MutationCache()
15​
16 mutationCache.find({
17 mutationKey: ref(['baz']),
18 })
19​
20 expect(MutationCacheOrigin.prototype.find).toBeCalledWith({
21 mutationKey: ['baz'],
22 })
23 })
24 })
25​
26 describe('findAll', () => {
27 test('should properly unwrap parameters', () => {
28 const mutationCache = new MutationCache()
29​
30 mutationCache.findAll({
31 mutationKey: ref(['baz']),
32 })
33​
34 expect(MutationCacheOrigin.prototype.findAll).toBeCalledWith({
35 mutationKey: ['baz'],
36 })
37 })
38 })
39})