refactor(di): minor cleanup
This commit is contained in:
parent
6514b8ced0
commit
f9963d3d21
|
@ -643,9 +643,7 @@ function _extractToken(typeOrFunc, metadata /*any[] | any*/, params: any[][]): D
|
|||
|
||||
if (!isArray(metadata)) {
|
||||
if (metadata instanceof InjectMetadata) {
|
||||
var metaArrayWrapper = ListWrapper.createFixedSize(1);
|
||||
metaArrayWrapper[0] = metadata;
|
||||
metadata = metaArrayWrapper;
|
||||
return _createDependency(metadata.token, optional, null, null, depProps);
|
||||
} else {
|
||||
return _createDependency(metadata, optional, null, null, depProps);
|
||||
}
|
||||
|
|
|
@ -646,16 +646,16 @@ export function main() {
|
|||
expect(provider.resolvedFactories[0].dependencies[0].properties)
|
||||
.toEqual([new CustomDependencyMetadata()]);
|
||||
});
|
||||
});
|
||||
|
||||
it('should allow declaring dependencies with flat arrays', () => {
|
||||
var resolved =
|
||||
Injector.resolve([bind('token').toFactory(e => e, [new InjectMetadata("dep")])]);
|
||||
var nestedResolved =
|
||||
Injector.resolve([bind('token').toFactory(e => e, [[new InjectMetadata("dep")]])]);
|
||||
var resolved = Injector.resolve(
|
||||
[provide('token', {useFactory: e => e, deps: [new InjectMetadata("dep")]})]);
|
||||
var nestedResolved = Injector.resolve(
|
||||
[provide('token', {useFactory: e => e, deps: [[new InjectMetadata("dep")]]})]);
|
||||
expect(resolved[0].resolvedFactories[0].dependencies[0].key.token)
|
||||
.toEqual(nestedResolved[0].resolvedFactories[0].dependencies[0].key.token);
|
||||
});
|
||||
});
|
||||
|
||||
describe("displayName", () => {
|
||||
it("should work", () => {
|
||||
|
|
Loading…
Reference in New Issue