Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

create-injection-token.test.ts

30 lines926 Bytes

1/**
2 * The code in this file is adapted from NG Extension Platform at https://ngxtension.netlify.app.
3 *
4 * Original Author: Chau Tran
5 *
6 * NG Extension Platform is an open-source project licensed under the MIT license.
7 *
8 * For more information about the original code, see
9 * https://github.com/nartc/ngxtension-platform
10 */
11​
12import { TestBed } from '@angular/core/testing'
13import { createNoopInjectionToken } from './create-injection-token'
14​
15describe(createNoopInjectionToken.name, () => {
16 describe('given an injection token', () => {
17 const [injectFn, provideFn] = createNoopInjectionToken<number, true>(
18 'noop',
19 { multi: true },
20 )
21 it('then work properly', () => {
22 TestBed.configureTestingModule({
23 providers: [provideFn(1), provideFn(() => 2)],
24 }).runInInjectionContext(() => {
25 const values = injectFn()
26 expect(values).toEqual([1, 2])
27 })
28 })
29 })
30})