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

mutationCache.test.ts

40 lines1013 Bytes

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