From 69476f0ce5778afad4520ed42485b4110993afed Mon Sep 17 00:00:00 2001
From: Jongchan <kickbelldev@gmail.com>
Date: Wed, 2 Oct 2024 03:26:37 +0900
Subject: [PATCH] test(vue-query): add test and improve typing (#8103)

* test(vue-query): add test for clone getters returning values in queryKey

* fix(vue-query): improve typing in vueQueryPlugin.test.ts to resolve errors on tsc

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
---
 packages/vue-query/src/__tests__/utils.test.ts         |  6 ++++++
 .../vue-query/src/__tests__/vueQueryPlugin.test.ts     | 10 ++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/packages/vue-query/src/__tests__/utils.test.ts b/packages/vue-query/src/__tests__/utils.test.ts
index e287fcd266..8dead5d899 100644
--- a/packages/vue-query/src/__tests__/utils.test.ts
+++ b/packages/vue-query/src/__tests__/utils.test.ts
@@ -142,6 +142,12 @@ describe('utils', () => {
       })
     })
 
+    test('should clone getters returning values in queryKey', () => {
+      const val = ref({ queryKey: [1, 2, () => '3'] })
+      const cp = cloneDeepUnref(val)
+      expect(cp).toStrictEqual({ queryKey: [1, 2, '3'] })
+    })
+
     test('should unref undefined', () => {
       expect(cloneDeepUnref(ref(undefined))).toBe(undefined)
     })
diff --git a/packages/vue-query/src/__tests__/vueQueryPlugin.test.ts b/packages/vue-query/src/__tests__/vueQueryPlugin.test.ts
index 3896947fe5..b45228a303 100644
--- a/packages/vue-query/src/__tests__/vueQueryPlugin.test.ts
+++ b/packages/vue-query/src/__tests__/vueQueryPlugin.test.ts
@@ -14,9 +14,11 @@ vi.mock('../devtools/devtools')
 vi.mock('../useQueryClient')
 vi.mock('../useBaseQuery')
 
+type UnmountCallback = () => void
+
 interface TestApp extends App {
-  onUnmount: Function
-  _unmount: Function
+  onUnmount: UnmountCallback
+  _unmount: UnmountCallback
   _mixin: ComponentOptions
   _provided: Record<string, any>
   $root: TestApp
@@ -29,11 +31,11 @@ function getAppMock(withUnmountHook = false): TestApp {
     provide: vi.fn(),
     unmount: vi.fn(),
     onUnmount: withUnmountHook
-      ? vi.fn((u: Function) => {
+      ? vi.fn((u: UnmountCallback) => {
           mock._unmount = u
         })
       : undefined,
-    mixin: (m: ComponentOptions): any => {
+    mixin: (m: ComponentOptions) => {
       mock._mixin = m
     },
   } as unknown as TestApp