Open History to see the last commit
1import { TestBed } from '@angular/core/testing'
2import { describe, expect, test } from 'vitest'
3import { InjectionToken, provideZonelessChangeDetection } from '@angular/core'
4import { QueryClient } from '@tanstack/query-core'
5import { provideTanStackQuery } from '../providers'
6β
7describe('provideTanStackQuery', () => {
8 test('should provide a QueryClient instance directly', () => {
9 const queryClient = new QueryClient()
10β
11 TestBed.configureTestingModule({
12 providers: [
13 provideZonelessChangeDetection(),
14 provideTanStackQuery(queryClient),
15 ],
16 })
17β
18 const providedQueryClient = TestBed.inject(QueryClient)
19 expect(providedQueryClient).toBe(queryClient)
20 })
21β
22 test('should provide a QueryClient instance using an InjectionToken', () => {
23 const queryClient = new QueryClient()
24 const CUSTOM_QUERY_CLIENT = new InjectionToken<QueryClient>('', {
25 factory: () => queryClient,
26 })
27β
28 TestBed.configureTestingModule({
29 providers: [
30 provideZonelessChangeDetection(),
31 provideTanStackQuery(CUSTOM_QUERY_CLIENT),
32 ],
33 })
34β
35 const providedQueryClient = TestBed.inject(QueryClient)
36 expect(providedQueryClient).toBe(queryClient)
37 })
38})