@tanstack/react-query-persist-client 4.3.4 → 4.3.6

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ /// <reference types="jest" />
2
+ /// <reference types="node" />
3
+ import { QueryClient, QueryClientConfig } from '@tanstack/query-core';
4
+ export declare function createQueryClient(config?: QueryClientConfig): QueryClient;
5
+ export declare const mockLogger: {
6
+ log: jest.Mock<any, any>;
7
+ warn: jest.Mock<any, any>;
8
+ error: jest.Mock<any, any>;
9
+ };
10
+ export declare function queryKey(): Array<string>;
11
+ export declare function sleep(timeout: number): Promise<void>;
12
+ export declare function setActTimeout(fn: () => void, ms?: number): NodeJS.Timeout;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-query-persist-client",
3
- "version": "4.3.4",
3
+ "version": "4.3.6",
4
4
  "description": "TODO",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src"
32
32
  },
33
33
  "dependencies": {
34
- "@tanstack/query-core": "4.3.4",
35
- "@tanstack/react-query": "4.3.4"
34
+ "@tanstack/query-core": "4.3.6",
35
+ "@tanstack/react-query": "4.3.6"
36
36
  }
37
37
  }
@@ -8,12 +8,7 @@ import {
8
8
  useQueries,
9
9
  DefinedUseQueryResult,
10
10
  } from '@tanstack/react-query'
11
- import {
12
- createQueryClient,
13
- mockLogger,
14
- queryKey,
15
- sleep,
16
- } from '../../../../tests/utils'
11
+ import { createQueryClient, mockLogger, queryKey, sleep } from './utils'
17
12
  import { PersistedClient, Persister, persistQueryClientSave } from '../persist'
18
13
  import { PersistQueryClientProvider } from '../PersistQueryClientProvider'
19
14
 
@@ -1,4 +1,4 @@
1
- import { createQueryClient, sleep } from '../../../../tests/utils'
1
+ import { createQueryClient, sleep } from './utils'
2
2
  import {
3
3
  PersistedClient,
4
4
  Persister,
@@ -0,0 +1,34 @@
1
+ import { act } from '@testing-library/react'
2
+
3
+ import { QueryClient, QueryClientConfig } from '@tanstack/query-core'
4
+
5
+ export function createQueryClient(config?: QueryClientConfig): QueryClient {
6
+ jest.spyOn(console, 'error').mockImplementation(() => undefined)
7
+ return new QueryClient({ logger: mockLogger, ...config })
8
+ }
9
+
10
+ export const mockLogger = {
11
+ log: jest.fn(),
12
+ warn: jest.fn(),
13
+ error: jest.fn(),
14
+ }
15
+
16
+ let queryKeyCount = 0
17
+ export function queryKey(): Array<string> {
18
+ queryKeyCount++
19
+ return [`query_${queryKeyCount}`]
20
+ }
21
+
22
+ export function sleep(timeout: number): Promise<void> {
23
+ return new Promise((resolve, _reject) => {
24
+ setTimeout(resolve, timeout)
25
+ })
26
+ }
27
+
28
+ export function setActTimeout(fn: () => void, ms?: number) {
29
+ return setTimeout(() => {
30
+ act(() => {
31
+ fn()
32
+ })
33
+ }, ms)
34
+ }