generated from Soontao/ts-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
wrapper & disable wrapper
Theo Sun edited this page Oct 28, 2020
·
2 revisions
framework will return a wrapped
proxy object of target class
it('should support inject methods of wrapped object', async () => {
class A {
async calculate(@inject("v") v?: number) {
return v + 1;
}
}
class B {
async run(@inject(A) a?: InjectWrappedInstance<A>) {
// object 'a' has been wrapped with container
return await a.calculate();
}
}
const c = InjectContainer.New();
c.registerInstance("v", 999);
const b = await c.getWrappedInstance(B);
expect(await b.run()).toBe(1000);