reactant-di
Version:
A dependency injection lib for Reactant
32 lines (26 loc) • 788 B
text/typescript
import { injectable, createContainer, inject, forwardRef } from '..';
test('forwardRef', () => {
class Foo {}
class FooBar {}
class Bar {
constructor( public foo: Foo) {}
}
const ServiceIdentifiers = new Map();
const container = createContainer({
ServiceIdentifiers,
modules: [
FooBar,
{ provide: 'string', useValue: 'test' },
{ provide: 'number', useValue: 42 },
{ provide: 'symbol', useValue: Symbol('test') },
{ provide: 'null', useValue: null },
{ provide: 'undefined', useValue: undefined },
],
});
const bar = container.get(Bar);
expect(bar.foo instanceof Foo).toBeTruthy();
expect(container.isBound(FooBar)).toBeTruthy();
});