test(angular-query/injectIsRestoring): add tests for 'injectIsRestoring' and 'provideIsRestoring'#10217
test(angular-query/injectIsRestoring): add tests for 'injectIsRestoring' and 'provideIsRestoring'#10217sukvvon wants to merge 2 commits intoTanStack:mainfrom
Conversation
…ng' and 'provideIsRestoring'
|
📝 WalkthroughWalkthroughA new test file is added to verify the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
View your CI Pipeline Execution ↗ for commit 23570d4
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/angular-query-experimental/src/__tests__/inject-is-restoring.test.ts (1)
17-22: Consider extracting repeated TestBed provider setup.The module setup is duplicated across three tests. A small helper would reduce repetition and make future updates safer.
♻️ Example refactor
describe('injectIsRestoring', () => { let queryClient: QueryClient + + const baseProviders = (client: QueryClient) => [ + provideZonelessChangeDetection(), + provideTanStackQuery(client), + ] test('returns false by default when provideIsRestoring is not used', () => { queryClient = new QueryClient() TestBed.configureTestingModule({ - providers: [ - provideZonelessChangeDetection(), - provideTanStackQuery(queryClient), - ], + providers: baseProviders(queryClient), }) }) test('returns provided signal value when provideIsRestoring is used', () => { queryClient = new QueryClient() const restoringSignal = signal(true) TestBed.configureTestingModule({ - providers: [ - provideZonelessChangeDetection(), - provideTanStackQuery(queryClient), - provideIsRestoring(restoringSignal.asReadonly()), - ], + providers: [ + ...baseProviders(queryClient), + provideIsRestoring(restoringSignal.asReadonly()), + ], }) }) test('can be used outside injection context when passing an injector', () => { queryClient = new QueryClient() TestBed.configureTestingModule({ - providers: [ - provideZonelessChangeDetection(), - provideTanStackQuery(queryClient), - ], + providers: baseProviders(queryClient), }) }) })Also applies to: 35-41, 53-58
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/angular-query-experimental/src/__tests__/inject-is-restoring.test.ts` around lines 17 - 22, The TestBed provider setup is duplicated in multiple tests; extract a helper function (e.g., setupTestProviders or configureTestBedWithQuery) that calls TestBed.configureTestingModule with provideZonelessChangeDetection() and provideTanStackQuery(queryClient) and then call that helper from each test, replacing the inline TestBed.configureTestingModule blocks to remove repetition and centralize future changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@packages/angular-query-experimental/src/__tests__/inject-is-restoring.test.ts`:
- Around line 17-22: The TestBed provider setup is duplicated in multiple tests;
extract a helper function (e.g., setupTestProviders or
configureTestBedWithQuery) that calls TestBed.configureTestingModule with
provideZonelessChangeDetection() and provideTanStackQuery(queryClient) and then
call that helper from each test, replacing the inline
TestBed.configureTestingModule blocks to remove repetition and centralize future
changes.
🎯 Changes
Add tests for
injectIsRestoringandprovideIsRestoringinangular-query-experimental.falsewhenprovideIsRestoringis not usedprovideIsRestoringis usedinjectoroptionNG0203error outside injection contextThis improves
inject-is-restoring.tscoverage from 83.33% to 100%.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
injectIsRestoringfunctionality, including default behavior, signal provision, injector context handling, and error scenarios in the angular-query-experimental package.