Skip to content

Commit b0d735d

Browse files
committed
test(core): add instance wrapper test
ensure mergeWith handles FactoryProviders with injected dependencies
1 parent 7696f43 commit b0d735d

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

packages/core/test/injector/instance-wrapper.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,5 +462,25 @@ describe('InstanceWrapper', () => {
462462
expect(wrapper.metatype).to.be.eql(TestClass);
463463
});
464464
});
465+
466+
describe('when provider is a FactoryProvider', () => {
467+
describe('and it has injected dependencies', () => {
468+
it('should alter the instance wrapper metatype and inject attributes with the given values', () => {
469+
const wrapper = new InstanceWrapper();
470+
471+
const factory = (_dependency1, _dependency2) => {};
472+
const injectedDependencies = ['dependency1', 'dependency2'];
473+
474+
wrapper.mergeWith({
475+
provide: 'token',
476+
useFactory: factory,
477+
inject: injectedDependencies,
478+
});
479+
480+
expect(wrapper.metatype).to.be.eql(factory);
481+
expect(wrapper.inject).to.be.eq(injectedDependencies);
482+
});
483+
});
484+
});
465485
});
466486
});

0 commit comments

Comments
 (0)