refactor(test_injector): Provide separate methods for creating test injector with and without runtime compiler.
BREAKING CHANGE: `createTestInjector()` does not more include the runtime compiler. Use `createTestInjectorWithRuntimeCompiler()` instead. Closes #5583
This commit is contained in:
@ -57,6 +57,7 @@ import {COMPILER_PROVIDERS} from 'angular2/src/compiler/compiler';
|
||||
import {DomRenderer_} from "angular2/src/platform/dom/dom_renderer";
|
||||
import {DynamicComponentLoader_} from "angular2/src/core/linker/dynamic_component_loader";
|
||||
import {AppViewManager_} from "angular2/src/core/linker/view_manager";
|
||||
import {APPLICATION_COMMON_PROVIDERS} from 'angular2/src/core/application_common_providers';
|
||||
|
||||
/**
|
||||
* Returns the root injector providers.
|
||||
@ -87,7 +88,7 @@ function _getAppBindings() {
|
||||
}
|
||||
|
||||
return [
|
||||
COMPILER_PROVIDERS,
|
||||
APPLICATION_COMMON_PROVIDERS,
|
||||
provide(ChangeDetectorGenConfig, {useValue: new ChangeDetectorGenConfig(true, false, true)}),
|
||||
provide(DOCUMENT, {useValue: appDoc}),
|
||||
provide(DomRenderer, {useClass: DomRenderer_}),
|
||||
@ -120,11 +121,23 @@ function _getAppBindings() {
|
||||
];
|
||||
}
|
||||
|
||||
function _runtimeCompilerBindings() {
|
||||
return [
|
||||
provide(XHR, {useClass: DOM.getXHR()}),
|
||||
COMPILER_PROVIDERS,
|
||||
];
|
||||
}
|
||||
|
||||
export function createTestInjector(providers: Array<Type | Provider | any[]>): Injector {
|
||||
var rootInjector = Injector.resolveAndCreate(_getRootProviders());
|
||||
return rootInjector.resolveAndCreateChild(ListWrapper.concat(_getAppBindings(), providers));
|
||||
}
|
||||
|
||||
export function createTestInjectorWithRuntimeCompiler(
|
||||
providers: Array<Type | Provider | any[]>): Injector {
|
||||
return createTestInjector(ListWrapper.concat(_runtimeCompilerBindings(), providers));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows injecting dependencies in `beforeEach()` and `it()`. When using with the
|
||||
* `angular2/testing` library, the test function will be run within a zone and will
|
||||
|
Reference in New Issue
Block a user