Open History to see the last commit
1import { ref } from 'vue-demi'
2import { QueryCache as QueryCacheOrigin } from '@tanstack/query-core'
3β
4import { vi } from 'vitest'
5import { QueryCache } from '../queryCache'
6β
7describe('QueryCache', () => {
8 beforeAll(() => {
9 vi.spyOn(QueryCacheOrigin.prototype, 'find')
10 vi.spyOn(QueryCacheOrigin.prototype, 'findAll')
11 })
12β
13 describe('find', () => {
14 test('should properly unwrap parameters', async () => {
15 const queryCache = new QueryCache()
16β
17 queryCache.find({
18 queryKey: ['foo', ref('bar')],
19 })
20β
21 expect(QueryCacheOrigin.prototype.find).toBeCalledWith({
22 queryKey: ['foo', 'bar'],
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})