Skip to content

Commit

Permalink
test(core): add instance wrapper test
Browse files Browse the repository at this point in the history
ensure mergeWith handles FactoryProviders with injected dependencies
  • Loading branch information
thiagomini committed Jul 11, 2022
1 parent 7696f43 commit b0d735d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/core/test/injector/instance-wrapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,5 +462,25 @@ describe('InstanceWrapper', () => {
expect(wrapper.metatype).to.be.eql(TestClass);
});
});

describe('when provider is a FactoryProvider', () => {
describe('and it has injected dependencies', () => {
it('should alter the instance wrapper metatype and inject attributes with the given values', () => {
const wrapper = new InstanceWrapper();

const factory = (_dependency1, _dependency2) => {};
const injectedDependencies = ['dependency1', 'dependency2'];

wrapper.mergeWith({
provide: 'token',
useFactory: factory,
inject: injectedDependencies,
});

expect(wrapper.metatype).to.be.eql(factory);
expect(wrapper.inject).to.be.eq(injectedDependencies);
});
});
});
});
});

0 comments on commit b0d735d

Please sign in to comment.