@tanstack/query-async-storage-persister 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-async-storage-persister",
3
- "version": "5.0.0-alpha.3",
3
+ "version": "5.0.0-alpha.5",
4
4
  "description": "A persister for asynchronous storages, to be used with TanStack/Query",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -28,13 +28,13 @@
28
28
  "src"
29
29
  ],
30
30
  "dependencies": {
31
- "@tanstack/query-persist-client-core": "5.0.0-alpha.3"
31
+ "@tanstack/query-persist-client-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": "jest --config ./jest.config.ts",
37
+ "test:lib": "vitest run --coverage",
38
38
  "test:lib:dev": "pnpm run test:lib --watch",
39
39
  "build:types": "tsc --build"
40
40
  }
@@ -1,11 +1,12 @@
1
1
  import { asyncThrottle } from '../asyncThrottle'
2
2
  import { sleep as delay } from './utils'
3
+ import { vi } from 'vitest'
3
4
 
4
5
  describe('asyncThrottle', () => {
5
6
  test('basic', async () => {
6
7
  const interval = 10
7
8
  const execTimeStamps: number[] = []
8
- const mockFunc = jest.fn(
9
+ const mockFunc = vi.fn(
9
10
  async (id: number, complete?: (value?: unknown) => void) => {
10
11
  await delay(1)
11
12
  execTimeStamps.push(Date.now())
@@ -33,7 +34,7 @@ describe('asyncThrottle', () => {
33
34
  test('Bug #3331 case 1: Special timing', async () => {
34
35
  const interval = 1000
35
36
  const execTimeStamps: number[] = []
36
- const mockFunc = jest.fn(
37
+ const mockFunc = vi.fn(
37
38
  async (id: number, complete?: (value?: unknown) => void) => {
38
39
  await delay(30)
39
40
  execTimeStamps.push(Date.now())
@@ -62,7 +63,7 @@ describe('asyncThrottle', () => {
62
63
  test('Bug #3331 case 2: "func" execution time is greater than the interval.', async () => {
63
64
  const interval = 1000
64
65
  const execTimeStamps: number[] = []
65
- const mockFunc = jest.fn(
66
+ const mockFunc = vi.fn(
66
67
  async (id: number, complete?: (value?: unknown) => void) => {
67
68
  await delay(interval + 10)
68
69
  execTimeStamps.push(Date.now())
@@ -86,7 +87,7 @@ describe('asyncThrottle', () => {
86
87
  })
87
88
 
88
89
  test('"func" throw error not break next invoke', async () => {
89
- const mockFunc = jest.fn(
90
+ const mockFunc = vi.fn(
90
91
  async (id: number, complete?: (value?: unknown) => void) => {
91
92
  if (id === 1) throw new Error('error')
92
93
  await delay(1)
@@ -105,11 +106,10 @@ describe('asyncThrottle', () => {
105
106
  expect(mockFunc.mock.calls[1]?.[0]).toBe(2)
106
107
  })
107
108
 
108
- test('"onError" should be called when "func" throw error', (done) => {
109
+ test('"onError" should be called when "func" throw error', () => {
109
110
  const err = new Error('error')
110
111
  const handleError = (e: unknown) => {
111
112
  expect(e).toBe(err)
112
- done()
113
113
  }
114
114
 
115
115
  const testFunc = asyncThrottle(