Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('withPersistQueryClient', () => {
vi.useRealTimers()
})

it('restores cache from persister', async () => {
it('should restore cache from persister', async () => {
const key = createKey()
const states: Array<{
status: string
Expand Down Expand Up @@ -157,7 +157,7 @@ describe('withPersistQueryClient', () => {
})
})

it('restores cache for injectQueries and keeps it idle while restoring', async () => {
it('should restore cache for injectQueries and keep it idle while restoring', async () => {
const key1 = createKey()
const key2 = createKey()
const states: Array<
Expand Down Expand Up @@ -692,7 +692,7 @@ describe('withPersistQueryClient', () => {
onErrorMock.mockRestore()
})

it('factory form can inject a token and restores cache', async () => {
it('should inject a token and restore cache with the factory form', async () => {
const key = createKey()
const holder = { persister: createMockPersister() }
const HOLDER = new InjectionToken<{ persister: Persister }>(
Expand Down Expand Up @@ -745,7 +745,7 @@ describe('withPersistQueryClient', () => {
expect(rendered.getByText('hydrated')).toBeInTheDocument()
})

it('factory callback runs only in browser mode', async () => {
it('should run the factory callback only in browser mode', async () => {
const factory = vi.fn<
() => { persistOptions: { persister: persistClientCore.Persister } }
>(() => ({
Expand Down Expand Up @@ -778,7 +778,7 @@ describe('withPersistQueryClient', () => {
expect(rendered.fixture.nativeElement.textContent.trim()).toBe('false')
})

it('cleanup subscription runs on injector destroy', async () => {
it('should run the cleanup subscription on injector destroy', async () => {
const key = createKey()
const queryClient = new QueryClient()
const persister = createMockPersister()
Expand Down Expand Up @@ -818,7 +818,7 @@ describe('withPersistQueryClient', () => {
expect(cleanup).toHaveBeenCalledTimes(1)
})

it('does not subscribe when the injector is destroyed during restore', async () => {
it('should not subscribe when the injector is destroyed during restore', async () => {
const subscribeSpy = vi.spyOn(
persistClientCore,
'persistQueryClientSubscribe',
Expand Down Expand Up @@ -846,7 +846,7 @@ describe('withPersistQueryClient', () => {
expect(subscribeSpy).not.toHaveBeenCalled()
})

it('keeps restoration state independent when a provider configuration is reused', async () => {
it('should keep restoration state independent when a provider configuration is reused', async () => {
TestBed.configureTestingModule({
providers: [provideZonelessChangeDetection()],
})
Expand Down

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/angular-query/schematics-build/ng-add.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function createAngularApplication(standalone = true) {
}

describe('ng-add schematic', () => {
it('configures Angular Query and devtools', async () => {
it('should configure Angular Query and devtools', async () => {
const tree = await createAngularApplication()
const result = await queryRunner.runSchematic(
'ng-add',
Expand Down Expand Up @@ -67,7 +67,7 @@ describe('ng-add schematic', () => {
])
})

it('adds the devtools with a caret range so they update with Angular Query', async () => {
it('should add the devtools with a caret range so they update with Angular Query', async () => {
const tree = await createAngularApplication()
const result = await queryRunner.runSchematic(
'ng-add',
Expand All @@ -87,7 +87,7 @@ describe('ng-add schematic', () => {
{ applicationType: 'standalone', standalone: true },
{ applicationType: 'NgModule', standalone: false },
])(
'does not duplicate configuration in a $applicationType application',
'should not duplicate configuration in a $applicationType application',
async ({ standalone }) => {
const tree = await createAngularApplication(standalone)
const firstResult = await queryRunner.runSchematic(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { InfiniteData } from '@tanstack/query-core'
import type { CreateInfiniteQueryOptions, CreateInfiniteQueryResult } from '..'

describe('injectInfiniteQuery', () => {
it('supports reading data from a generic result type', () => {
it('should support reading data from a generic result type', () => {
const readPages = <T extends InfiniteData<{ id: number }>>(
query: CreateInfiniteQueryResult<T>,
) => query.data()?.pages
Expand Down Expand Up @@ -68,7 +68,7 @@ describe('injectInfiniteQuery', () => {
})

describe('Discriminated union return type', () => {
it('data should be possibly undefined by default', () => {
it('should have possibly undefined data by default', () => {
const query = injectInfiniteQuery(() => ({
queryKey: ['infiniteQuery'],
queryFn: ({ pageParam }) =>
Expand All @@ -82,7 +82,7 @@ describe('injectInfiniteQuery', () => {
>()
})

it('data should be defined when query is success', () => {
it('should have defined data when query is success', () => {
const query = injectInfiniteQuery(() => ({
queryKey: ['infiniteQuery'],
queryFn: ({ pageParam }) =>
Expand All @@ -101,7 +101,7 @@ describe('injectInfiniteQuery', () => {
}
})

it('error should be null when query is success', () => {
it('should have null error when query is success', () => {
const query = injectInfiniteQuery(() => ({
queryKey: ['infiniteQuery'],
queryFn: ({ pageParam }) =>
Expand All @@ -115,7 +115,7 @@ describe('injectInfiniteQuery', () => {
}
})

it('data should be undefined when query is pending', () => {
it('should have undefined data when query is pending', () => {
const query = injectInfiniteQuery(() => ({
queryKey: ['infiniteQuery'],
queryFn: ({ pageParam }) =>
Expand All @@ -129,7 +129,7 @@ describe('injectInfiniteQuery', () => {
}
})

it('error should be defined when query is error', () => {
it('should have defined error when query is error', () => {
const query = injectInfiniteQuery(() => ({
queryKey: ['infiniteQuery'],
queryFn: ({ pageParam }) =>
Expand Down Expand Up @@ -178,7 +178,7 @@ describe('injectInfiniteQuery', () => {
})

describe('injectInfiniteQuery options', () => {
it('omits observer error reporting options', () => {
it('should omit observer error reporting options', () => {
expectTypeOf<CreateInfiniteQueryOptions>().not.toHaveProperty(
'throwOnError',
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('injectInfiniteQuery', () => {
})

it.each(['refetch', 'fetchNextPage', 'fetchPreviousPage'] as const)(
'applies current infinite-query options before %s',
'should apply current infinite-query options before %s',
async (method) => {
vi.useRealTimers()
const version = signal('old')
Expand Down Expand Up @@ -175,7 +175,7 @@ describe('injectInfiniteQuery', () => {
})

describe('injection context', () => {
it('throws NG0203 with descriptive error outside injection context', () => {
it('should throw NG0203 with descriptive error outside injection context', () => {
expect(() => {
injectInfiniteQuery(() => ({
queryKey: ['injectionContextError'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { provideAngularQueryChangeDetection } from './test-utils'
describe('injectIsRestoring', () => {
let queryClient: QueryClient

it('returns false by default when provideIsRestoring is not used', () => {
it('should return false by default when provideIsRestoring is not used', () => {
queryClient = new QueryClient()

TestBed.configureTestingModule({
Expand All @@ -25,7 +25,7 @@ describe('injectIsRestoring', () => {
expect(isRestoring()).toBe(false)
})

it('resolves a restoration signal factory in the injection context', () => {
it('should resolve a restoration signal factory in the injection context', () => {
const state = signal(true)
const token = new InjectionToken<typeof state>('restoration state')
TestBed.configureTestingModule({
Expand All @@ -43,7 +43,7 @@ describe('injectIsRestoring', () => {
expect(TestBed.runInInjectionContext(injectIsRestoring)).toBe(isRestoring)
})

it('throws NG0203 with descriptive error outside injection context', () => {
it('should throw NG0203 with descriptive error outside injection context', () => {
expect(() => {
injectIsRestoring()
}).toThrow(/NG0203(.*?)injectIsRestoring/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('injectMutationState', () => {
vi.useRealTimers()
})

it('publishes selected mutation values unchanged and compares snapshot entries by identity', () => {
it('should publish selected mutation values unchanged and compare snapshot entries by identity', () => {
const version = signal('before')
queryClient.getMutationCache().build(queryClient, { mutationKey: ['a'] })
queryClient.getMutationCache().build(queryClient, { mutationKey: ['b'] })
Expand Down Expand Up @@ -100,7 +100,7 @@ describe('injectMutationState', () => {
expect(mutationState()).toStrictEqual([variables])
})

it('reactive options should update injectMutationState', () => {
it('should update injectMutationState with reactive options', () => {
const mutationKey1 = ['mutation1']
const mutationKey2 = ['mutation2']
const variables1 = 'foo123'
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('injectMutationState', () => {
expect(mutationState()).toStrictEqual([variables2])
})

it('preserves result identity when an unrelated mutation changes', () => {
it('should preserve result identity when an unrelated mutation changes', () => {
const mutationState = TestBed.runInInjectionContext(() =>
injectMutationState(() => ({
filters: { mutationKey: ['matching'] },
Expand Down Expand Up @@ -242,7 +242,7 @@ describe('injectMutationState', () => {
})

describe('injection context', () => {
it('throws NG0203 with descriptive error outside injection context', () => {
it('should throw NG0203 with descriptive error outside injection context', () => {
expect(() => {
injectMutationState()
}).toThrow(/NG0203(.*?)injectMutationState/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
import type { CreateMutationOptions, CreateMutationResult } from '..'

describe('injectMutation', () => {
it('supports reading data from a generic result type', () => {
it('should support reading data from a generic result type', () => {
const readId = <T extends { id: number }>(
mutation: CreateMutationResult<T>,
) => mutation.data()?.id
Expand Down Expand Up @@ -169,7 +169,7 @@ describe('injectMutation', () => {
})

describe('injectMutation options', () => {
it('omits observer error reporting options', () => {
it('should omit observer error reporting options', () => {
expectTypeOf<CreateMutationOptions>().not.toHaveProperty('throwOnError')
})
})
14 changes: 7 additions & 7 deletions packages/angular-query/src/__tests__/inject-mutation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('injectMutation', () => {
vi.useRealTimers()
})

it('publishes mutation failures to observers and cache signals without global reporting', async () => {
it('should publish mutation failures to observers and cache signals without global reporting', async () => {
vi.useRealTimers()
queryClient.setDefaultOptions({ mutations: { throwOnError: true } })
const cacheReport = vi.fn<(error: Error) => void>()
Expand Down Expand Up @@ -159,7 +159,7 @@ describe('injectMutation', () => {
})
})

it('reactive options should update mutation', () => {
it('should update mutation with reactive options', () => {
const mutationCache = queryClient.getMutationCache()
// Signal will be updated before the mutation is called
// this test confirms that the mutation uses the updated value
Expand All @@ -180,7 +180,7 @@ describe('injectMutation', () => {
expect(mutations?.options.mutationKey).toStrictEqual(['2'])
})

it('reflects a mutation started in ngOnInit', async () => {
it('should reflect a mutation started in ngOnInit', async () => {
const statusesInsideOnMutate: Array<string> = []

@Component({ template: '' })
Expand Down Expand Up @@ -208,7 +208,7 @@ describe('injectMutation', () => {
expect(fixture.componentInstance.mutation.status()).toBe('success')
})

it('allows cache listeners to read the result while options update', () => {
it('should allow cache listeners to read the result while options update', () => {
const mutationKey = signal('one')
const mutation = TestBed.runInInjectionContext(() =>
injectMutation(() => ({
Expand Down Expand Up @@ -237,7 +237,7 @@ describe('injectMutation', () => {
unsubscribe()
})

it('does not track mutation state when mutating from a reactive context', async () => {
it('should not track mutation state when mutating from a reactive context', async () => {
const trigger = signal(false)
const runs = vi.fn<() => void>()
const mutation = TestBed.runInInjectionContext(() =>
Expand Down Expand Up @@ -828,7 +828,7 @@ describe('injectMutation', () => {
})

describe('injection context', () => {
it('throws NG0203 with descriptive error outside injection context', () => {
it('should throw NG0203 with descriptive error outside injection context', () => {
expect(() => {
injectMutation(() => ({
mutationKey: ['injectionContextError'],
Expand Down Expand Up @@ -1040,7 +1040,7 @@ describe('injectMutation', () => {
expect(queryClient.getQueryData(testQueryKey)).toBe('final: test')
})

it('reads an optimistic update inside onMutate before the query signal or effects initialize', async () => {
it('should read an optimistic update inside onMutate before the query signal or effects initialize', async () => {
const testQueryKey = ['unread-sync-optimistic']
const seenInsideOnMutate: Array<string | undefined> = []
queryClient.setQueryData(testQueryKey, 'initial')
Expand Down
16 changes: 8 additions & 8 deletions packages/angular-query/src/__tests__/inject-queries.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { Resource, Signal } from '@angular/core'
import type { CreateQueryOptions, CreateQueryResult, OmitKeyof } from '..'

describe('InjectQueries config object overload', () => {
it('keeps optional initial data in service queryOptions results undefined-capable', () => {
it('should keep optional initial data in service queryOptions results undefined-capable', () => {
const service = {
options: () => queryOptions({ queryKey: ['service'], queryFn: () => 1 }),
}
Expand All @@ -26,7 +26,7 @@ describe('InjectQueries config object overload', () => {
}
})

it('supports status helpers on heterogeneous dynamic results and tuple indices', () => {
it('should support status helpers on heterogeneous dynamic results and tuple indices', () => {
const numberOptions = () =>
queryOptions({ queryKey: ['number'], queryFn: () => 1 })
const stringOptions = () =>
Expand Down Expand Up @@ -56,7 +56,7 @@ describe('InjectQueries config object overload', () => {
expectTypeOf(succeeded()).toEqualTypeOf<boolean>()
})

it('infers tagged custom errors in parallel queries and combine', () => {
it('should infer tagged custom errors in parallel queries and combine', () => {
class CustomError extends Error {
detail = 'detail'
}
Expand All @@ -74,7 +74,7 @@ describe('InjectQueries config object overload', () => {
expectTypeOf(combined()).toEqualTypeOf<CustomError | null>()
})

it('preserves custom errors from annotated options without a query-key tag', () => {
it('should preserve custom errors from annotated options without a query-key tag', () => {
class CustomError extends Error {
detail = 'detail'
}
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('InjectQueries config object overload', () => {
queryResults()[0].resource
})

it('tData should always be defined when initialData is provided as an object', () => {
it('should always define TData when initialData is provided as an object', () => {
const query1 = {
queryKey: ['key1'],
queryFn: () => {
Expand Down Expand Up @@ -147,7 +147,7 @@ describe('InjectQueries config object overload', () => {
expectTypeOf(query3Data).toEqualTypeOf<string | undefined>()
})

it('tData should be defined when passed through queryOptions', () => {
it('should define TData when passed through queryOptions', () => {
const options = queryOptions({
queryKey: ['key'],
queryFn: () => {
Expand Down Expand Up @@ -187,7 +187,7 @@ describe('InjectQueries config object overload', () => {
expectTypeOf(query2Data).toEqualTypeOf<boolean | undefined>()
})

it('tData should have undefined in the union when initialData is provided as a function which can return undefined', () => {
it('should have undefined in the TData union when initialData is provided as a function which can return undefined', () => {
const queryResults = injectQueries(() => ({
queries: [
{
Expand Down Expand Up @@ -232,7 +232,7 @@ describe('InjectQueries config object overload', () => {
})
})

it('tData should have correct type when conditional skipToken is passed', () => {
it('should have correct TData type when conditional skipToken is passed', () => {
const queryResults = injectQueries(() => ({
queries: [
{
Expand Down
Loading
Loading