Skip to content

Commit f2bc921

Browse files
committed
test(*): rename the 'queryKey' test helper to 'createKey' since it creates keys for both queries and mutations
1 parent 1117bdd commit f2bc921

182 files changed

Lines changed: 3051 additions & 3032 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎packages/angular-query-experimental/src/__tests__/infinite-query-options.test-d.ts‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { assertType, describe, expectTypeOf, it } from 'vitest'
2-
import { queryKey } from '@tanstack/query-test-utils'
2+
import { createKey } from '@tanstack/query-test-utils'
33
import { QueryClient, dataTagSymbol, skipToken } from '@tanstack/query-core'
44
import { infiniteQueryOptions } from '../infinite-query-options'
55
import { injectInfiniteQuery } from '../inject-infinite-query'
@@ -21,7 +21,7 @@ export const exportedInfiniteQueryOptions = infiniteQueryOptions({
2121

2222
describe('infiniteQueryOptions', () => {
2323
it('should not allow excess properties', () => {
24-
const key = queryKey()
24+
const key = createKey()
2525
assertType(
2626
infiniteQueryOptions({
2727
queryKey: key,
@@ -35,7 +35,7 @@ describe('infiniteQueryOptions', () => {
3535
})
3636

3737
it('should infer types for callbacks', () => {
38-
const key = queryKey()
38+
const key = createKey()
3939
infiniteQueryOptions({
4040
queryKey: key,
4141
queryFn: () => Promise.resolve('data'),
@@ -49,7 +49,7 @@ describe('infiniteQueryOptions', () => {
4949
})
5050

5151
it('should work when passed to useInfiniteQuery', () => {
52-
const key = queryKey()
52+
const key = createKey()
5353
const options = infiniteQueryOptions({
5454
queryKey: key,
5555
queryFn: () => Promise.resolve('string'),
@@ -66,7 +66,7 @@ describe('infiniteQueryOptions', () => {
6666
})
6767

6868
it('should work when passed to fetchInfiniteQuery', async () => {
69-
const key = queryKey()
69+
const key = createKey()
7070
const options = infiniteQueryOptions({
7171
queryKey: key,
7272
queryFn: () => Promise.resolve('string'),
@@ -135,7 +135,7 @@ describe('infiniteQueryOptions', () => {
135135
})
136136

137137
it('should tag the queryKey with the result type of the QueryFn', () => {
138-
const key = queryKey()
138+
const key = createKey()
139139
const { queryKey: tagged } = infiniteQueryOptions({
140140
queryKey: key,
141141
queryFn: () => Promise.resolve('string'),
@@ -147,7 +147,7 @@ describe('infiniteQueryOptions', () => {
147147
})
148148

149149
it('should tag the queryKey even if no promise is returned', () => {
150-
const key = queryKey()
150+
const key = createKey()
151151
const { queryKey: tagged } = infiniteQueryOptions({
152152
queryKey: key,
153153
queryFn: () => 'string',
@@ -159,7 +159,7 @@ describe('infiniteQueryOptions', () => {
159159
})
160160

161161
it('should tag the queryKey with the result type of the QueryFn if select is used', () => {
162-
const key = queryKey()
162+
const key = createKey()
163163
const { queryKey: tagged } = infiniteQueryOptions({
164164
queryKey: key,
165165
queryFn: () => Promise.resolve('string'),
@@ -172,7 +172,7 @@ describe('infiniteQueryOptions', () => {
172172
})
173173

174174
it('should return the proper type when passed to getQueryData', () => {
175-
const key = queryKey()
175+
const key = createKey()
176176
const { queryKey: tagged } = infiniteQueryOptions({
177177
queryKey: key,
178178
queryFn: () => Promise.resolve('string'),
@@ -189,7 +189,7 @@ describe('infiniteQueryOptions', () => {
189189
})
190190

191191
it('should properly type when passed to setQueryData', () => {
192-
const key = queryKey()
192+
const key = createKey()
193193
const { queryKey: tagged } = infiniteQueryOptions({
194194
queryKey: key,
195195
queryFn: () => Promise.resolve('string'),
@@ -211,7 +211,7 @@ describe('infiniteQueryOptions', () => {
211211
})
212212

213213
it('should not be allowed to be passed to non-infinite query functions', () => {
214-
const key = queryKey()
214+
const key = createKey()
215215
const queryClient = new QueryClient()
216216
const options = infiniteQueryOptions({
217217
queryKey: key,
@@ -247,7 +247,7 @@ describe('infiniteQueryOptions', () => {
247247
})
248248

249249
it('should allow optional initialData function', () => {
250-
const key = queryKey()
250+
const key = createKey()
251251
const initialData: { example: boolean } | undefined = { example: true }
252252
const queryOptions = infiniteQueryOptions({
253253
queryKey: key,
@@ -266,7 +266,7 @@ describe('infiniteQueryOptions', () => {
266266
})
267267

268268
it('should allow optional initialData object', () => {
269-
const key = queryKey()
269+
const key = createKey()
270270
const initialData: { example: boolean } | undefined = { example: true }
271271
const queryOptions = infiniteQueryOptions({
272272
queryKey: key,

‎packages/angular-query-experimental/src/__tests__/infinite-query-options.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { describe, expect, it } from 'vitest'
2-
import { queryKey } from '@tanstack/query-test-utils'
2+
import { createKey } from '@tanstack/query-test-utils'
33

44
import { infiniteQueryOptions } from '../infinite-query-options'
55
import type { CreateInfiniteQueryOptions } from '../types'
66

77
describe('infiniteQueryOptions', () => {
88
it('should return the object received as a parameter without any modification.', () => {
9-
const key = queryKey()
9+
const key = createKey()
1010
const object: CreateInfiniteQueryOptions = {
1111
queryKey: key,
1212
queryFn: () => Promise.resolve(5),

‎packages/angular-query-experimental/src/__tests__/inject-infinite-query.test-d.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { TestBed } from '@angular/core/testing'
22
import { afterEach, beforeEach, describe, expectTypeOf, it, vi } from 'vitest'
33
import { provideZonelessChangeDetection } from '@angular/core'
4-
import { queryKey, sleep } from '@tanstack/query-test-utils'
4+
import { createKey, sleep } from '@tanstack/query-test-utils'
55
import {
66
QueryClient,
77
injectInfiniteQuery,
@@ -29,7 +29,7 @@ describe('injectInfiniteQuery', () => {
2929
})
3030

3131
it('should narrow type after isSuccess', () => {
32-
const key = queryKey()
32+
const key = createKey()
3333
const query = TestBed.runInInjectionContext(() => {
3434
return injectInfiniteQuery(() => ({
3535
queryKey: key,
@@ -47,7 +47,7 @@ describe('injectInfiniteQuery', () => {
4747
})
4848

4949
it('should work when queryFn is skipToken', () => {
50-
const key = queryKey()
50+
const key = createKey()
5151
const query = TestBed.runInInjectionContext(() => {
5252
return injectInfiniteQuery(() => ({
5353
queryKey: key,

‎packages/angular-query-experimental/src/__tests__/inject-infinite-query.test.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
signal,
88
} from '@angular/core'
99
import { render } from '@testing-library/angular'
10-
import { queryKey, sleep } from '@tanstack/query-test-utils'
10+
import { createKey, sleep } from '@tanstack/query-test-utils'
1111
import {
1212
QueryClient,
1313
injectInfiniteQuery,
@@ -34,7 +34,7 @@ describe('injectInfiniteQuery', () => {
3434
})
3535

3636
it('should properly execute infinite query', async () => {
37-
const key = queryKey()
37+
const key = createKey()
3838

3939
@Component({
4040
template: `
@@ -71,7 +71,7 @@ describe('injectInfiniteQuery', () => {
7171
})
7272

7373
it('should reject and update signal', async () => {
74-
const key = queryKey()
74+
const key = createKey()
7575

7676
@Component({
7777
template: `
@@ -107,7 +107,7 @@ describe('injectInfiniteQuery', () => {
107107
})
108108

109109
it('should keep initialData visible alongside the error when a refetch fails', async () => {
110-
const key = queryKey()
110+
const key = createKey()
111111

112112
@Component({
113113
template: `
@@ -139,7 +139,7 @@ describe('injectInfiniteQuery', () => {
139139

140140
describe('skipToken', () => {
141141
it('should not fetch when queryFn is skipToken, and fetch once it is replaced', async () => {
142-
const key = queryKey()
142+
const key = createKey()
143143
const queryFn = vi.fn<
144144
(context: { pageParam: number }) => Promise<string>
145145
>(({ pageParam }: { pageParam: number }) =>
@@ -189,7 +189,7 @@ describe('injectInfiniteQuery', () => {
189189

190190
describe('injection context', () => {
191191
it('should throw NG0203 with descriptive error outside injection context', () => {
192-
const key = queryKey()
192+
const key = createKey()
193193
expect(() => {
194194
injectInfiniteQuery(() => ({
195195
queryKey: key,
@@ -202,7 +202,7 @@ describe('injectInfiniteQuery', () => {
202202
})
203203

204204
it('should be usable outside injection context when passing an injector', () => {
205-
const key = queryKey()
205+
const key = createKey()
206206
const query = injectInfiniteQuery(
207207
() => ({
208208
queryKey: key,

‎packages/angular-query-experimental/src/__tests__/inject-is-fetching.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
provideZonelessChangeDetection,
77
} from '@angular/core'
88
import { render } from '@testing-library/angular'
9-
import { queryKey, sleep } from '@tanstack/query-test-utils'
9+
import { createKey, sleep } from '@tanstack/query-test-utils'
1010
import {
1111
QueryClient,
1212
injectIsFetching,
@@ -34,7 +34,7 @@ describe('injectIsFetching', () => {
3434
})
3535

3636
it('should return the number of fetching queries', async () => {
37-
const key = queryKey()
37+
const key = createKey()
3838

3939
@Component({
4040
template: `<div>fetching: {{ isFetching() }}</div>`,
@@ -59,8 +59,8 @@ describe('injectIsFetching', () => {
5959
})
6060

6161
it('should be able to filter by queryKey', async () => {
62-
const key1 = queryKey()
63-
const key2 = queryKey()
62+
const key1 = createKey()
63+
const key2 = createKey()
6464

6565
@Component({
6666
template: `<div>fetching: {{ isFetching() }}</div>`,

‎packages/angular-query-experimental/src/__tests__/inject-is-mutating.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
provideZonelessChangeDetection,
77
} from '@angular/core'
88
import { render } from '@testing-library/angular'
9-
import { queryKey, sleep } from '@tanstack/query-test-utils'
9+
import { createKey, sleep } from '@tanstack/query-test-utils'
1010
import {
1111
QueryClient,
1212
injectIsMutating,
@@ -34,7 +34,7 @@ describe('injectIsMutating', () => {
3434
})
3535

3636
it('should properly return isMutating state', async () => {
37-
const key = queryKey()
37+
const key = createKey()
3838

3939
@Component({
4040
template: `<div>mutating: {{ isMutating() }}</div>`,
@@ -61,8 +61,8 @@ describe('injectIsMutating', () => {
6161
})
6262

6363
it('should be able to filter by mutationKey', async () => {
64-
const key1 = queryKey()
65-
const key2 = queryKey()
64+
const key1 = createKey()
65+
const key2 = createKey()
6666

6767
@Component({
6868
template: `<div>mutating: {{ isMutating() }}</div>`,

‎packages/angular-query-experimental/src/__tests__/inject-mutation-state.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import { TestBed } from '@angular/core/testing'
99
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
1010
import { By } from '@angular/platform-browser'
11-
import { queryKey, sleep } from '@tanstack/query-test-utils'
11+
import { createKey, sleep } from '@tanstack/query-test-utils'
1212
import {
1313
QueryClient,
1414
injectMutation,
@@ -37,7 +37,7 @@ describe('injectMutationState', () => {
3737

3838
describe('injectMutationState', () => {
3939
it('should return variables after calling mutate 1', () => {
40-
const mutationKey = queryKey()
40+
const mutationKey = createKey()
4141
const variables = 'foo123'
4242

4343
const mutation = TestBed.runInInjectionContext(() => {
@@ -60,8 +60,8 @@ describe('injectMutationState', () => {
6060
})
6161

6262
it('should update injectMutationState when reactive options change', () => {
63-
const mutationKey1 = queryKey()
64-
const mutationKey2 = queryKey()
63+
const mutationKey1 = createKey()
64+
const mutationKey2 = createKey()
6565
const variables1 = 'foo123'
6666
const variables2 = 'bar234'
6767

@@ -98,7 +98,7 @@ describe('injectMutationState', () => {
9898

9999
it('should return variables after calling mutate 2', () => {
100100
queryClient.clear()
101-
const mutationKey = queryKey()
101+
const mutationKey = createKey()
102102
const variables = 'bar234'
103103

104104
const mutation = TestBed.runInInjectionContext(() => {

0 commit comments

Comments
 (0)