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 no depencies
  • Loading branch information
thiagomini committed Jul 11, 2022
1 parent b0d735d commit a2f4b34
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/core/test/injector/instance-wrapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ describe('InstanceWrapper', () => {
it('should alter the instance wrapper metatype and inject attributes with the given values', () => {
const wrapper = new InstanceWrapper();

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

wrapper.mergeWith({
Expand All @@ -481,6 +481,21 @@ describe('InstanceWrapper', () => {
expect(wrapper.inject).to.be.eq(injectedDependencies);
});
});

describe('and it has no injected dependencies', () => {
it('should alter the instance wrapper metatype with the given values', () => {
const wrapper = new InstanceWrapper();
const factory = (_dependency1: any, _dependency2: any) => {};

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

expect(wrapper.metatype).to.be.eql(factory);
expect(wrapper.inject).to.be.eql([]);
});
});
});
});
});

0 comments on commit a2f4b34

Please sign in to comment.