|
1 | 1 | import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' |
2 | 2 | import { fireEvent, render } from '@solidjs/testing-library' |
3 | 3 | import { createEffect, createRenderEffect } from 'solid-js' |
4 | | -import { sleep } from '@tanstack/query-test-utils' |
| 4 | +import { queryKey, sleep } from '@tanstack/query-test-utils' |
5 | 5 | import { |
6 | 6 | QueryClient, |
7 | 7 | QueryClientProvider, |
@@ -41,8 +41,9 @@ describe('mutationOptions', () => { |
41 | 41 | it('should return the number of fetching mutations when used with useIsMutating (with mutationKey in mutationOptions)', async () => { |
42 | 42 | const isMutatingArray: Array<number> = [] |
43 | 43 | const queryClient = new QueryClient() |
| 44 | + const key = queryKey() |
44 | 45 | const mutationOpts = mutationOptions({ |
45 | | - mutationKey: ['key'], |
| 46 | + mutationKey: key, |
46 | 47 | mutationFn: () => sleep(50).then(() => 'data'), |
47 | 48 | }) |
48 | 49 |
|
@@ -116,8 +117,9 @@ describe('mutationOptions', () => { |
116 | 117 | it('should return the number of fetching mutations when used with useIsMutating', async () => { |
117 | 118 | const isMutatingArray: Array<number> = [] |
118 | 119 | const queryClient = new QueryClient() |
| 120 | + const key = queryKey() |
119 | 121 | const mutationOpts1 = mutationOptions({ |
120 | | - mutationKey: ['key'], |
| 122 | + mutationKey: key, |
121 | 123 | mutationFn: () => sleep(50).then(() => 'data1'), |
122 | 124 | }) |
123 | 125 | const mutationOpts2 = mutationOptions({ |
@@ -159,8 +161,9 @@ describe('mutationOptions', () => { |
159 | 161 | it('should return the number of fetching mutations when used with useIsMutating (filter mutationOpts1.mutationKey)', async () => { |
160 | 162 | const isMutatingArray: Array<number> = [] |
161 | 163 | const queryClient = new QueryClient() |
| 164 | + const key = queryKey() |
162 | 165 | const mutationOpts1 = mutationOptions({ |
163 | | - mutationKey: ['key'], |
| 166 | + mutationKey: key, |
164 | 167 | mutationFn: () => sleep(50).then(() => 'data1'), |
165 | 168 | }) |
166 | 169 | const mutationOpts2 = mutationOptions({ |
@@ -205,8 +208,9 @@ describe('mutationOptions', () => { |
205 | 208 | it('should return the number of fetching mutations when used with queryClient.isMutating (with mutationKey in mutationOptions)', async () => { |
206 | 209 | const isMutatingArray: Array<number> = [] |
207 | 210 | const queryClient = new QueryClient() |
| 211 | + const key = queryKey() |
208 | 212 | const mutationOpts = mutationOptions({ |
209 | | - mutationKey: ['mutation'], |
| 213 | + mutationKey: key, |
210 | 214 | mutationFn: () => sleep(500).then(() => 'data'), |
211 | 215 | }) |
212 | 216 |
|
@@ -288,8 +292,9 @@ describe('mutationOptions', () => { |
288 | 292 | it('should return the number of fetching mutations when used with queryClient.isMutating', async () => { |
289 | 293 | const isMutatingArray: Array<number> = [] |
290 | 294 | const queryClient = new QueryClient() |
| 295 | + const key = queryKey() |
291 | 296 | const mutationOpts1 = mutationOptions({ |
292 | | - mutationKey: ['mutation'], |
| 297 | + mutationKey: key, |
293 | 298 | mutationFn: () => sleep(500).then(() => 'data1'), |
294 | 299 | }) |
295 | 300 | const mutationOpts2 = mutationOptions({ |
@@ -336,8 +341,9 @@ describe('mutationOptions', () => { |
336 | 341 | it('should return the number of fetching mutations when used with queryClient.isMutating (filter mutationOpt1.mutationKey)', async () => { |
337 | 342 | const isMutatingArray: Array<number> = [] |
338 | 343 | const queryClient = new QueryClient() |
| 344 | + const key = queryKey() |
339 | 345 | const mutationOpts1 = mutationOptions({ |
340 | | - mutationKey: ['mutation'], |
| 346 | + mutationKey: key, |
341 | 347 | mutationFn: () => sleep(500).then(() => 'data1'), |
342 | 348 | }) |
343 | 349 | const mutationOpts2 = mutationOptions({ |
@@ -392,8 +398,9 @@ describe('mutationOptions', () => { |
392 | 398 | it('should return the number of fetching mutations when used with useMutationState (with mutationKey in mutationOptions)', async () => { |
393 | 399 | const mutationStateArray: Array<Array<MutationState>> = [] |
394 | 400 | const queryClient = new QueryClient() |
| 401 | + const key = queryKey() |
395 | 402 | const mutationOpts = mutationOptions({ |
396 | | - mutationKey: ['mutation'], |
| 403 | + mutationKey: key, |
397 | 404 | mutationFn: () => sleep(10).then(() => 'data'), |
398 | 405 | }) |
399 | 406 |
|
@@ -471,8 +478,9 @@ describe('mutationOptions', () => { |
471 | 478 | it('should return the number of fetching mutations when used with useMutationState', async () => { |
472 | 479 | const mutationStateArray: Array<Array<MutationState>> = [] |
473 | 480 | const queryClient = new QueryClient() |
| 481 | + const key = queryKey() |
474 | 482 | const mutationOpts1 = mutationOptions({ |
475 | | - mutationKey: ['mutation'], |
| 483 | + mutationKey: key, |
476 | 484 | mutationFn: () => sleep(10).then(() => 'data1'), |
477 | 485 | }) |
478 | 486 | const mutationOpts2 = mutationOptions({ |
@@ -518,8 +526,9 @@ describe('mutationOptions', () => { |
518 | 526 | it('should return the number of fetching mutations when used with useMutationState (filter mutationOpt1.mutationKey)', async () => { |
519 | 527 | const mutationStateArray: Array<Array<MutationState>> = [] |
520 | 528 | const queryClient = new QueryClient() |
| 529 | + const key = queryKey() |
521 | 530 | const mutationOpts1 = mutationOptions({ |
522 | | - mutationKey: ['mutation'], |
| 531 | + mutationKey: key, |
523 | 532 | mutationFn: () => sleep(10).then(() => 'data1'), |
524 | 533 | }) |
525 | 534 | const mutationOpts2 = mutationOptions({ |
|
0 commit comments