Open History to see the last commit
1import { beforeAll, describe, expect, test, vi } from 'vitest'
2import { ref } from 'vue-demi'
3import { QueryCache as QueryCacheOrigin } from '@tanstack/query-core'
4import { QueryCache } from '../queryCache'
5β
6describe('QueryCache', () => {
7 beforeAll(() => {
8 vi.spyOn(QueryCacheOrigin.prototype, 'find')
9 vi.spyOn(QueryCacheOrigin.prototype, 'findAll')
10 })
11β
12 describe('find', () => {
13 test('should properly unwrap parameters', () => {
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 })
23 })
24 })
25β
26 describe('findAll', () => {
27 test('should properly unwrap two parameters', () => {
28 const queryCache = new QueryCache()
29β
30 queryCache.findAll({
31 queryKey: ['foo', ref('bar')],
32 })
33β
34 expect(QueryCacheOrigin.prototype.findAll).toBeCalledWith({
35 queryKey: ['foo', 'bar'],
36 })
37 })
38β
39 test('should default to empty filters', () => {
40 const queryCache = new QueryCache()
41β
42 queryCache.findAll()
43β
44 expect(QueryCacheOrigin.prototype.findAll).toBeCalledWith({})
45 })
46 })
47})