feat(upgrade): provide unit test helpers for wiring up injectors (#16848)
Adds two new helper functions that can be used when unit testing Angular services that depend upon upgraded AngularJS services, or vice versa. The functions return a module (AngularJS or NgModule) that is configured to wire up the Angular and AngularJS injectors without the need to actually bootstrap a full hybrid application. This makes it simpler and faster to unit test services. PR Close #16848
This commit is contained in:

committed by
Kara Erickson

parent
5e53956c2b
commit
3fb78aaacc
@ -234,6 +234,7 @@ let angular: {
|
||||
(e: string | Element | Document | IAugmentedJQuery): IAugmentedJQuery;
|
||||
cleanData: (nodes: Node[] | NodeList) => void;
|
||||
},
|
||||
injector: (modules: Array<string|IInjectable>, strictDi?: boolean) => IInjectorService,
|
||||
version: {major: number},
|
||||
resumeBootstrap: () => void,
|
||||
getTestability: (e: Element) => ITestabilityService
|
||||
@ -241,6 +242,7 @@ let angular: {
|
||||
bootstrap: noNg,
|
||||
module: noNg,
|
||||
element: noNgElement,
|
||||
injector: noNg,
|
||||
version: undefined as any,
|
||||
resumeBootstrap: noNg,
|
||||
getTestability: noNg
|
||||
@ -304,6 +306,9 @@ export const module_: typeof angular.module = (prefix, dependencies?) =>
|
||||
export const element: typeof angular.element = (e => angular.element(e)) as typeof angular.element;
|
||||
element.cleanData = nodes => angular.element.cleanData(nodes);
|
||||
|
||||
export const injector: typeof angular.injector =
|
||||
(modules: Array<string|IInjectable>, strictDi?: boolean) => angular.injector(modules, strictDi);
|
||||
|
||||
export const resumeBootstrap: typeof angular.resumeBootstrap = () => angular.resumeBootstrap();
|
||||
|
||||
export const getTestability: typeof angular.getTestability = e => angular.getTestability(e);
|
||||
|
Reference in New Issue
Block a user