Skip to content

Commit 6b6667e

Browse files
test(*): migrate 'test' to 'it' and enforce 'vitest/consistent-test-it' rule (#10528)
* test(*): migrate 'test' to 'it' and enforce 'vitest/consistent-test-it' rule * ci: apply automated fixes * chore(preact-query): revert unintended removal of 'eslint-disable' comments from 'src' files --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 799952f commit 6b6667e

75 files changed

Lines changed: 882 additions & 882 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.

eslint.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ export default [
5252
plugins: { vitest },
5353
rules: {
5454
...vitest.configs.recommended.rules,
55+
'vitest/consistent-test-it': [
56+
'error',
57+
{ fn: 'it', withinDescribe: 'it' },
58+
],
5559
'vitest/no-standalone-expect': [
5660
'error',
5761
{

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assertType, describe, expectTypeOf, it, test } from 'vitest'
1+
import { assertType, describe, expectTypeOf, it } from 'vitest'
22
import { queryKey } from '@tanstack/query-test-utils'
33
import { QueryClient, dataTagSymbol } from '@tanstack/query-core'
44
import { infiniteQueryOptions } from '../infinite-query-options'
@@ -139,7 +139,7 @@ describe('infiniteQueryOptions', () => {
139139
>()
140140
})
141141

142-
test('should not be allowed to be passed to non-infinite query functions', () => {
142+
it('should not be allowed to be passed to non-infinite query functions', () => {
143143
const key = queryKey()
144144
const queryClient = new QueryClient()
145145
const options = infiniteQueryOptions({
@@ -166,7 +166,7 @@ describe('infiniteQueryOptions', () => {
166166
)
167167
})
168168

169-
test('allow optional initialData function', () => {
169+
it('allow optional initialData function', () => {
170170
const key = queryKey()
171171
const initialData: { example: boolean } | undefined = { example: true }
172172
const queryOptions = infiniteQueryOptions({
@@ -185,7 +185,7 @@ describe('infiniteQueryOptions', () => {
185185
>()
186186
})
187187

188-
test('allow optional initialData object', () => {
188+
it('allow optional initialData object', () => {
189189
const key = queryKey()
190190
const initialData: { example: boolean } | undefined = { example: true }
191191
const queryOptions = infiniteQueryOptions({

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { TestBed } from '@angular/core/testing'
2-
import { afterEach, beforeEach, describe, expectTypeOf, test, vi } from 'vitest'
2+
import { afterEach, beforeEach, describe, expectTypeOf, it, vi } from 'vitest'
33
import { provideZonelessChangeDetection } from '@angular/core'
44
import { queryKey, sleep } from '@tanstack/query-test-utils'
55
import { QueryClient, injectInfiniteQuery, provideTanStackQuery } from '..'
@@ -23,7 +23,7 @@ describe('injectInfiniteQuery', () => {
2323
vi.useRealTimers()
2424
})
2525

26-
test('should narrow type after isSuccess', () => {
26+
it('should narrow type after isSuccess', () => {
2727
const key = queryKey()
2828
const query = TestBed.runInInjectionContext(() => {
2929
return injectInfiniteQuery(() => ({

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { TestBed } from '@angular/core/testing'
2-
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
2+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
33
import { Injector, provideZonelessChangeDetection } from '@angular/core'
44
import { queryKey, sleep } from '@tanstack/query-test-utils'
55
import { QueryClient, injectInfiniteQuery, provideTanStackQuery } from '..'
@@ -23,7 +23,7 @@ describe('injectInfiniteQuery', () => {
2323
vi.useRealTimers()
2424
})
2525

26-
test('should properly execute infinite query', async () => {
26+
it('should properly execute infinite query', async () => {
2727
const key = queryKey()
2828
const query = TestBed.runInInjectionContext(() => {
2929
return injectInfiniteQuery(() => ({
@@ -64,7 +64,7 @@ describe('injectInfiniteQuery', () => {
6464
})
6565

6666
describe('injection context', () => {
67-
test('throws NG0203 with descriptive error outside injection context', () => {
67+
it('throws NG0203 with descriptive error outside injection context', () => {
6868
const key = queryKey()
6969
expect(() => {
7070
injectInfiniteQuery(() => ({
@@ -77,7 +77,7 @@ describe('injectInfiniteQuery', () => {
7777
}).toThrow(/NG0203(.*?)injectInfiniteQuery/)
7878
})
7979

80-
test('can be used outside injection context when passing an injector', () => {
80+
it('can be used outside injection context when passing an injector', () => {
8181
const key = queryKey()
8282
const query = injectInfiniteQuery(
8383
() => ({

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
@@ -1,5 +1,5 @@
11
import { TestBed } from '@angular/core/testing'
2-
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
2+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
33
import { Injector, provideZonelessChangeDetection } from '@angular/core'
44
import { queryKey, sleep } from '@tanstack/query-test-utils'
55
import {
@@ -28,7 +28,7 @@ describe('injectIsFetching', () => {
2828
vi.useRealTimers()
2929
})
3030

31-
test('Returns number of fetching queries', async () => {
31+
it('Returns number of fetching queries', async () => {
3232
const key = queryKey()
3333
const isFetching = TestBed.runInInjectionContext(() => {
3434
injectQuery(() => ({
@@ -46,13 +46,13 @@ describe('injectIsFetching', () => {
4646
})
4747

4848
describe('injection context', () => {
49-
test('throws NG0203 with descriptive error outside injection context', () => {
49+
it('throws NG0203 with descriptive error outside injection context', () => {
5050
expect(() => {
5151
injectIsFetching()
5252
}).toThrow(/NG0203(.*?)injectIsFetching/)
5353
})
5454

55-
test('can be used outside injection context when passing an injector', () => {
55+
it('can be used outside injection context when passing an injector', () => {
5656
expect(
5757
injectIsFetching(undefined, {
5858
injector: TestBed.inject(Injector),

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
@@ -1,4 +1,4 @@
1-
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
1+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
22
import { TestBed } from '@angular/core/testing'
33
import { Injector, provideZonelessChangeDetection } from '@angular/core'
44
import { queryKey, sleep } from '@tanstack/query-test-utils'
@@ -28,7 +28,7 @@ describe('injectIsMutating', () => {
2828
vi.useRealTimers()
2929
})
3030

31-
test('should properly return isMutating state', async () => {
31+
it('should properly return isMutating state', async () => {
3232
const key = queryKey()
3333
const [mutation, isMutating] = TestBed.runInInjectionContext(() => [
3434
injectMutation(() => ({
@@ -52,13 +52,13 @@ describe('injectIsMutating', () => {
5252
})
5353

5454
describe('injection context', () => {
55-
test('throws NG0203 with descriptive error outside injection context', () => {
55+
it('throws NG0203 with descriptive error outside injection context', () => {
5656
expect(() => {
5757
injectIsMutating()
5858
}).toThrow(/NG0203(.*?)injectIsMutating/)
5959
})
6060

61-
test('can be used outside injection context when passing an injector', () => {
61+
it('can be used outside injection context when passing an injector', () => {
6262
expect(
6363
injectIsMutating(undefined, {
6464
injector: TestBed.inject(Injector),

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { TestBed } from '@angular/core/testing'
2-
import { describe, expect, test } from 'vitest'
2+
import { describe, expect, it } from 'vitest'
33
import { Injector, provideZonelessChangeDetection, signal } from '@angular/core'
44
import {
55
QueryClient,
@@ -11,7 +11,7 @@ import {
1111
describe('injectIsRestoring', () => {
1212
let queryClient: QueryClient
1313

14-
test('returns false by default when provideIsRestoring is not used', () => {
14+
it('returns false by default when provideIsRestoring is not used', () => {
1515
queryClient = new QueryClient()
1616

1717
TestBed.configureTestingModule({
@@ -28,7 +28,7 @@ describe('injectIsRestoring', () => {
2828
expect(isRestoring()).toBe(false)
2929
})
3030

31-
test('returns provided signal value when provideIsRestoring is used', () => {
31+
it('returns provided signal value when provideIsRestoring is used', () => {
3232
queryClient = new QueryClient()
3333
const restoringSignal = signal(true)
3434

@@ -47,7 +47,7 @@ describe('injectIsRestoring', () => {
4747
expect(isRestoring()).toBe(true)
4848
})
4949

50-
test('can be used outside injection context when passing an injector', () => {
50+
it('can be used outside injection context when passing an injector', () => {
5151
queryClient = new QueryClient()
5252

5353
TestBed.configureTestingModule({
@@ -64,7 +64,7 @@ describe('injectIsRestoring', () => {
6464
expect(isRestoring()).toBe(false)
6565
})
6666

67-
test('throws NG0203 with descriptive error outside injection context', () => {
67+
it('throws NG0203 with descriptive error outside injection context', () => {
6868
expect(() => {
6969
injectIsRestoring()
7070
}).toThrow(/NG0203(.*?)injectIsRestoring/)

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
signal,
77
} from '@angular/core'
88
import { TestBed } from '@angular/core/testing'
9-
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
9+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
1010
import { By } from '@angular/platform-browser'
1111
import { queryKey, sleep } from '@tanstack/query-test-utils'
1212
import {
@@ -36,7 +36,7 @@ describe('injectMutationState', () => {
3636
})
3737

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

@@ -59,7 +59,7 @@ describe('injectMutationState', () => {
5959
expect(mutationState()).toEqual([variables])
6060
})
6161

62-
test('reactive options should update injectMutationState', () => {
62+
it('reactive options should update injectMutationState', () => {
6363
const mutationKey1 = queryKey()
6464
const mutationKey2 = queryKey()
6565
const variables1 = 'foo123'
@@ -96,7 +96,7 @@ describe('injectMutationState', () => {
9696
expect(mutationState()).toEqual([variables2])
9797
})
9898

99-
test('should return variables after calling mutate 2', () => {
99+
it('should return variables after calling mutate 2', () => {
100100
queryClient.clear()
101101
const mutationKey = queryKey()
102102
const variables = 'bar234'
@@ -117,7 +117,7 @@ describe('injectMutationState', () => {
117117
expect(mutationState()[0]?.variables).toEqual(variables)
118118
})
119119

120-
test('should support required signal inputs', async () => {
120+
it('should support required signal inputs', async () => {
121121
queryClient.clear()
122122
const fakeName = 'name1'
123123
const mutationKey1 = ['fake', fakeName]
@@ -179,13 +179,13 @@ describe('injectMutationState', () => {
179179
})
180180

181181
describe('injection context', () => {
182-
test('throws NG0203 with descriptive error outside injection context', () => {
182+
it('throws NG0203 with descriptive error outside injection context', () => {
183183
expect(() => {
184184
injectMutationState()
185185
}).toThrow(/NG0203(.*?)injectMutationState/)
186186
})
187187

188-
test('can be used outside injection context when passing an injector', () => {
188+
it('can be used outside injection context when passing an injector', () => {
189189
const injector = TestBed.inject(Injector)
190190
expect(
191191
injectMutationState(undefined, {

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { describe, expectTypeOf, test } from 'vitest'
1+
import { describe, expectTypeOf, it } from 'vitest'
22
import { sleep } from '@tanstack/query-test-utils'
33
import { injectMutation } from '..'
44
import type { Signal } from '@angular/core'
55

66
describe('injectMutation', () => {
77
describe('Discriminated union return type', () => {
8-
test('data should be possibly undefined by default', () => {
8+
it('data should be possibly undefined by default', () => {
99
const mutation = injectMutation(() => ({
1010
mutationFn: () => sleep(0).then(() => 'string'),
1111
}))
1212

1313
expectTypeOf(mutation.data).toEqualTypeOf<Signal<string | undefined>>()
1414
})
1515

16-
test('data should be defined when mutation is success', () => {
16+
it('data should be defined when mutation is success', () => {
1717
const mutation = injectMutation(() => ({
1818
mutationFn: () => sleep(0).then(() => 'string'),
1919
}))
@@ -23,7 +23,7 @@ describe('injectMutation', () => {
2323
}
2424
})
2525

26-
test('error should be null when mutation is success', () => {
26+
it('error should be null when mutation is success', () => {
2727
const mutation = injectMutation(() => ({
2828
mutationFn: () => sleep(0).then(() => 'string'),
2929
}))
@@ -33,7 +33,7 @@ describe('injectMutation', () => {
3333
}
3434
})
3535

36-
test('data should be undefined when mutation is pending', () => {
36+
it('data should be undefined when mutation is pending', () => {
3737
const mutation = injectMutation(() => ({
3838
mutationFn: () => sleep(0).then(() => 'string'),
3939
}))
@@ -43,7 +43,7 @@ describe('injectMutation', () => {
4343
}
4444
})
4545

46-
test('error should be defined when mutation is error', () => {
46+
it('error should be defined when mutation is error', () => {
4747
const mutation = injectMutation(() => ({
4848
mutationFn: () => sleep(0).then(() => 'string'),
4949
}))
@@ -53,7 +53,7 @@ describe('injectMutation', () => {
5353
}
5454
})
5555

56-
test('should narrow variables', () => {
56+
it('should narrow variables', () => {
5757
const mutation = injectMutation(() => ({
5858
mutationFn: (_variables: string) => sleep(0).then(() => 'string'),
5959
}))

0 commit comments

Comments
 (0)