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