-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Expand file tree
/
Copy pathprovide-tanstack-query.test.ts
More file actions
41 lines (35 loc) · 1.23 KB
/
Copy pathprovide-tanstack-query.test.ts
File metadata and controls
41 lines (35 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { TestBed } from '@angular/core/testing'
import { describe, expect, test } from 'vitest'
import {
InjectionToken,
provideExperimentalZonelessChangeDetection,
} from '@angular/core'
import { QueryClient } from '@tanstack/query-core'
import { provideTanStackQuery } from '../providers'
describe('provideTanStackQuery', () => {
test('should provide a QueryClient instance directly', () => {
const queryClient = new QueryClient()
TestBed.configureTestingModule({
providers: [
provideExperimentalZonelessChangeDetection(),
provideTanStackQuery(queryClient),
],
})
const providedQueryClient = TestBed.inject(QueryClient)
expect(providedQueryClient).toBe(queryClient)
})
test('should provide a QueryClient instance using an InjectionToken', () => {
const queryClient = new QueryClient()
const CUSTOM_QUERY_CLIENT = new InjectionToken<QueryClient>('', {
factory: () => queryClient,
})
TestBed.configureTestingModule({
providers: [
provideExperimentalZonelessChangeDetection(),
provideTanStackQuery(CUSTOM_QUERY_CLIENT),
],
})
const providedQueryClient = TestBed.inject(QueryClient)
expect(providedQueryClient).toBe(queryClient)
})
})