Open History to see the last commit
1import { ref } from 'vue-demi'
2import { QueryCache as QueryCacheOrigin } from '@tanstack/query-core'
3β
4import { QueryCache } from '../queryCache'
5β
6describe('QueryCache', () => {
7 beforeAll(() => {
8 jest.spyOn(QueryCacheOrigin.prototype, 'find')
9 jest.spyOn(QueryCacheOrigin.prototype, 'findAll')
10 })
11β
12 describe('find', () => {
13 test('should properly unwrap parameters', async () => {
14 const queryCache = new QueryCache()
15β
16 queryCache.find({
17 queryKey: ['foo', ref('bar')],
18 })
19β
20 expect(QueryCacheOrigin.prototype.find).toBeCalledWith({
21 queryKey: ['foo', 'bar'],
22 exact: true, //Exact is true, as `find` in QueryCacheOrigin sets exact to true in the passed filters if exact is undefined
23 })
24 })
25 })
26β
27 describe('findAll', () => {
28 test('should properly unwrap two parameters', async () => {
29 const queryCache = new QueryCache()
30β
31 queryCache.findAll({
32 queryKey: ['foo', ref('bar')],
33 })
34β
35 expect(QueryCacheOrigin.prototype.findAll).toBeCalledWith({
36 queryKey: ['foo', 'bar'],
37 })
38 })
39β
40 test('should default to empty filters', async () => {
41 const queryCache = new QueryCache()
42β
43 queryCache.findAll()
44β
45 expect(QueryCacheOrigin.prototype.findAll).toBeCalledWith({})
46 })
47 })
48})