@tanstack/query-persist-client-core 5.0.0-alpha.3 → 5.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/query-persist-client-core",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.5",
|
|
4
4
|
"description": "Set of utilities for interacting with persisters, which can save your queryClient for later use",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
"src"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@tanstack/query-core": "5.0.0-alpha.
|
|
31
|
+
"@tanstack/query-core": "5.0.0-alpha.5"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"clean": "rimraf ./build",
|
|
35
35
|
"test:eslint": "eslint --ext .ts,.tsx ./src",
|
|
36
36
|
"test:types": "tsc",
|
|
37
|
-
"test:lib": "
|
|
37
|
+
"test:lib": "vitest run --coverage",
|
|
38
38
|
"test:lib:dev": "pnpm run test:lib --watch",
|
|
39
39
|
"build:types": "tsc --build"
|
|
40
40
|
}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from './utils'
|
|
6
6
|
import { persistQueryClientSubscribe } from '../persist'
|
|
7
7
|
import { QueriesObserver } from '@tanstack/query-core'
|
|
8
|
+
import { vi } from 'vitest'
|
|
8
9
|
|
|
9
10
|
describe('persistQueryClientSubscribe', () => {
|
|
10
11
|
test('should persist mutations', async () => {
|
|
@@ -42,9 +43,9 @@ describe('persistQueryClientSave', () => {
|
|
|
42
43
|
})
|
|
43
44
|
|
|
44
45
|
const queryKey = ['test']
|
|
45
|
-
const queryFn =
|
|
46
|
+
const queryFn = vi.fn().mockReturnValue(1)
|
|
46
47
|
const observer = new QueriesObserver(queryClient, [{ queryKey, queryFn }])
|
|
47
|
-
const unsubscribeObserver = observer.subscribe(
|
|
48
|
+
const unsubscribeObserver = observer.subscribe(vi.fn())
|
|
48
49
|
observer.getObservers()[0]?.setOptions({ refetchOnWindowFocus: false })
|
|
49
50
|
unsubscribeObserver()
|
|
50
51
|
|
package/src/__tests__/utils.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
Persister,
|
|
5
5
|
PersistedClient,
|
|
6
6
|
} from '@tanstack/query-persist-client-core'
|
|
7
|
+
import { vi } from 'vitest'
|
|
7
8
|
|
|
8
9
|
export function createQueryClient(config?: QueryClientConfig): QueryClient {
|
|
9
10
|
return new QueryClient(config)
|
|
@@ -34,8 +35,8 @@ export const createMockPersister = (): Persister => {
|
|
|
34
35
|
|
|
35
36
|
export const createSpyablePersister = (): Persister => {
|
|
36
37
|
return {
|
|
37
|
-
persistClient:
|
|
38
|
-
restoreClient:
|
|
39
|
-
removeClient:
|
|
38
|
+
persistClient: vi.fn(),
|
|
39
|
+
restoreClient: vi.fn(),
|
|
40
|
+
removeClient: vi.fn(),
|
|
40
41
|
}
|
|
41
42
|
}
|