fix(closure): prevent closure renaming of testability interface (#11146)
This commit is contained in:
parent
d7de5c4f8e
commit
875e66409c
|
@ -21,7 +21,7 @@ export * from './src/zone';
|
||||||
export * from './src/render';
|
export * from './src/render';
|
||||||
export * from './src/linker';
|
export * from './src/linker';
|
||||||
export {DebugElement, DebugNode, asNativeElements, getDebugNode} from './src/debug/debug_node';
|
export {DebugElement, DebugNode, asNativeElements, getDebugNode} from './src/debug/debug_node';
|
||||||
export * from './src/testability/testability';
|
export {GetTestability, Testability, TestabilityRegistry, setTestabilityGetter} from './src/testability/testability';
|
||||||
export * from './src/change_detection';
|
export * from './src/change_detection';
|
||||||
export * from './src/platform_core_providers';
|
export * from './src/platform_core_providers';
|
||||||
export {TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID} from './src/i18n/tokens';
|
export {TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID} from './src/i18n/tokens';
|
||||||
|
|
|
@ -11,7 +11,17 @@ import {Map, MapWrapper} from '../facade/collection';
|
||||||
import {scheduleMicroTask} from '../facade/lang';
|
import {scheduleMicroTask} from '../facade/lang';
|
||||||
import {NgZone} from '../zone/ng_zone';
|
import {NgZone} from '../zone/ng_zone';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Testability API.
|
||||||
|
* `declare` keyword causes tsickle to generate externs, so these methods are
|
||||||
|
* not renamed by Closure Compiler.
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
export declare interface PublicTestability {
|
||||||
|
isStable(): boolean;
|
||||||
|
whenStable(callback: Function): void;
|
||||||
|
findProviders(using: any, provider: string, exactMatch: boolean): any[];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Testability service provides testing hooks that can be accessed from
|
* The Testability service provides testing hooks that can be accessed from
|
||||||
|
@ -20,7 +30,7 @@ import {NgZone} from '../zone/ng_zone';
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class Testability {
|
export class Testability implements PublicTestability {
|
||||||
/** @internal */
|
/** @internal */
|
||||||
_pendingCount: number = 0;
|
_pendingCount: number = 0;
|
||||||
/** @internal */
|
/** @internal */
|
||||||
|
|
|
@ -12,27 +12,6 @@ import {getDOM} from '../dom/dom_adapter';
|
||||||
import {ListWrapper} from '../facade/collection';
|
import {ListWrapper} from '../facade/collection';
|
||||||
import {global, isPresent} from '../facade/lang';
|
import {global, isPresent} from '../facade/lang';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PublicTestability {
|
|
||||||
/** @internal */
|
|
||||||
_testability: Testability;
|
|
||||||
|
|
||||||
constructor(testability: Testability) { this._testability = testability; }
|
|
||||||
|
|
||||||
isStable(): boolean { return this._testability.isStable(); }
|
|
||||||
|
|
||||||
whenStable(callback: Function) { this._testability.whenStable(callback); }
|
|
||||||
|
|
||||||
findBindings(using: any, provider: string, exactMatch: boolean): any[] {
|
|
||||||
return this.findProviders(using, provider, exactMatch);
|
|
||||||
}
|
|
||||||
|
|
||||||
findProviders(using: any, provider: string, exactMatch: boolean): any[] {
|
|
||||||
return this._testability.findBindings(using, provider, exactMatch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class BrowserGetTestability implements GetTestability {
|
export class BrowserGetTestability implements GetTestability {
|
||||||
static init() { setTestabilityGetter(new BrowserGetTestability()); }
|
static init() { setTestabilityGetter(new BrowserGetTestability()); }
|
||||||
|
|
||||||
|
@ -42,13 +21,10 @@ export class BrowserGetTestability implements GetTestability {
|
||||||
if (testability == null) {
|
if (testability == null) {
|
||||||
throw new Error('Could not find testability for element.');
|
throw new Error('Could not find testability for element.');
|
||||||
}
|
}
|
||||||
return new PublicTestability(testability);
|
return testability;
|
||||||
};
|
};
|
||||||
|
|
||||||
global.getAllAngularTestabilities = () => {
|
global.getAllAngularTestabilities = () => { return registry.getAllTestabilities(); };
|
||||||
var testabilities = registry.getAllTestabilities();
|
|
||||||
return testabilities.map((testability) => { return new PublicTestability(testability); });
|
|
||||||
};
|
|
||||||
|
|
||||||
global.getAllAngularRootElements = () => registry.getAllRootElements();
|
global.getAllAngularRootElements = () => registry.getAllRootElements();
|
||||||
|
|
||||||
|
|
|
@ -1120,7 +1120,7 @@ export declare abstract class TemplateRef<C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare class Testability {
|
export declare class Testability implements PublicTestability {
|
||||||
constructor(_ngZone: NgZone);
|
constructor(_ngZone: NgZone);
|
||||||
decreasePendingRequestCount(): number;
|
decreasePendingRequestCount(): number;
|
||||||
findBindings(using: any, provider: string, exactMatch: boolean): any[];
|
findBindings(using: any, provider: string, exactMatch: boolean): any[];
|
||||||
|
|
Loading…
Reference in New Issue