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(['foo', ref('bar')], {
17 queryKey: ref(['baz']),
18 })
19β
20 expect(QueryCacheOrigin.prototype.find).toBeCalledWith(['foo', 'bar'], {
21 queryKey: ['baz'],
22 })
23 })
24 })
25β
26 describe('findAll', () => {
27 test('should properly unwrap two parameters', async () => {
28 const queryCache = new QueryCache()
29β
30 queryCache.findAll(['foo', ref('bar')], {
31 queryKey: ref(['baz']),
32 })
33β
34 expect(QueryCacheOrigin.prototype.findAll).toBeCalledWith(
35 ['foo', 'bar'],
36 {
37 queryKey: ['baz'],
38 },
39 )
40 })
41β
42 test('should properly unwrap one parameter', async () => {
43 const queryCache = new QueryCache()
44β
45 queryCache.findAll({
46 queryKey: ref(['baz']),
47 })
48β
49 expect(QueryCacheOrigin.prototype.findAll).toBeCalledWith({
50 queryKey: ['baz'],
51 })
52 })
53 })
54})