diff --git a/packages/angular-query-persist-client/src/__tests__/with-persist-query-client.test.ts b/packages/angular-query-persist-client/src/__tests__/with-persist-query-client.test.ts index 50ac62369cf..d3c9a86add6 100644 --- a/packages/angular-query-persist-client/src/__tests__/with-persist-query-client.test.ts +++ b/packages/angular-query-persist-client/src/__tests__/with-persist-query-client.test.ts @@ -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 @@ -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< @@ -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 }>( @@ -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 } } >(() => ({ @@ -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() @@ -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', @@ -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()], }) diff --git a/packages/angular-query/schematics-build/migrate-from-experimental.test.ts b/packages/angular-query/schematics-build/migrate-from-experimental.test.ts index 397bb1f3918..5e1dae55c8b 100644 --- a/packages/angular-query/schematics-build/migrate-from-experimental.test.ts +++ b/packages/angular-query/schematics-build/migrate-from-experimental.test.ts @@ -29,7 +29,7 @@ function setup(source: string) { } describe('migrate-from-experimental', () => { - it('migrates aliases, factories, spreads, filters, helpers and dependencies; is idempotent', async () => { + it('should migrate aliases, factories, spreads, filters, helpers and dependencies idempotently', async () => { const { runner, tree } = setup(`import { QueryClient as Client, provideAngularQuery as provide, injectQueryClient as client, injectIsFetching } from '@tanstack/angular-query-experimental'; import { withDevtools } from '@tanstack/angular-query-experimental/devtools/production'; @@ -73,7 +73,7 @@ function unrelated(provide: any, client: any) { provide(new Client()); client(); expect(runner.tasks).toHaveLength(0) }) - it('handles namespaces without touching shadowed bindings or existing factories', async () => { + it('should handle namespaces without touching shadowed bindings or existing factories', async () => { const { runner, tree } = setup(`import * as query from '@tanstack/angular-query-experimental'; query.provideAngularQuery(new query.QueryClient()); @@ -98,7 +98,7 @@ function other(query: any) { query.provideAngularQuery(new query.QueryClient()); expect(runner.tasks).toHaveLength(0) }) - it('generates ordinary named imports when neither API is imported', async () => { + it('should generate ordinary named imports when neither API is imported', async () => { const { runner, tree } = setup(`import { injectQueryClient } from '@tanstack/angular-query-experimental'; const client = injectQueryClient();`) @@ -116,7 +116,7 @@ const client = injectQueryClient();`) expect(output).not.toContain('import { }') }) - it('reuses existing aliased and namespace imports', async () => { + it('should reuse existing aliased and namespace imports', async () => { const { runner, tree } = setup(`import { inject as angularInject } from '@angular/core'; import * as query from '@tanstack/angular-query-experimental'; @@ -131,7 +131,7 @@ const client = query.injectQueryClient();`) expect(output.match(/import /g)).toHaveLength(2) }) - it('adds readable aliases when existing imports are shadowed', async () => { + it('should add readable aliases when existing imports are shadowed', async () => { const { runner, tree } = setup(`import { inject } from '@angular/core'; import { QueryClient, injectQueryClient } from '@tanstack/angular-query-experimental'; function example(inject: unknown, QueryClient: unknown) { return injectQueryClient(); } @@ -159,7 +159,7 @@ const client = injectQueryClient();`) expect(again.readContent('/src/app.ts')).toBe(output) }) - it('does not use type-only imports as runtime values and avoids alias collisions', async () => { + it('should not use type-only imports as runtime values and avoid alias collisions', async () => { const { runner, tree } = setup(`import type { QueryClient } from '@tanstack/angular-query-experimental'; import { injectQueryClient } from '@tanstack/angular-query-experimental'; @@ -177,7 +177,7 @@ const client = injectQueryClient();`) expect(output).toContain('const client = inject(TanStackQueryClient2);') }) - it('reports ambiguous changes and preserves imperative error options', async () => { + it('should report ambiguous changes and preserve imperative error options', async () => { const { runner, tree, warnings } = setup(`import { provideTanStackQuery, injectQueries, injectIsMutating } from '@tanstack/angular-query-experimental'; provideTanStackQuery(client); @@ -202,7 +202,7 @@ query.refetch({ throwOnError: true }); }) it.each([false, true])( - 'wraps ambiguous client references only when unsafe wrapping is %s and warns about each conversion', + 'should wrap ambiguous client references only when unsafe wrapping is %s and warn about each conversion', async (unsafeWrapClientReferences) => { const { runner, tree, warnings } = setup(`import { provideAngularQuery as provide, QueryClient } from '@tanstack/angular-query-experimental'; @@ -252,7 +252,7 @@ function other(provide: any) { provide(client); }`) ) it.each([false, true])( - 'consolidates core imports and dependencies only when requested: %s', + 'should consolidate core imports and dependencies only when requested: %s', async (migrateQueryCoreImports) => { const { runner, tree } = setup(`import { QueryClient as Client, type QueryKey } from '@tanstack/query-core'; @@ -313,7 +313,7 @@ provideTanStackQuery(new core.QueryClient()); }, ) - it('adds Angular Query when replacing a dependency used only through core imports', async () => { + it('should add Angular Query when replacing a dependency used only through core imports', async () => { const { runner, tree } = setup( `import type { QueryKey } from '@tanstack/query-core';`, ) @@ -341,7 +341,7 @@ provideTanStackQuery(new core.QueryClient()); ['src/subpath.ts', `import '@tanstack/query-core/unsupported'`], ['src/dynamic.ts', 'const core = import(`@tanstack/query-core/${entry}`)'], ])( - 'retains core dependencies for remaining references in %s', + 'should retain core dependencies for remaining references in %s', async (path, source) => { const { runner, tree, warnings } = setup( `import { QueryClient } from '@tanstack/query-core';`, @@ -382,7 +382,7 @@ provideTanStackQuery(new core.QueryClient()); ] it.each(helpers)( - 'warns for named, aliased and namespace calls to %s', + 'should warn for named, aliased and namespace calls to %s', async (helper) => { const args = helper === 'injectIsRestoring' @@ -423,7 +423,7 @@ query.${helper}(${args});`) ) it.each(helpers)( - 'does not warn for current signatures or shadowed %s', + 'should not warn for current signatures or shadowed %s', async (helper) => { const args = helper === 'injectIsRestoring' ? '' : '() => ({})' const { runner, tree, warnings } = @@ -435,7 +435,7 @@ function unrelated(${helper}: any) { ${helper}(options, { injector }); }`) }, ) - it('reports undefined options, optional injector objects and spread arguments', async () => { + it('should report undefined options, optional injector objects and spread arguments', async () => { const { runner, tree, warnings } = setup(`import { injectQuery, injectMutation, injectIsRestoring } from '@tanstack/angular-query-experimental'; injectQuery(options, undefined); @@ -451,7 +451,7 @@ injectQuery(...args);`) }) it.each(['injectIsFetching', 'injectIsMutating'])( - 'still wraps filters while warning about %s injector options', + 'should still wrap filters while warning about %s injector options', async (helper) => { const { runner, tree, warnings } = setup(`import { ${helper} } from '@tanstack/angular-query-experimental'; @@ -476,7 +476,7 @@ ${helper}({}, { injector });`) 'InjectMutationStateOptions', 'InjectIsFetchingOptions', 'InjectIsMutatingOptions', - ])('flags removed %s types used by wrappers', async (name) => { + ])('should flag removed %s types used by wrappers', async (name) => { const { runner, tree, warnings } = setup(`import type { ${name} as Options } from '@tanstack/angular-query-experimental'; import type * as query from '@tanstack/angular-query-experimental'; @@ -489,7 +489,7 @@ let other: query.${name};`) }) }) - it('preserves existing stable dependency versions and skips generated files', async () => { + it('should preserve existing stable dependency versions and skip generated files', async () => { const { runner, tree } = setup( `export { injectQueries } from '@tanstack/angular-query-experimental/inject-queries-experimental';`, ) @@ -535,7 +535,7 @@ describe('migration regression coverage', () => { ['devtools-panel', '/devtools-panel'], ['devtools-panel/production', '/devtools-panel/production'], ])( - 'moves the %s entrypoint and installs devtools', + 'should move the %s entrypoint and install devtools', async (oldPath, newPath) => { const { runner, tree } = setup(`import * as tools from '@tanstack/angular-query-experimental/${oldPath}'; @@ -562,7 +562,7 @@ export * from '@tanstack/angular-query-experimental/${oldPath}';`) }, ) - it('reports unknown entrypoints instead of inventing an export', async () => { + it('should report unknown entrypoints instead of inventing an export', async () => { const { runner, tree, warnings } = setup( `import * as tools from '@tanstack/angular-query-experimental/devtools/panel';`, ) @@ -582,7 +582,7 @@ export * from '@tanstack/angular-query-experimental/${oldPath}';`) ).toBeUndefined() }) - it('renames provider references and reports indirect helper uses without touching shadowed namespaces', async () => { + it('should rename provider references and report indirect helper uses without touching shadowed namespaces', async () => { const { runner, tree, warnings } = setup(`import * as query from '@tanstack/angular-query-experimental'; import { provideAngularQuery as provide, injectIsFetching } from '@tanstack/angular-query-experimental'; @@ -621,7 +621,7 @@ function unrelated(query: any) { return query.provideAngularQuery; }`) ['PersistQueryClientFeature', 'non-generic QueryFeature'], ['CreateBaseQueryOptions', 'CreateQueryOptions'], ])( - 'reports removed %s imports, namespace references and re-exports', + 'should report removed %s imports, namespace references and re-exports', async (name, guidance) => { const { runner, tree, warnings } = setup(`import { ${name} as legacy } from '@tanstack/angular-query-experimental'; @@ -637,7 +637,7 @@ type Used = typeof query.${name};`) }, ) - it('reports generic QueryFeature references through aliases and namespaces', async () => { + it('should report generic QueryFeature references through aliases and namespaces', async () => { const { runner, tree, warnings } = setup(`import type { QueryFeature as Feature } from '@tanstack/angular-query-experimental'; import type * as query from '@tanstack/angular-query-experimental'; @@ -653,7 +653,7 @@ let supported: Feature;`) ).toBe(true) }) - it('preserves type-only provider specifiers when renaming imports', async () => { + it('should preserve type-only provider specifiers when renaming imports', async () => { const { runner, tree } = setup(`import { type provideAngularQuery } from '@tanstack/angular-query-experimental'; type Provider = typeof provideAngularQuery;`) @@ -667,7 +667,7 @@ type Provider = typeof provideAngularQuery;`) ) }) - it('limits option diagnostics to observer options, client defaults and devtools injection dependencies', async () => { + it('should limit option diagnostics to observer options, client defaults and devtools injection dependencies', async () => { const { runner, tree, warnings } = setup(`import { injectQuery as query, mutationOptions, QueryClient } from '@tanstack/angular-query-experimental'; import { withDevtools as tools } from '@tanstack/angular-query-experimental/devtools'; @@ -701,7 +701,7 @@ function shadowed(query: any, tools: any) { query(() => ({ throwOnError: true }) ) }) - it('finds returned observer options without treating nested functions as option factories', async () => { + it('should find returned observer options without treating nested functions as option factories', async () => { const { runner, tree, warnings } = setup(`import { injectInfiniteQuery, injectMutation } from '@tanstack/angular-query-experimental'; injectInfiniteQuery(() => { const unrelated = () => ({ throwOnError: true }); return { throwOnError: true }; }); @@ -713,7 +713,7 @@ injectMutation(() => condition ? { throwOnError: true } : ({ throwOnError: true ).toBe(true) }) - it('replaces peer and optional dependencies while preserving existing ranges and unrelated manifest formatting', async () => { + it('should replace peer and optional dependencies while preserving existing ranges and unrelated manifest formatting', async () => { const { runner, tree, warnings } = setup( `import { injectQuery } from '@tanstack/angular-query-experimental';`, ) @@ -739,7 +739,7 @@ injectMutation(() => condition ? { throwOnError: true } : ({ throwOnError: true expect(runner.tasks).toHaveLength(1) }) - it('uses inherited build/test configurations, follows local imports, and updates library manifests', async () => { + it('should use inherited build/test configurations, follow local imports, and update library manifests', async () => { const legacy = `import { injectQuery } from '@tanstack/angular-query-experimental';` const { runner, tree } = setup(legacy) tree.create( @@ -868,7 +868,7 @@ injectMutation(() => condition ? { throwOnError: true } : ({ throwOnError: true }) it.each([false, true])( - 'discovers Nx libraries from project.json alongside an Angular workspace: %s', + 'should discover Nx libraries from project.json alongside an Angular workspace: %s', async (angularWorkspace) => { const legacy = `import { QueryClient } from '@tanstack/angular-query-experimental';` const { runner, tree, warnings } = setup(legacy) @@ -959,7 +959,7 @@ export type { QueryKey } from '@tanstack/query-core';`, }, ) - it('resolves imports of package subpaths that name a file', async () => { + it('should resolve imports of package subpaths that name a file', async () => { // TypeScript probes `directoryExists` with candidate paths that are files, like // `/node_modules/@noble/hashes/sha3.js`; that must not abort the migration. const { runner, tree } = setup( @@ -1010,7 +1010,7 @@ import { sha3_256 } from '@noble/hashes/sha3.js';`, expect(result.readContent('/src/app.ts')).toContain(packageJson.name) }) - it('discovers package-based Nx libraries and respects their tsconfigs', async () => { + it('should discover package-based Nx libraries and respect their tsconfigs', async () => { const legacy = `import { QueryClient } from '@tanstack/angular-query-experimental';` const { runner, tree } = setup(legacy) tree.create('/nx.json', '{}') @@ -1050,7 +1050,7 @@ import { sha3_256 } from '@noble/hashes/sha3.js';`, ).toStrictEqual({ [packageJson.name]: `^${packageJson.version}` }) }) - it('keeps a root core dependency used by an excluded nested library source', async () => { + it('should keep a root core dependency used by an excluded nested library source', async () => { const { runner, tree, warnings } = setup( `import { QueryClient } from '@tanstack/query-core';`, ) @@ -1087,7 +1087,7 @@ import { sha3_256 } from '@noble/hashes/sha3.js';`, ) }) - it('summarizes prepared changes, links to the guide, and explains skipped installation', async () => { + it('should summarize prepared changes, link to the guide, and explain skipped installation', async () => { const { runner, tree, messages } = setup( `import { injectQuery } from '@tanstack/angular-query-experimental';`, ) @@ -1111,7 +1111,7 @@ import { sha3_256 } from '@noble/hashes/sha3.js';`, expect(runner.tasks).toHaveLength(0) }) - it('reports panel injector arguments and the removed panel options type', async () => { + it('should report panel injector arguments and the removed panel options type', async () => { const { runner, tree, warnings } = setup(`import { injectDevtoolsPanel as panel, type InjectDevtoolsPanelOptions } from '@tanstack/angular-query-experimental/devtools-panel'; panel(() => ({}), { injector });`) @@ -1135,7 +1135,7 @@ describe('migration dependency specifiers', () => { [true, false].map((versioned) => ({ type, versioned })), ), )( - 'replaces experimental aliases in $type (versioned=$versioned) and remains idempotent', + 'should replace experimental aliases in $type (versioned=$versioned) and remain idempotent', async ({ type, versioned }) => { const { runner, tree } = setup( `import { provideAngularQuery, QueryClient } from '@tanstack/angular-query'; @@ -1180,7 +1180,7 @@ provideAngularQuery(new QueryClient());`, }, ) - it('replaces an alias alongside the original dependency and respects skipInstall', async () => { + it('should replace an alias alongside the original dependency and respect skipInstall', async () => { const { runner, tree } = setup( `import { QueryClient } from '@tanstack/angular-query-experimental';`, ) @@ -1205,7 +1205,7 @@ provideAngularQuery(new QueryClient());`, expect(runner.tasks).toHaveLength(0) }) - it('preserves unrelated npm aliases', async () => { + it('should preserve unrelated npm aliases', async () => { const { runner, tree } = setup( `import { QueryClient } from '@tanstack/angular-query';`, ) @@ -1242,31 +1242,34 @@ provideAngularQuery(new QueryClient());`, ['>=5.90.25', false], ['*', false], ['latest', false], - ])('preserves pin policy when replacing %s', async (previous, exact) => { - const { runner, tree } = setup( - `import { withDevtools } from '@tanstack/angular-query-experimental/devtools';`, - ) - tree.overwrite( - '/package.json', - JSON.stringify({ - dependencies: { '@tanstack/angular-query-experimental': previous }, - }), - ) - const result = await runner.runSchematic( - 'migrate-from-experimental', - {}, - tree, - ) - expect( - JSON.parse(result.readContent('/package.json')).dependencies, - ).toStrictEqual({ - [packageJson.name]: `${exact ? '' : '^'}${packageJson.version}`, - [devtoolsPackage.name]: `${exact ? '' : '^'}${devtoolsPackage.version}`, - }) - }) + ])( + 'should preserve pin policy when replacing %s', + async (previous, exact) => { + const { runner, tree } = setup( + `import { withDevtools } from '@tanstack/angular-query-experimental/devtools';`, + ) + tree.overwrite( + '/package.json', + JSON.stringify({ + dependencies: { '@tanstack/angular-query-experimental': previous }, + }), + ) + const result = await runner.runSchematic( + 'migrate-from-experimental', + {}, + tree, + ) + expect( + JSON.parse(result.readContent('/package.json')).dependencies, + ).toStrictEqual({ + [packageJson.name]: `${exact ? '' : '^'}${packageJson.version}`, + [devtoolsPackage.name]: `${exact ? '' : '^'}${devtoolsPackage.version}`, + }) + }, + ) it.each(['v5.90.25', '=5.90.25', ' 5.90.25 ', '= v5.90.25'])( - 'preserves an exact alias pin written as %s', + 'should preserve an exact alias pin written as %s', async (previous) => { const { runner, tree } = setup( "import { QueryClient } from '@tanstack/angular-query';", @@ -1294,7 +1297,7 @@ provideAngularQuery(new QueryClient());`, }, ) - it('preserves a development dependency pin when adding devtools', async () => { + it('should preserve a development dependency pin when adding devtools', async () => { const { runner, tree } = setup( "import { withDevtools } from '@tanstack/angular-query-experimental/devtools'", ) @@ -1316,7 +1319,7 @@ provideAngularQuery(new QueryClient());`, ) }) - it('preserves exact core pins when opting into core migration', async () => { + it('should preserve exact core pins when opting into core migration', async () => { const { runner, tree } = setup( `import { QueryClient } from '@tanstack/query-core';`, ) @@ -1336,7 +1339,7 @@ provideAngularQuery(new QueryClient());`, ).toStrictEqual({ [packageJson.name]: packageJson.version }) }) - it('keeps existing stable and devtools version specifiers', async () => { + it('should keep existing stable and devtools version specifiers', async () => { const { runner, tree } = setup( `import { withDevtools } from '@tanstack/angular-query-experimental/devtools';`, ) @@ -1366,7 +1369,7 @@ provideAngularQuery(new QueryClient());`, describe('project-local test configurations', () => { it.each(['', 'projects/app'])( - 'discovers the default spec config under %s', + 'should discover the default spec config under %s', async (root) => { const { runner, tree } = setup( `import { QueryClient } from '@tanstack/angular-query-experimental';`, @@ -1426,7 +1429,7 @@ describe('project-local test configurations', () => { ['manual Vitest', { command: 'vitest run' }], ['package script', undefined], ])( - 'discovers test configs for %s alongside a library build', + 'should discover test configs for %s alongside a library build', async (_runner, test) => { const { runner, tree } = setup( "import { QueryClient } from '@tanstack/angular-query-experimental';", @@ -1474,7 +1477,7 @@ describe('project-local test configurations', () => { }, ) - it('respects library and test configs in a standalone package without targets', async () => { + it('should respect library and test configs in a standalone package without targets', async () => { const { runner, tree } = setup( "import { QueryClient } from '@tanstack/angular-query-experimental';", ) @@ -1506,7 +1509,7 @@ describe('project-local test configurations', () => { }) it.each([false, true])( - 'keeps application sources with a standalone spec config (solution=%s)', + 'should keep application sources with a standalone spec config (solution=%s)', async (solution) => { const { runner, tree } = setup( "import { QueryClient } from '@tanstack/angular-query-experimental';", @@ -1554,7 +1557,7 @@ describe('project-local test configurations', () => { ) it.each([false, true])( - 'keeps an explicit test config across merged Nx declarations (metadata first=%s)', + 'should keep an explicit test config across merged Nx declarations (metadata first=%s)', async (metadataFirst) => { const { runner, tree } = setup( "import { QueryClient } from '@tanstack/angular-query-experimental';", @@ -1617,7 +1620,7 @@ describe('project-local test configurations', () => { }, ) - it('uses an explicit test config instead of the default spec config', async () => { + it('should use an explicit test config instead of the default spec config', async () => { const { runner, tree } = setup( `import { QueryClient } from '@tanstack/angular-query-experimental';`, ) diff --git a/packages/angular-query/schematics-build/ng-add.test.ts b/packages/angular-query/schematics-build/ng-add.test.ts index a4285e407c7..78808881a98 100644 --- a/packages/angular-query/schematics-build/ng-add.test.ts +++ b/packages/angular-query/schematics-build/ng-add.test.ts @@ -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', @@ -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', @@ -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( diff --git a/packages/angular-query/src/__tests__/inject-infinite-query.test-d.ts b/packages/angular-query/src/__tests__/inject-infinite-query.test-d.ts index e9d70908bcc..ebbb2ece22f 100644 --- a/packages/angular-query/src/__tests__/inject-infinite-query.test-d.ts +++ b/packages/angular-query/src/__tests__/inject-infinite-query.test-d.ts @@ -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 = >( query: CreateInfiniteQueryResult, ) => query.data()?.pages @@ -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 }) => @@ -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 }) => @@ -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 }) => @@ -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 }) => @@ -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 }) => @@ -178,7 +178,7 @@ describe('injectInfiniteQuery', () => { }) describe('injectInfiniteQuery options', () => { - it('omits observer error reporting options', () => { + it('should omit observer error reporting options', () => { expectTypeOf().not.toHaveProperty( 'throwOnError', ) diff --git a/packages/angular-query/src/__tests__/inject-infinite-query.test.ts b/packages/angular-query/src/__tests__/inject-infinite-query.test.ts index c860d78ed15..b9ee26aaec7 100644 --- a/packages/angular-query/src/__tests__/inject-infinite-query.test.ts +++ b/packages/angular-query/src/__tests__/inject-infinite-query.test.ts @@ -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') @@ -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'], diff --git a/packages/angular-query/src/__tests__/inject-is-restoring.test.ts b/packages/angular-query/src/__tests__/inject-is-restoring.test.ts index 6ebcdf58665..d29ce57d318 100644 --- a/packages/angular-query/src/__tests__/inject-is-restoring.test.ts +++ b/packages/angular-query/src/__tests__/inject-is-restoring.test.ts @@ -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({ @@ -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('restoration state') TestBed.configureTestingModule({ @@ -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/) diff --git a/packages/angular-query/src/__tests__/inject-mutation-state.test.ts b/packages/angular-query/src/__tests__/inject-mutation-state.test.ts index 9b0d6d341c8..e7a8cf993c2 100644 --- a/packages/angular-query/src/__tests__/inject-mutation-state.test.ts +++ b/packages/angular-query/src/__tests__/inject-mutation-state.test.ts @@ -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'] }) @@ -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' @@ -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'] }, @@ -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/) diff --git a/packages/angular-query/src/__tests__/inject-mutation.test-d.ts b/packages/angular-query/src/__tests__/inject-mutation.test-d.ts index 52adbed552a..4091e48e4fb 100644 --- a/packages/angular-query/src/__tests__/inject-mutation.test-d.ts +++ b/packages/angular-query/src/__tests__/inject-mutation.test-d.ts @@ -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 = ( mutation: CreateMutationResult, ) => mutation.data()?.id @@ -169,7 +169,7 @@ describe('injectMutation', () => { }) describe('injectMutation options', () => { - it('omits observer error reporting options', () => { + it('should omit observer error reporting options', () => { expectTypeOf().not.toHaveProperty('throwOnError') }) }) diff --git a/packages/angular-query/src/__tests__/inject-mutation.test.ts b/packages/angular-query/src/__tests__/inject-mutation.test.ts index 28b94607d92..edf9ff67a9f 100644 --- a/packages/angular-query/src/__tests__/inject-mutation.test.ts +++ b/packages/angular-query/src/__tests__/inject-mutation.test.ts @@ -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>() @@ -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 @@ -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 = [] @Component({ template: '' }) @@ -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(() => ({ @@ -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(() => @@ -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'], @@ -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 = [] queryClient.setQueryData(testQueryKey, 'initial') diff --git a/packages/angular-query/src/__tests__/inject-queries.test-d.ts b/packages/angular-query/src/__tests__/inject-queries.test-d.ts index e92158a8df0..697998a8d66 100644 --- a/packages/angular-query/src/__tests__/inject-queries.test-d.ts +++ b/packages/angular-query/src/__tests__/inject-queries.test-d.ts @@ -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 }), } @@ -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 = () => @@ -56,7 +56,7 @@ describe('InjectQueries config object overload', () => { expectTypeOf(succeeded()).toEqualTypeOf() }) - 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' } @@ -74,7 +74,7 @@ describe('InjectQueries config object overload', () => { expectTypeOf(combined()).toEqualTypeOf() }) - 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' } @@ -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: () => { @@ -147,7 +147,7 @@ describe('InjectQueries config object overload', () => { expectTypeOf(query3Data).toEqualTypeOf() }) - it('tData should be defined when passed through queryOptions', () => { + it('should define TData when passed through queryOptions', () => { const options = queryOptions({ queryKey: ['key'], queryFn: () => { @@ -187,7 +187,7 @@ describe('InjectQueries config object overload', () => { expectTypeOf(query2Data).toEqualTypeOf() }) - 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: [ { @@ -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: [ { diff --git a/packages/angular-query/src/__tests__/inject-queries.test.ts b/packages/angular-query/src/__tests__/inject-queries.test.ts index de14be3117e..fa82284329e 100644 --- a/packages/angular-query/src/__tests__/inject-queries.test.ts +++ b/packages/angular-query/src/__tests__/inject-queries.test.ts @@ -39,7 +39,7 @@ describe('injectQueries', () => { }) it.each([false, true])( - 'uses current options and slot identity for multi-query refetch (combine=%s)', + 'should use current options and slot identity for multi-query refetch (combine=%s)', async (combine) => { vi.useRealTimers() const keys = signal(['a', 'b']) @@ -102,7 +102,7 @@ describe('injectQueries', () => { expect(report).not.toHaveBeenCalled() }) - it('throws NG0203 with descriptive error outside injection context', () => { + it('should throw NG0203 with descriptive error outside injection context', () => { expect(() => { injectQueries(() => ({ queries: [ @@ -115,7 +115,7 @@ describe('injectQueries', () => { }).toThrow(/NG0203(.*?)injectQueries/) }) - it('allows cache listeners to read a result while options update', () => { + it('should allow cache listeners to read a result while options update', () => { const staleTime = signal(0) const queries = TestBed.runInInjectionContext(() => injectQueries(() => ({ @@ -154,7 +154,7 @@ describe('injectQueries', () => { unsubscribe() }) - it('allows deferred cache-listener reads during restoration detach and reattach', async () => { + it('should allow deferred cache-listener reads during restoration detach and reattach', async () => { const isRestoring = signal(false) setupTanStackQueryTestBed(queryClient, { providers: [provideIsRestoring(() => isRestoring.asReadonly())], @@ -192,7 +192,7 @@ describe('injectQueries', () => { unsubscribe() }) - it('allows deferred cache-listener reads while a list change creates a query', async () => { + it('should allow deferred cache-listener reads while a list change creates a query', async () => { const key = signal('old') const queries = TestBed.runInInjectionContext(() => injectQueries(() => ({ @@ -419,7 +419,7 @@ describe('injectQueries', () => { ).toBe(true) }) - it('updates the result shape when combine configuration changes', () => { + it('should update the result shape when combine configuration changes', () => { const shouldCombine = signal(false) const queries = TestBed.runInInjectionContext(() => injectQueries(() => ({ @@ -442,7 +442,7 @@ describe('injectQueries', () => { expect(queries()).toStrictEqual({ count: 1 }) }) - it('removes a combined result when combine configuration changes', () => { + it('should remove a combined result when combine configuration changes', () => { const shouldCombine = signal(true) const queries = TestBed.runInInjectionContext(() => injectQueries(() => ({ @@ -466,7 +466,7 @@ describe('injectQueries', () => { expect(queries()).toHaveLength(1) }) - it('combines fresh raw results when a signal changes what combine selects', () => { + it('should combine fresh raw results when a signal changes what combine selects', () => { const showData = signal(false) const key = ['reactive-combine-selection'] queryClient.setQueryData(key, 1) @@ -1040,7 +1040,7 @@ describe('injectQueries', () => { expect(errorQuery.error()).toStrictEqual(new Error('instant-error')) }) - it('tracks invalidation even when combine returns an unchanged value', async () => { + it('should track invalidation even when combine returns an unchanged value', async () => { vi.useRealTimers() const key = ['combined-pending-invalidation'] let complete!: (value: number) => void @@ -1331,7 +1331,7 @@ describe('injectQueries', () => { }) it.each(['options-first', 'restoring-first'] as const)( - 'uses the latest query list when leaving restoration in the same turn (%s)', + 'should use the latest query list when leaving restoration in the same turn (%s)', async (writeOrder) => { const isRestoring = signal(true) const key = signal('old') @@ -1386,7 +1386,7 @@ describe('injectQueries', () => { }, ) - it('allows a cache listener to read a result during restoration-boundary configuration', () => { + it('should allow a cache listener to read a result during restoration-boundary configuration', () => { const isRestoring = signal(true) const staleTime = signal(0) setupTanStackQueryTestBed(queryClient, { @@ -1436,7 +1436,7 @@ describe('injectQueries', () => { unsubscribe() }) - it('converges to the current query list after an early restoration read', () => { + it('should converge to the current query list after an early restoration read', () => { const isRestoring = signal(true) const key = signal('old') const oldQueryKey = ['early-restoration-read', 'old'] as const @@ -1484,7 +1484,7 @@ describe('injectQueries', () => { expect(queries()[0].data()).toBe('early data') }) - it('reads the optimistic query list before moving subscriptions on the next tick', () => { + it('should read the optimistic query list before moving subscriptions on the next tick', () => { const key = signal('old') const oldQueryKey = ['early-options-read', 'old'] as const const newQueryKey = ['early-options-read', 'new'] as const diff --git a/packages/angular-query/src/__tests__/inject-query-lifecycle.test.ts b/packages/angular-query/src/__tests__/inject-query-lifecycle.test.ts index 9f29ebafac7..ec401d9f439 100644 --- a/packages/angular-query/src/__tests__/inject-query-lifecycle.test.ts +++ b/packages/angular-query/src/__tests__/inject-query-lifecycle.test.ts @@ -55,7 +55,7 @@ function setupLifecycle() { } describe('QueryLifecycle', () => { - it('tracks pending state without registering duplicate tasks', () => { + it('should track pending state without registering duplicate tasks', () => { const { lifecycle, pendingTasks, taskCleanups } = setupLifecycle() lifecycle.setPending(true) @@ -70,7 +70,7 @@ describe('QueryLifecycle', () => { expect(pendingTasks.add).toHaveBeenCalledTimes(2) }) - it('tracks destruction, releases its task, and cannot restart', () => { + it('should track destruction, release its task, and not restart', () => { const { lifecycle, pendingTasks, taskCleanups, destroy } = setupLifecycle() lifecycle.setPending(true) diff --git a/packages/angular-query/src/__tests__/inject-query.test.ts b/packages/angular-query/src/__tests__/inject-query.test.ts index 5ee0b0c5411..a192539413c 100644 --- a/packages/angular-query/src/__tests__/inject-query.test.ts +++ b/packages/angular-query/src/__tests__/inject-query.test.ts @@ -439,7 +439,7 @@ describe('injectQuery', () => { ) }) - it('allows cache listeners to read the result while options update', () => { + it('should allow cache listeners to read the result while options update', () => { const key = signal('one') const query = TestBed.runInInjectionContext(() => injectQuery(() => ({ @@ -467,7 +467,7 @@ describe('injectQuery', () => { unsubscribe() }) - it('allows deferred cache-listener reads during restoration detach and reattach', async () => { + it('should allow deferred cache-listener reads during restoration detach and reattach', async () => { const isRestoring = signal(false) TestBed.resetTestingModule() TestBed.configureTestingModule({ @@ -504,7 +504,7 @@ describe('injectQuery', () => { unsubscribe() }) - it('allows deferred cache-listener reads while an option change creates a query', async () => { + it('should allow deferred cache-listener reads while an option change creates a query', async () => { const key = signal('old') const query = TestBed.runInInjectionContext(() => injectQuery(() => ({ @@ -532,7 +532,7 @@ describe('injectQuery', () => { unsubscribe() }) - it('keeps the external subscription when non-key options change', () => { + it('should keep the external subscription when non-key options change', () => { const staleTime = signal(0) const query = TestBed.runInInjectionContext(() => injectQuery(() => ({ @@ -1031,7 +1031,7 @@ describe('injectQuery', () => { }) it.each(['options-first', 'restoring-first'] as const)( - 'uses the latest options when leaving restoration in the same turn (%s)', + 'should use the latest options when leaving restoration in the same turn (%s)', async (writeOrder) => { const isRestoring = signal(true) const key = signal('old') @@ -1090,7 +1090,7 @@ describe('injectQuery', () => { }, ) - it('allows a cache listener to read the result during restoration-boundary configuration', () => { + it('should allow a cache listener to read the result during restoration-boundary configuration', () => { const isRestoring = signal(true) const key = signal('old') @@ -1140,7 +1140,7 @@ describe('injectQuery', () => { unsubscribe() }) - it('converges to the current query after an early restoration read', async () => { + it('should converge to the current query after an early restoration read', async () => { const isRestoring = signal(true) const key = signal('old') const queriedKeys: Array = [] @@ -1195,7 +1195,7 @@ describe('injectQuery', () => { expect(query.data()).toBe('early data') }) - it('reads optimistic options before moving the subscription on the next tick', () => { + it('should read optimistic options before moving the subscription on the next tick', () => { const key = signal('old') const oldQueryKey = ['early-options-read', 'old'] as const const newQueryKey = ['early-options-read', 'new'] as const @@ -1231,7 +1231,7 @@ describe('injectQuery', () => { }) describe('injection context', () => { - it('throws NG0203 with descriptive error outside injection context', () => { + it('should throw NG0203 with descriptive error outside injection context', () => { expect(() => { injectQuery(() => ({ queryKey: ['injectionContextError'], diff --git a/packages/angular-query/src/__tests__/pending-tasks-ssr.zoneful.test.ts b/packages/angular-query/src/__tests__/pending-tasks-ssr.zoneful.test.ts index 596cc0b58cb..c9c14a3f9c5 100644 --- a/packages/angular-query/src/__tests__/pending-tasks-ssr.zoneful.test.ts +++ b/packages/angular-query/src/__tests__/pending-tasks-ssr.zoneful.test.ts @@ -135,23 +135,23 @@ async function render(component: Type) { describe('SSR with real Zone.js timers', () => { afterEach(() => destroyPlatform()) - it('serializes cached data without waiting for stale or GC timers', async () => { + it('should serialize cached data without waiting for stale or GC timers', async () => { await expect(render(CachedQueryComponent)).resolves.toContain( 'cached-on-server', ) }) - it('serializes reactive query changes without waiting for background timers', async () => { + it('should serialize reactive query changes without waiting for background timers', async () => { await expect(render(ReactiveQueryComponent)).resolves.toContain('second') }) - it('waits for a query fetch, but not its background timers', async () => { + it('should wait for a query fetch, but not its background timers', async () => { await expect(render(FetchingQueryComponent)).resolves.toContain( 'fetched-on-server', ) }) - it('waits for parallel query fetches, but not their background timers', async () => { + it('should wait for parallel query fetches, but not their background timers', async () => { await expect(render(FetchingQueriesComponent)).resolves.toContain( 'fetched-on-server', ) diff --git a/packages/angular-query/src/__tests__/pending-tasks.test.ts b/packages/angular-query/src/__tests__/pending-tasks.test.ts index 69653da2b41..762ed7549a4 100644 --- a/packages/angular-query/src/__tests__/pending-tasks.test.ts +++ b/packages/angular-query/src/__tests__/pending-tasks.test.ts @@ -48,7 +48,7 @@ describe('PendingTasks Integration', () => { }) it.each([false, true])( - 'keeps all mutation invocations pending (reset=%s)', + 'should keep all mutation invocations pending (reset=%s)', async (reset) => { vi.useRealTimers() const resolve = new Map void>() @@ -446,7 +446,7 @@ describe('PendingTasks Integration', () => { }) describe('Component Destruction', () => { - it('becomes stable after destruction before an unresolved query completes', async () => { + it('should become stable after destruction before an unresolved query completes', async () => { vi.useRealTimers() let resolveQuery!: (value: string) => void const queryPromise = new Promise((resolve) => { @@ -473,7 +473,7 @@ describe('PendingTasks Integration', () => { await Promise.resolve() }) - it('becomes stable after destruction before an unresolved mutation completes', async () => { + it('should become stable after destruction before an unresolved mutation completes', async () => { vi.useRealTimers() let resolveMutation!: (value: string) => void const mutationPromise = new Promise((resolve) => { diff --git a/packages/angular-query/src/__tests__/provide-tanstack-query.test-d.ts b/packages/angular-query/src/__tests__/provide-tanstack-query.test-d.ts index 814f624e4b8..9c684048630 100644 --- a/packages/angular-query/src/__tests__/provide-tanstack-query.test-d.ts +++ b/packages/angular-query/src/__tests__/provide-tanstack-query.test-d.ts @@ -10,7 +10,7 @@ import type * as PublicApi from '..' import type * as InternalApi from '../internal' describe('provideTanStackQuery', () => { - it('keeps integration helpers out of the public entry point', () => { + it('should keep integration helpers out of the public entry point', () => { type InternalHelpers = | 'queryFeature' | 'getQueryFeatureProviders' @@ -21,7 +21,7 @@ describe('provideTanStackQuery', () => { >().toEqualTypeOf() }) - it('accepts built-in opaque query features', () => { + it('should accept built-in opaque query features', () => { expectTypeOf(withHydrationKey('cache')).toEqualTypeOf() expectTypeOf(withNoQueryHydration()).toEqualTypeOf() @@ -32,7 +32,7 @@ describe('provideTanStackQuery', () => { ) }) - it('rejects structurally fabricated features', () => { + it('should reject structurally fabricated features', () => { expectTypeOf(withHydrationKey('cache')).toEqualTypeOf() provideTanStackQuery( diff --git a/packages/angular-query/src/__tests__/provide-tanstack-query.test.ts b/packages/angular-query/src/__tests__/provide-tanstack-query.test.ts index 64769d31fec..07fa23ff405 100644 --- a/packages/angular-query/src/__tests__/provide-tanstack-query.test.ts +++ b/packages/angular-query/src/__tests__/provide-tanstack-query.test.ts @@ -20,7 +20,7 @@ describe('provideTanStackQuery', () => { expect(providedQueryClient).toBe(queryClient) }) - it('resolves an existing QueryClient through a factory in the injection context', () => { + it('should resolve an existing QueryClient through a factory in the injection context', () => { const queryClient = new QueryClient() const CUSTOM_QUERY_CLIENT = new InjectionToken('', { factory: () => queryClient, @@ -39,7 +39,7 @@ describe('provideTanStackQuery', () => { }) describe('server client defaults', () => { - it('uses server defaults without changing an unrelated client', () => { + it('should use server defaults without changing an unrelated client', () => { const unrelated = new QueryClient() TestBed.configureTestingModule({ providers: [ @@ -55,7 +55,7 @@ describe('server client defaults', () => { expect(unrelated.getDefaultOptions()).toStrictEqual({}) }) - it('preserves explicit server client defaults', () => { + it('should preserve explicit server client defaults', () => { TestBed.configureTestingModule({ providers: [ provideAngularQueryChangeDetection(), diff --git a/packages/angular-query/src/__tests__/query-options.test.ts b/packages/angular-query/src/__tests__/query-options.test.ts index 40d5704be74..998b31154f8 100644 --- a/packages/angular-query/src/__tests__/query-options.test.ts +++ b/packages/angular-query/src/__tests__/query-options.test.ts @@ -12,7 +12,7 @@ describe('queryOptions', () => { expect(queryOptions(object)).toBe(object) }) - it('keeps notifyOnChangeProps adapter-owned', () => { + it('should keep notifyOnChangeProps adapter-owned', () => { const options: CreateQueryOptions = { queryKey: ['key'], // @ts-expect-error Angular Query always subscribes to every result change. diff --git a/packages/angular-query/src/__tests__/signal-proxy.test.ts b/packages/angular-query/src/__tests__/signal-proxy.test.ts index a7522e73eab..5b5e6d480dd 100644 --- a/packages/angular-query/src/__tests__/signal-proxy.test.ts +++ b/packages/angular-query/src/__tests__/signal-proxy.test.ts @@ -13,7 +13,7 @@ import { signalProxy } from '../utils/signal-proxy' import { provideAngularQueryChangeDetection } from './test-utils' describe('signalProxy', () => { - it('only exposes declared fields with ordinary object semantics', async () => { + it('should only expose declared fields with ordinary object semantics', async () => { const source = signal({ value: 'data', falsy: false, zero: 0 }) const proxy = signalProxy(source, ['value', 'falsy', 'zero']) diff --git a/packages/angular-query/src/__tests__/upstream-issues.test.ts b/packages/angular-query/src/__tests__/upstream-issues.test.ts index 1fc1309b1d8..8b712579dc3 100644 --- a/packages/angular-query/src/__tests__/upstream-issues.test.ts +++ b/packages/angular-query/src/__tests__/upstream-issues.test.ts @@ -46,7 +46,7 @@ describe('upstream Angular issue reproductions', () => { client.clear() }) - it('#9910: a template signal read does not prevent whenStable from seeing success', async () => { + it('should not prevent whenStable from seeing success when a template reads a signal (#9910)', async () => { @Component({ template: '{{ query.isSuccess() }}' }) class App { query = injectQuery(() => ({ @@ -65,7 +65,7 @@ describe('upstream Angular issue reproductions', () => { expect(fixture.nativeElement.textContent).toBe('true') }) - it('#10046: a class-field data alias is populated after whenStable', async () => { + it('should populate a class-field data alias after whenStable (#10046)', async () => { @Component({ template: '{{ data() }}' }) class App { query = injectQuery(() => ({ @@ -83,7 +83,7 @@ describe('upstream Angular issue reproductions', () => { }) it.each(['TestBed', 'Testing Library'] as const)( - '#9981: an isSuccess effect updates component state using %s', + 'should update component state from an isSuccess effect using %s (#9981)', async (runner) => { @Component({ template: '{{ value }}', @@ -113,7 +113,7 @@ describe('upstream Angular issue reproductions', () => { }, ) - it('#7488: taking a data alias does not read an unset required input', async () => { + it('should not read an unset required input when taking a data alias (#7488)', async () => { const optionsRead = vi.fn<() => void>() @Component({ template: '{{ data() }}' }) class App { @@ -136,7 +136,7 @@ describe('upstream Angular issue reproductions', () => { }) it.each(['constructor', 'ngOnInit', 'ngAfterContentInit'] as const)( - '#9020: mutate immediately exposes pending from %s', + 'should expose pending from %s immediately after mutate (#9020)', async (phase) => { let finish!: (value: string) => void const request = new Promise((resolve) => { @@ -170,7 +170,7 @@ describe('upstream Angular issue reproductions', () => { }, ) - it('#11176: whenStable waits for a just-triggered fire-and-forget mutation', async () => { + it('should wait in whenStable for a just-triggered fire-and-forget mutation (#11176)', async () => { const app = TestBed.inject(ApplicationRef) const mutation = TestBed.runInInjectionContext(() => injectMutation(() => ({ @@ -188,7 +188,7 @@ describe('upstream Angular issue reproductions', () => { }) it.each([false, true])( - '#11176: a newer mutation settling cannot release an older invocation (reset=%s)', + 'should not let a newer mutation settling release an older invocation (reset=%s) (#11176)', async (reset) => { let finish!: () => void const first = new Promise((resolve) => { @@ -218,7 +218,7 @@ describe('upstream Angular issue reproductions', () => { }, ) - it('#9735: saving an edit exposes optimistic data in the same turn and render', async () => { + it('should expose optimistic data in the same turn and render when saving an edit (#9735)', async () => { const snapshots: Array = [] @Component({ template: '@if (!editing()) { {{ query.data() }} }', @@ -255,7 +255,7 @@ describe('upstream Angular issue reproductions', () => { await fixture.whenStable() }) - it('#6567: changing to another cached key updates data immediately', () => { + it('should update data immediately when changing to another cached key (#6567)', () => { client.setQueryData(['6567', 'a'], 'A') client.setQueryData(['6567', 'b'], 'B') const key = signal('a') @@ -271,7 +271,7 @@ describe('upstream Angular issue reproductions', () => { expect(query.data()).toBe('B') }) - it('#6771: enabling a fresh cached query and immediately refetching settles', async () => { + it('should settle when enabling a fresh cached query and immediately refetching (#6771)', async () => { client.setQueryData(['6771'], 'cached') const enabled = signal(false) const query = TestBed.runInInjectionContext(() => diff --git a/packages/angular-query/src/__tests__/with-hydration.test.ts b/packages/angular-query/src/__tests__/with-hydration.test.ts index c5950d711d5..208b30c2900 100644 --- a/packages/angular-query/src/__tests__/with-hydration.test.ts +++ b/packages/angular-query/src/__tests__/with-hydration.test.ts @@ -37,7 +37,7 @@ describe('TransferState', () => { }) describe('TransferState hydration (client)', () => { - it('browser hydrates from default key', async () => { + it('should hydrate from the default key in the browser', async () => { const key = createKey() const sourceClient = new QueryClient() sourceClient.setQueryData(key, 'from-server') @@ -76,7 +76,7 @@ describe('TransferState', () => { ).toBeNull() }) - it('browser hydrates from custom key', async () => { + it('should hydrate from a custom key in the browser', async () => { const customKeyName = 'tanstack-test-custom-hydration' const customKey = makeStateKey(customKeyName) const key = createKey() @@ -118,7 +118,7 @@ describe('TransferState', () => { ).toBeNull() }) - it('browser does not re-fetch when hydrated state is fresh', async () => { + it('should not re-fetch in the browser when hydrated state is fresh', async () => { const key = createKey() const sourceClient = new QueryClient() sourceClient.setQueryData(key, 'cached') @@ -161,7 +161,7 @@ describe('TransferState', () => { expect(queryFnCalls).toBe(0) }) - it('withNoQueryHydration disables browser hydration', async () => { + it('should disable browser hydration with withNoQueryHydration', async () => { const key = createKey() const sourceClient = new QueryClient() sourceClient.setQueryData(key, 'from-server') @@ -223,7 +223,7 @@ describe('TransferState', () => { ) } - it('server serializes dehydrated queries on TransferState.toJson', async () => { + it('should serialize dehydrated queries on TransferState.toJson on the server', async () => { const key = createKey() const queryClient = new QueryClient() const injector = createQueryInjector(queryClient, 'server') @@ -246,7 +246,7 @@ describe('TransferState', () => { expect(stored!.queries[0]?.queryKey).toStrictEqual(key) }) - it('browser platform does not write server dehydration state', async () => { + it('should not write server dehydration state on the browser platform', async () => { const key = createKey() const queryClient = new QueryClient() const injector = createQueryInjector(queryClient, 'browser') @@ -268,7 +268,7 @@ describe('TransferState', () => { ).toBeNull() }) - it('withNoQueryHydration disables server dehydration', async () => { + it('should disable server dehydration with withNoQueryHydration', async () => { const key = createKey() const queryClient = new QueryClient() const injector = createQueryInjector( @@ -294,7 +294,7 @@ describe('TransferState', () => { ).toBeNull() }) - it('multiple query clients can use distinct hydration keys', async () => { + it('should allow multiple query clients to use distinct hydration keys', async () => { const keyA = createKey() const keyB = createKey() const clientA = new QueryClient() diff --git a/packages/angular-query/src/__tests__/zoneful-integration.test.ts b/packages/angular-query/src/__tests__/zoneful-integration.test.ts index 9d7c20224f0..ed0c6f3a3d0 100644 --- a/packages/angular-query/src/__tests__/zoneful-integration.test.ts +++ b/packages/angular-query/src/__tests__/zoneful-integration.test.ts @@ -40,7 +40,7 @@ describe('Zone.js notification integration', () => { TestBed.resetTestingModule() }) - it('keeps an injectQuery signal current after its subscription commits', () => { + it('should keep an injectQuery signal current after its subscription commits', () => { const key = ['zoneful-query'] const query = TestBed.runInInjectionContext(() => injectQuery(() => ({ @@ -56,7 +56,7 @@ describe('Zone.js notification integration', () => { expect(query.data()).toBe('updated') }) - it('keeps injectQueries current after its subscription commits', () => { + it('should keep injectQueries current after its subscription commits', () => { const key = ['zoneful-queries'] const queries = TestBed.runInInjectionContext(() => injectQueries(() => ({ @@ -71,7 +71,7 @@ describe('Zone.js notification integration', () => { expect(queries()[0].data()).toBe('updated') }) - it('makes committed query notifications visible inside mutation onMutate', async () => { + it('should make committed query notifications visible inside mutation onMutate', async () => { const key = ['zoneful-optimistic'] const query = TestBed.runInInjectionContext(() => injectQuery(() => ({ @@ -98,7 +98,7 @@ describe('Zone.js notification integration', () => { expect(seenInOnMutate).toStrictEqual(['optimistic']) }) - it('uses the latest options when restoration ends in the same Zone.js turn', async () => { + it('should use the latest options when restoration ends in the same Zone.js turn', async () => { const isRestoring = signal(true) const key = signal('old') const queriedKeys: Array = [] @@ -139,7 +139,7 @@ describe('Zone.js notification integration', () => { ).toBe(1) }) - it('completes dependent queries before application stability without manual effect flushing', async () => { + it('should complete dependent queries before application stability without manual effect flushing', async () => { @Component({ template: '{{ second.data() }}' }) class Page { first = injectQuery(() => ({ @@ -159,7 +159,7 @@ describe('Zone.js notification integration', () => { expect(fixture.componentInstance.second.data()).toBe('dependent data') }) - it('renders outside-zone query, multi-query and mutation notifications automatically', async () => { + it('should render outside-zone query, multi-query and mutation notifications automatically', async () => { @Component({ template: '{{ query.data() }} / {{ queries()[0].data() }} / {{ mutation.status() }}', diff --git a/packages/angular-query/src/utils/__test__/inject-external-store.test.ts b/packages/angular-query/src/utils/__test__/inject-external-store.test.ts index fe6e73d610f..82907161e6b 100644 --- a/packages/angular-query/src/utils/__test__/inject-external-store.test.ts +++ b/packages/angular-query/src/utils/__test__/inject-external-store.test.ts @@ -49,7 +49,7 @@ describe('injectExternalStore', () => { }) }) - it('reflects changes made during initialization after an early snapshot read', () => { + it('should reflect changes made during initialization after an early snapshot read', () => { const source = store(1) const fixture = host( () => injectExternalStore(() => source), @@ -65,7 +65,7 @@ describe('injectExternalStore', () => { }) it.each([false, true])( - 'reflects changes made by subscription setup (notifies: %s)', + 'should reflect changes made by subscription setup (notifies: %s)', (notifies) => { const source = store(1) const fixture = host(() => @@ -85,7 +85,7 @@ describe('injectExternalStore', () => { }, ) - it('preserves equal snapshots for consumers', () => { + it('should preserve equal snapshots for consumers', () => { const source = store(1) const fixture = host(() => injectExternalStore( @@ -109,7 +109,7 @@ describe('injectExternalStore', () => { expect(derived()).toBe(2) }) - it('tracks snapshot dependencies without reconnecting for selectors or incidental reads', () => { + it('should track snapshot dependencies without reconnecting for selectors or incidental reads', () => { const source = store(0) const multiplier = signal(10) const incidental = signal(0) @@ -134,7 +134,7 @@ describe('injectExternalStore', () => { expect(source.subscribe).toHaveBeenCalledTimes(1) }) - it('follows the current source and releases the previous source', () => { + it('should follow the current source and release the previous source', () => { const first = store(1) const second = store(10) const requested = signal(first) @@ -154,7 +154,7 @@ describe('injectExternalStore', () => { expect(value()).toBe(12) }) - it('releases observation while paused and catches up on resume', () => { + it('should release observation while paused and catch up on resume', () => { const source = store(1) const paused = signal(false) const fixture = host(() => @@ -175,7 +175,7 @@ describe('injectExternalStore', () => { expect(fixture.componentInstance.value()).toBe(3) }) - it('allows subscription setup and cleanup to read the result', () => { + it('should allow subscription setup and cleanup to read the result', () => { const source = store(1) const enabled = signal(true) const seen: Array = [] @@ -201,7 +201,7 @@ describe('injectExternalStore', () => { expect(seen).toStrictEqual([1, 1]) }) - it('keeps snapshot errors separate from subscription errors', () => { + it('should keep snapshot errors separate from subscription errors', () => { const source = store(1) const fixture = host(() => injectExternalStore(() => ({ @@ -216,7 +216,7 @@ describe('injectExternalStore', () => { expect(fixture.componentInstance.value()).toBe(2) }) - it('recovers from a snapshot error on the next store notification', () => { + it('should recover from a snapshot error on the next store notification', () => { const source = store(1) const fixture = host(() => injectExternalStore(() => ({ @@ -236,7 +236,7 @@ describe('injectExternalStore', () => { }) it.each([false, true])( - 'releases subscriptions on destruction (during setup: %s)', + 'should release subscriptions on destruction (during setup: %s)', (duringSetup) => { const source = store(1) const fixture = host(() => @@ -257,7 +257,7 @@ describe('injectExternalStore', () => { }, ) - it('renders required inputs and changes made in ngOnInit', () => { + it('should render required inputs and changes made in ngOnInit', () => { const source = store(1) @Component({ template: '{{ value() }}' }) class Example { diff --git a/packages/query-core/src/__tests__/cacheGc.test.tsx b/packages/query-core/src/__tests__/cacheGc.test.tsx index b2a87b92224..e85639d1196 100644 --- a/packages/query-core/src/__tests__/cacheGc.test.tsx +++ b/packages/query-core/src/__tests__/cacheGc.test.tsx @@ -19,7 +19,7 @@ describe('garbage collection after cache removal', () => { vi.useRealTimers() }) - it('clears an existing mutation timer on clear', () => { + it('should clear an existing mutation timer on clear', () => { const cache = client.getMutationCache() cache.build(client, {}) expect(vi.getTimerCount()).toBe(1) @@ -30,7 +30,7 @@ describe('garbage collection after cache removal', () => { expect(vi.getTimerCount()).toBe(0) }) - it('clears an existing mutation timer on remove', () => { + it('should clear an existing mutation timer on remove', () => { const cache = client.getMutationCache() const mutation = cache.build(client, {}) expect(vi.getTimerCount()).toBe(1) @@ -41,7 +41,7 @@ describe('garbage collection after cache removal', () => { expect(vi.getTimerCount()).toBe(0) }) - it('does not schedule mutation GC when an observer resets after clear', async () => { + it('should not schedule mutation GC when an observer resets after clear', async () => { const observer = new MutationObserver(client, { mutationFn: () => Promise.resolve('done'), }) @@ -54,7 +54,7 @@ describe('garbage collection after cache removal', () => { expect(vi.getTimerCount()).toBe(0) }) - it('keeps only the replacement query timer when a removed fetch settles', async () => { + it('should keep only the replacement query timer when a removed fetch settles', async () => { const queryKey = ['replacement'] const pending = client.query({ queryKey, @@ -74,7 +74,7 @@ describe('garbage collection after cache removal', () => { expect(client.getQueryCache().getAll()).toHaveLength(0) }) - it('does not schedule query GC when an observer unsubscribes after clear', async () => { + it('should not schedule query GC when an observer unsubscribes after clear', async () => { const queryKey = ['observed'] await client.query({ queryKey, queryFn: () => Promise.resolve('data') }) const observer = new QueryObserver(client, { @@ -90,7 +90,7 @@ describe('garbage collection after cache removal', () => { expect(vi.getTimerCount()).toBe(0) }) - it('clears a timer scheduled by an abort listener during removal', async () => { + it('should clear a timer scheduled by an abort listener during removal', async () => { const observer = new QueryObserver(client, { queryKey: ['aborted'], queryFn: ({ signal }) => diff --git a/packages/query-core/src/__tests__/queriesObserver.test.tsx b/packages/query-core/src/__tests__/queriesObserver.test.tsx index 680d5015a36..29cca768d51 100644 --- a/packages/query-core/src/__tests__/queriesObserver.test.tsx +++ b/packages/query-core/src/__tests__/queriesObserver.test.tsx @@ -19,7 +19,7 @@ describe('queriesObserver', () => { vi.useRealTimers() }) - it('keeps the current snapshot during an optimistic read for a different query list', () => { + it('should keep the current snapshot during an optimistic read for a different query list', () => { const first = { queryKey: createKey(), enabled: false, placeholderData: 1 } const second = { queryKey: createKey(), enabled: false, placeholderData: 2 } const third = { queryKey: createKey(), enabled: false, placeholderData: 3 } diff --git a/packages/query-devtools/src/__tests__/Devtools.test.tsx b/packages/query-devtools/src/__tests__/Devtools.test.tsx index 47bc02848a3..7837f6fe65a 100644 --- a/packages/query-devtools/src/__tests__/Devtools.test.tsx +++ b/packages/query-devtools/src/__tests__/Devtools.test.tsx @@ -202,7 +202,7 @@ describe('Devtools', () => { } } - it('keeps selected query details updating when its row is offscreen', async () => { + it('should keep selected query details updating when its row is offscreen', async () => { seedQueries() const rendered = renderDevtools( { initialIsOpen: true }, @@ -224,7 +224,7 @@ describe('Devtools', () => { expect(rendered.getByText('Query Details')).toBeVisible() }) - it('filters, clears, and restores queries after distant scrolling', async () => { + it('should filter, clear, and restore queries after distant scrolling', async () => { seedQueries() const rendered = renderDevtools({ initialIsOpen: true }) const viewport = getViewport(rendered.container, 'queries') @@ -322,7 +322,7 @@ describe('Devtools', () => { ).toHaveLength(0) }) - it('keeps query clicks aligned after a same-count sort change', () => { + it('should keep query clicks aligned after a same-count sort change', () => { seedQueries() const rendered = renderDevtools( { initialIsOpen: true }, @@ -341,7 +341,7 @@ describe('Devtools', () => { ).toBeVisible() }) - it('keeps mutation clicks aligned after a same-count sort change', () => { + it('should keep mutation clicks aligned after a same-count sort change', () => { for (let index = 0; index < 100; index++) { queryClient.getMutationCache().build(queryClient, { mutationKey: [`reorder-${index}`], @@ -362,7 +362,7 @@ describe('Devtools', () => { ).toHaveTextContent(key) }) - it('bounds mutation rows, preserves offscreen details, and filters from a distant offset', async () => { + it('should bound mutation rows, preserve offscreen details, and filter from a distant offset', async () => { const mutations = Array.from({ length: 2000 }, (_, index) => queryClient.getMutationCache().build(queryClient, { mutationKey: [ @@ -1403,7 +1403,7 @@ describe('Devtools', () => { }) describe('Data Explorer search', () => { - it('searches only query Data and resets search when the selection changes', async () => { + it('should search only query Data and reset search when the selection changes', async () => { queryClient.setQueryData(['search-first'], { nested: { name: 'first needle' }, }) @@ -1436,7 +1436,7 @@ describe('Devtools', () => { expect(dataContainer.querySelector('[data-search-match]')).toBeNull() }) - it('searches read-only mutation Data and resets search when the selection changes', async () => { + it('should search read-only mutation Data and reset search when the selection changes', async () => { const first = queryClient.getMutationCache().build(queryClient, { mutationKey: ['search-first'], mutationFn: () => diff --git a/packages/query-devtools/src/__tests__/Explorer.test.tsx b/packages/query-devtools/src/__tests__/Explorer.test.tsx index 3b1a4c3d340..f36c752d5a1 100644 --- a/packages/query-devtools/src/__tests__/Explorer.test.tsx +++ b/packages/query-devtools/src/__tests__/Explorer.test.tsx @@ -73,7 +73,7 @@ describe('Explorer', () => { } describe('nested search', () => { - it('bounds the number of native ranges for a repeated match', () => { + it('should bound the number of native ranges for a repeated match', () => { const rendered = renderSearchable({ label: 'Data', value: 'a'.repeat(2000), @@ -83,7 +83,7 @@ describe('Explorer', () => { expect(rendered.container).toHaveTextContent('a'.repeat(2000)) }) - it('shares the range limit across rows and resets it for each search', () => { + it('should share the range limit across rows and reset it for each search', () => { const [value, setValue] = createSignal({ first: 'a'.repeat(600), second: 'a'.repeat(600), @@ -108,7 +108,7 @@ describe('Explorer', () => { expect(highlightedText()).toHaveLength(0) }) - it('uses native ranges and replaces them when the search or data changes', () => { + it('should use native ranges and replace them when the search or data changes', () => { const highlights = new Map>() vi.stubGlobal('CSS', { highlights }) vi.stubGlobal('Highlight', Set) @@ -136,7 +136,7 @@ describe('Explorer', () => { expect(highlights.size).toBe(0) }) - it('keeps the native ranges of each explorer separate and cleans up on unmount', () => { + it('should keep the native ranges of each explorer separate and clean up on unmount', () => { const foreign = new Set() const highlights = new Map([['other-feature', foreign]]) vi.stubGlobal('CSS', { highlights }) @@ -170,7 +170,7 @@ describe('Explorer', () => { expect([...highlights]).toStrictEqual([['other-feature', foreign]]) }) - it('registers highlights in the document that contains the explorer', () => { + it('should register highlights in the document that contains the explorer', () => { const highlights = new Map>() vi.stubGlobal('CSS', { highlights: new Map() }) vi.stubGlobal('Highlight', Set) @@ -210,7 +210,7 @@ describe('Explorer', () => { frame.remove() }) - it('debounces nested label matches and leaves ordinary siblings visible', () => { + it('should debounce nested label matches and leave ordinary siblings visible', () => { const rendered = renderSearchable({ label: 'Data', value: { users: { profile: { firstName: 'Anna' } }, unrelated: 42 }, @@ -227,7 +227,7 @@ describe('Explorer', () => { expect(rendered.getByText('42')).toBeVisible() }) - it('matches nested primitive values with case-insensitive literal substrings', () => { + it('should match nested primitive values with case-insensitive literal substrings', () => { const rendered = renderSearchable({ label: 'Data', value: { @@ -250,7 +250,7 @@ describe('Explorer', () => { expect(highlightedText()).toContain('null') }) - it('highlights literal backslashes and quotes in string values', () => { + it('should highlight literal backslashes and quotes in string values', () => { const rendered = renderSearchable({ label: 'Data', value: { text: 'a\\b"c' }, @@ -259,7 +259,7 @@ describe('Explorer', () => { expect(highlightedText()).toContain('a\\b"c') }) - it('highlights original text when Unicode lowercasing changes its length', () => { + it('should highlight original text when Unicode lowercasing changes its length', () => { const rendered = renderSearchable({ label: 'Data', value: { material: '\ud83d\udccd \u0130pek' }, @@ -273,7 +273,7 @@ describe('Explorer', () => { expect(highlightedText()).toContain('\u0130') }) - it('reports no matches without matching the synthetic Data label', () => { + it('should report no matches without matching the synthetic Data label', () => { const rendered = renderSearchable({ label: 'Data', value: { count: 1 } }) searchData(rendered, 'Data') expect(rendered.getByRole('status')).toHaveTextContent('No matches') @@ -282,7 +282,7 @@ describe('Explorer', () => { expect(rendered.getByRole('status')).toHaveTextContent(/^$/) }) - it('reveals a matching container label without opening unrelated descendants', () => { + it('should reveal a matching container label without opening unrelated descendants', () => { const rendered = renderSearchable({ label: 'Data', value: { profile: { secret: 'hidden' } }, @@ -297,7 +297,7 @@ describe('Explorer', () => { expect(rendered.queryByText('secret:')).not.toBeInTheDocument() }) - it('restores manual expansion immediately on clear and Escape', () => { + it('should restore manual expansion immediately on clear and Escape', () => { const rendered = renderSearchable({ label: 'Data', defaultExpanded: ['Data'], @@ -320,7 +320,7 @@ describe('Explorer', () => { expect(highlightedText()).toHaveLength(0) }) - it('keeps manual expansion when clicking search-open branches', () => { + it('should keep manual expansion when clicking search-open branches', () => { const rendered = renderSearchable({ label: 'Data', defaultExpanded: ['Data', 'opened'], @@ -348,7 +348,7 @@ describe('Explorer', () => { ).toHaveAttribute('aria-expanded', 'true') }) - it('cancels a pending search on Escape', () => { + it('should cancel a pending search on Escape', () => { const rendered = renderSearchable({ label: 'Data', value: { nested: { target: 1 } }, @@ -364,7 +364,7 @@ describe('Explorer', () => { expect(rendered.getByLabelText('Search data')).toHaveValue('') }) - it('highlights the full editable input and edits original index 150 without changing manual pages', () => { + it('should highlight the full editable input and edit original index 150 without changing manual pages', () => { const value = Array.from({ length: 200 }, (_, index) => `value-${index}`) queryClient.setQueryData(['data'], value) const rendered = renderSearchable({ @@ -391,7 +391,7 @@ describe('Explorer', () => { expect(rendered.getByText('150:')).toBeVisible() }) - it('keeps property paths distinct when labels contain separators', () => { + it('should keep property paths distinct when labels contain separators', () => { const value = { 'a.b': { name: 'needle' }, a: { b: { name: 'needle' } } } queryClient.setQueryData(['data'], value) const rendered = renderSearchable({ @@ -410,7 +410,7 @@ describe('Explorer', () => { }) }) - it('opens only the first matching page and marks other pages with matches', () => { + it('should open only the first matching page and mark other pages with matches', () => { const rendered = renderSearchable({ label: 'Data', defaultExpanded: ['Data'], @@ -435,7 +435,7 @@ describe('Explorer', () => { expect(first).toHaveAttribute('aria-expanded', 'false') }) - it('updates search results when root data changes', () => { + it('should update search results when root data changes', () => { const [value, setValue] = createSignal({ nested: { text: 'old' } }) const rendered = renderSearchable({ label: 'Data', @@ -453,7 +453,7 @@ describe('Explorer', () => { expect(highlightedText()).toHaveLength(0) }) - it('clears the term when the selected root changes', () => { + it('should clear the term when the selected root changes', () => { const [key, setKey] = createSignal('first') const rendered = renderSearchable({ label: 'Data', @@ -468,7 +468,7 @@ describe('Explorer', () => { expect(highlightedText()).toHaveLength(0) }) - it('starts with the initial search and restores it when the selected root changes', () => { + it('should start with the initial search and restore it when the selected root changes', () => { const [key, setKey] = createSignal('first') const [initialSearch, setInitialSearch] = createSignal('Needle') const rendered = renderSearchable({ @@ -492,7 +492,7 @@ describe('Explorer', () => { expect(highlightedText()).toStrictEqual(['a']) }) - it('searches Map and Set entries and keeps distinct object keys', () => { + it('should search Map and Set entries and keep distinct object keys', () => { const first = { toString() { throw new Error('Do not convert keys') @@ -531,7 +531,7 @@ describe('Explorer', () => { }, { kind: 'Set', populated: "new Set(['needle'])", empty: 'new Set()' }, ])( - 'renders cross-realm $kind labels and empty values', + 'should render cross-realm $kind labels and empty values', ({ kind, populated, empty }) => { const collection: unknown = runInNewContext(populated) const [value, setValue] = createSignal({ collection }) @@ -570,7 +570,7 @@ describe('Explorer', () => { Array.from(Set.prototype.values.call(value)), }, ])( - 'edits and deletes cross-realm $kind entries', + 'should edit and delete cross-realm $kind entries', ({ expression, label, values }) => { const initial: unknown = runInNewContext(expression) const [value, setValue] = createSignal(initial) @@ -610,7 +610,7 @@ describe('Explorer', () => { }, ) - it('edits and deletes entries through a foreign object ancestor with a getter', () => { + it('should edit and delete entries through a foreign object ancestor with a getter', () => { const initial: unknown = runInNewContext( "({ nested: new Map([['entry', 'needle'], ['other', 'kept']]), sibling: 'kept', get unread() { throw new Error('Do not read') } })", ) @@ -681,7 +681,7 @@ describe('Explorer', () => { ), ), }, - ])('shows $kind fields as read-only', ({ create }) => { + ])('should show $kind fields as read-only', ({ create }) => { const value = create() queryClient.setQueryData(['data'], value) const rendered = renderSearchable({ @@ -703,7 +703,7 @@ describe('Explorer', () => { expect(queryClient.getQueryData(['data'])).toBe(value) }) - it('edits Map values through original non-string keys during search', () => { + it('should edit Map values through original non-string keys during search', () => { const key = {} const value = new Map([ [key, { name: 'needle' }], @@ -733,7 +733,7 @@ describe('Explorer', () => { ) }) - it('stops cycles and searches shared values under each original path', () => { + it('should stop cycles and search shared values under each original path', () => { const shared = { text: 'needle' } const value: { left: typeof shared @@ -749,7 +749,7 @@ describe('Explorer', () => { expect(rendered.getByText('[Circular]')).toBeVisible() }) - it('does not read accessors, consume generators, or serialize opaque objects during search', () => { + it('should not read accessors, consume generators, or serialize opaque objects during search', () => { const getter = vi.fn<() => never>(() => { throw new Error('Do not read') }) diff --git a/packages/query-devtools/src/__tests__/VirtualList.test.tsx b/packages/query-devtools/src/__tests__/VirtualList.test.tsx index 36ceafd7b21..38518c49062 100644 --- a/packages/query-devtools/src/__tests__/VirtualList.test.tsx +++ b/packages/query-devtools/src/__tests__/VirtualList.test.tsx @@ -82,7 +82,7 @@ describe('VirtualList', () => { return { ...rendered, items, setItems, onClick, viewport } } - it('bounds mounted rows and scrolls to distant items in both directions', () => { + it('should bound mounted rows and scroll to distant items in both directions', () => { const list = renderList() expect(list.getAllByRole('button').length).toBeLessThan(100) expect(list.getByRole('button', { name: 'Item 0' })).toBeVisible() @@ -101,7 +101,7 @@ describe('VirtualList', () => { ).not.toBeInTheDocument() }) - it('keeps click identity after a same-count reorder at a distant offset', () => { + it('should keep click identity after a same-count reorder at a distant offset', () => { const list = renderList() list.viewport.scrollTo({ top: 28000 }) list.setItems((items) => [...items].reverse()) @@ -119,7 +119,7 @@ describe('VirtualList', () => { expect(list.getByRole('button', { name: 'Item 0' })).toBeVisible() }) - it('uses replacement objects for reused keys and new keys at the same index', () => { + it('should use replacement objects for reused keys and new keys at the same index', () => { const list = renderList() list.viewport.scrollTo({ top: 28000 }) const button = list.getAllByRole('button')[5] @@ -150,7 +150,7 @@ describe('VirtualList', () => { ).not.toBeInTheDocument() }) - it('measures a resized row after its index changes', async () => { + it('should measure a resized row after its index changes', async () => { const list = renderList() const button = list.getByRole('button', { name: 'Item 0' }) list.setItems((items) => { @@ -172,7 +172,7 @@ describe('VirtualList', () => { expect(list.getByRole('button', { name: 'Item 1999' })).toBeVisible() }) - it('keeps a usable range after removal, an empty list, and repopulation', () => { + it('should keep a usable range after removal, an empty list, and repopulation', () => { const list = renderList() list.viewport.scrollTo({ top: list.viewport.scrollHeight }) const remaining = list.items().slice(0, 2) diff --git a/packages/query-devtools/src/__tests__/explorerSearch.test.ts b/packages/query-devtools/src/__tests__/explorerSearch.test.ts index d503ce9a5c0..eb9f37e5274 100644 --- a/packages/query-devtools/src/__tests__/explorerSearch.test.ts +++ b/packages/query-devtools/src/__tests__/explorerSearch.test.ts @@ -15,7 +15,7 @@ describe('explorer search', () => { label: 'name', }, ])( - 'searches cross-realm collections: $expression', + 'should search cross-realm collections: $expression', ({ expression, label }) => { const value: unknown = runInNewContext(expression) expect(searchExplorer(value, 'needle').hasMatch).toBe(true) @@ -23,7 +23,7 @@ describe('explorer search', () => { }, ) - it('does not read collection tag accessors', () => { + it('should not read collection tag accessors', () => { const read = vi.fn<() => never>(() => { throw new Error('Do not read') }) @@ -33,12 +33,12 @@ describe('explorer search', () => { expect(read).not.toHaveBeenCalled() }) - it('searches ordinary data when a collection tag has no native brand', () => { + it('should search ordinary data when a collection tag has no native brand', () => { const value = { name: 'needle', [Symbol.toStringTag]: 'Map' } expect(searchExplorer(value, 'needle').hasMatch).toBe(true) }) - it('finds the native brand behind an overridden collection tag', () => { + it('should find the native brand behind an overridden collection tag', () => { const value: unknown = runInNewContext( "Object.defineProperty(new Map([['name', 'needle']]), Symbol.toStringTag, {value: 'Set'})", ) @@ -46,7 +46,7 @@ describe('explorer search', () => { expect(searchEntries(value)?.[0]?.label).toBe('name') }) - it('treats proxy collections and throwing introspection as opaque', () => { + it('should treat proxy collections and throwing introspection as opaque', () => { for (const collection of [ new Map([['name', 'needle']]), new Set(['needle']), @@ -64,7 +64,7 @@ describe('explorer search', () => { expect(searchExplorer(value, 'needle').hasMatch).toBe(false) }) - it('searches own class data fields without invoking custom code', () => { + it('should search own class data fields without invoking custom code', () => { const read = vi.fn<() => never>(() => { throw new Error('Do not read') }) @@ -87,7 +87,7 @@ describe('explorer search', () => { it.each([ { kind: 'Map', value: new Map([['entry', 'needle']]), key: 'entry' }, { kind: 'Set', value: new Set(['needle']), key: '0' }, - ])('searches a $kind with a null prototype', ({ value, key }) => { + ])('should search a $kind with a null prototype', ({ value, key }) => { Object.setPrototypeOf(value, null) expect(searchEntries(value)).toStrictEqual([ { key, label: key, value: 'needle' }, @@ -95,7 +95,7 @@ describe('explorer search', () => { expect(searchExplorer(value, 'needle').children.get(key)?.value).toBe(true) }) - it('keeps typed arrays and boxed strings opaque', () => { + it('should keep typed arrays and boxed strings opaque', () => { expect(searchEntries(new Uint8Array(100_000))).toBeUndefined() expect(searchEntries(Object('needle'))).toBeUndefined() const value: unknown = runInNewContext("new String('needle')") @@ -111,7 +111,7 @@ describe('explorer search', () => { expect(searchEntries(value)).toBeUndefined() }) - it('bounds deeply nested searches and keeps nearby matches', () => { + it('should bound deeply nested searches and keep nearby matches', () => { let value: unknown = 'needle' for (let depth = 0; depth < 10_000; depth++) value = { next: value } expect( @@ -123,12 +123,15 @@ describe('explorer search', () => { it.each([ { depth: 500, matches: true }, { depth: 501, matches: false }, - ])('bounds matching entries at object depth $depth', ({ depth, matches }) => { - let value: unknown = { name: 'needle' } - for (let index = 0; index < depth; index++) value = { next: value } - expect(searchExplorer(value, 'needle').hasMatch).toBe(matches) - expect(createSearchText(value).includes('needle')).toBe(matches) - }) + ])( + 'should bound matching entries at object depth $depth', + ({ depth, matches }) => { + let value: unknown = { name: 'needle' } + for (let index = 0; index < depth; index++) value = { next: value } + expect(searchExplorer(value, 'needle').hasMatch).toBe(matches) + expect(createSearchText(value).includes('needle')).toBe(matches) + }, + ) describe('createSearchText', () => { const matches = (value: unknown, term: string) => @@ -150,11 +153,11 @@ describe('explorer search', () => { { value: new Uint8Array([1]), term: '1' }, { value: { ab: 'cd' }, term: 'bc' }, { value: ['ab', 'cd'], term: 'bc' }, - ])('agrees with searchExplorer for $term', ({ value, term }) => { + ])('should agree with searchExplorer for $term', ({ value, term }) => { expect(matches(value, term)).toBe(searchExplorer(value, term).hasMatch) }) - it('handles circular data', () => { + it('should handle circular data', () => { const value: Record = { name: 'other' } value.self = value expect(matches(value, 'needle')).toBe(false) @@ -162,7 +165,7 @@ describe('explorer search', () => { expect(matches(value, 'needle')).toBe(true) }) - it('matches accessor labels without evaluating getters', () => { + it('should match accessor labels without evaluating getters', () => { const read = vi.fn<() => string>(() => 'needle') const value = {} Object.defineProperty(value, 'getter', { get: read, enumerable: true }) @@ -171,14 +174,14 @@ describe('explorer search', () => { expect(read).not.toHaveBeenCalled() }) - it('bounds deeply nested searches', () => { + it('should bound deeply nested searches', () => { let value: unknown = 'needle' for (let depth = 0; depth < 10_000; depth++) value = { next: value } expect(matches(value, 'needle')).toBe(false) expect(matches({ nearby: 'needle', deep: value }, 'needle')).toBe(true) }) - it('searches shared data once', () => { + it('should search shared data once', () => { let value: unknown = { name: 'needle' } for (let depth = 0; depth < 40; depth++) { value = { left: value, right: value } @@ -186,7 +189,7 @@ describe('explorer search', () => { expect(createSearchText(value).split('needle')).toHaveLength(2) }) - it('searches shared data at its shallowest depth', () => { + it('should search shared data at its shallowest depth', () => { const shared = { name: 'needle' } let deep: unknown = shared for (let depth = 0; depth < 600; depth++) deep = { next: deep } diff --git a/packages/query-devtools/src/__tests__/utils.test.ts b/packages/query-devtools/src/__tests__/utils.test.ts index 7918d79c01d..2c23829720f 100644 --- a/packages/query-devtools/src/__tests__/utils.test.ts +++ b/packages/query-devtools/src/__tests__/utils.test.ts @@ -58,7 +58,7 @@ describe('Utils tests', () => { ), }, ])('$realm object edits', ({ createDate, createData, createAccessor }) => { - it('preserves Date values when editing or deleting an own field', () => { + it('should preserve Date values when editing or deleting an own field', () => { const value = createDate() expect(updateNestedDataByPath(value, ['text'], 'edited')).toBe(value) expect(deleteNestedDataByPath(value, ['text'])).toBe(value) @@ -68,7 +68,7 @@ describe('Utils tests', () => { ) }) - it('edits and deletes data fields without reading sibling getters', () => { + it('should edit and delete data fields without reading sibling getters', () => { const value = createData() const edited = updateNestedDataByPath(value, ['nested', 'text'], 'edited') expect(edited.nested.text).toBe('edited') @@ -87,7 +87,7 @@ describe('Utils tests', () => { ) }) - it('does not evaluate accessors on the edited path', () => { + it('should not evaluate accessors on the edited path', () => { const value = createAccessor() expect(updateNestedDataByPath(value, ['unread', 'text'], 'edited')).toBe( value, diff --git a/packages/react-query/src/__tests__/placeholderData.test.ts b/packages/react-query/src/__tests__/placeholderData.test.ts index 17b5e7a4d89..4473d44f3ed 100644 --- a/packages/react-query/src/__tests__/placeholderData.test.ts +++ b/packages/react-query/src/__tests__/placeholderData.test.ts @@ -65,7 +65,7 @@ describe('placeholder updates', () => { ], ['useQuery with a throwing selector', useQuery, () => stable, selectError], ] as const)( - '%s settles after a parent render', + 'should settle after a parent render (%s)', async (_name, useResult, placeholder, select) => { const key = createKey() let renders = 0 @@ -98,7 +98,7 @@ describe('placeholder updates', () => { }, ) - it('shows fetched data after the selection of a computed placeholder throws', async () => { + it('should show fetched data after the selection of a computed placeholder throws', async () => { const queryKey = createKey() const placeholderData = () => ({ value: 0 }) const select = ({ value }: { value: number }) => { diff --git a/packages/vue-query-devtools/src/__tests__/client.test.ts b/packages/vue-query-devtools/src/__tests__/client.test.ts index 8b4e5b038df..4580d9c812c 100644 --- a/packages/vue-query-devtools/src/__tests__/client.test.ts +++ b/packages/vue-query-devtools/src/__tests__/client.test.ts @@ -44,7 +44,7 @@ describe.each([ vi.clearAllMocks() }) - it('switches explicit clients without remounting or requiring a provider', async () => { + it('should switch explicit clients without remounting or requiring a provider', async () => { const first = new QueryClient() const second = new QueryClient() const client = shallowRef(first) @@ -61,7 +61,7 @@ describe.each([ expect(unmount).not.toHaveBeenCalled() }) - it('returns to the initial context client after an override is removed', async () => { + it('should return to the initial context client after an override is removed', async () => { const contextClient = new QueryClient() const override = new QueryClient() const client = shallowRef()