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 (!isArray(metadata)) {
|
||||||
if (metadata instanceof InjectMetadata) {
|
if (metadata instanceof InjectMetadata) {
|
||||||
var metaArrayWrapper = ListWrapper.createFixedSize(1);
|
return _createDependency(metadata.token, optional, null, null, depProps);
|
||||||
metaArrayWrapper[0] = metadata;
|
|
||||||
metadata = metaArrayWrapper;
|
|
||||||
} else {
|
} else {
|
||||||
return _createDependency(metadata, optional, null, null, depProps);
|
return _createDependency(metadata, optional, null, null, depProps);
|
||||||
}
|
}
|
||||||
|
|
|
@ -646,15 +646,15 @@ export function main() {
|
||||||
expect(provider.resolvedFactories[0].dependencies[0].properties)
|
expect(provider.resolvedFactories[0].dependencies[0].properties)
|
||||||
.toEqual([new CustomDependencyMetadata()]);
|
.toEqual([new CustomDependencyMetadata()]);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('should allow declaring dependencies with flat arrays', () => {
|
it('should allow declaring dependencies with flat arrays', () => {
|
||||||
var resolved =
|
var resolved = Injector.resolve(
|
||||||
Injector.resolve([bind('token').toFactory(e => e, [new InjectMetadata("dep")])]);
|
[provide('token', {useFactory: e => e, deps: [new InjectMetadata("dep")]})]);
|
||||||
var nestedResolved =
|
var nestedResolved = Injector.resolve(
|
||||||
Injector.resolve([bind('token').toFactory(e => e, [[new InjectMetadata("dep")]])]);
|
[provide('token', {useFactory: e => e, deps: [[new InjectMetadata("dep")]]})]);
|
||||||
expect(resolved[0].resolvedFactories[0].dependencies[0].key.token)
|
expect(resolved[0].resolvedFactories[0].dependencies[0].key.token)
|
||||||
.toEqual(nestedResolved[0].resolvedFactories[0].dependencies[0].key.token);
|
.toEqual(nestedResolved[0].resolvedFactories[0].dependencies[0].key.token);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("displayName", () => {
|
describe("displayName", () => {
|
||||||
|
|
Loading…
Reference in New Issue