From 7b94bbf3e4fa4775d48080f5728bffc0694fcefa Mon Sep 17 00:00:00 2001 From: Hank Duan Date: Thu, 30 Jul 2015 15:51:06 -0700 Subject: [PATCH] feat(testability): Expose function getAllAngularTestabilities --- modules/angular2/globals.d.ts | 1 + modules/angular2/src/core/testability/get_testability.dart | 6 ++++++ modules/angular2/src/core/testability/get_testability.ts | 4 ++++ modules/angular2/src/core/testability/testability.ts | 2 ++ 4 files changed, 13 insertions(+) diff --git a/modules/angular2/globals.d.ts b/modules/angular2/globals.d.ts index d6b18a7845..ee3388ea4b 100644 --- a/modules/angular2/globals.d.ts +++ b/modules/angular2/globals.d.ts @@ -26,6 +26,7 @@ interface BrowserNodeGlobal { Reflect: any; zone: Zone; getAngularTestability: Function; + getAllAngularTestabilities: Function; setTimeout: Function; clearTimeout: Function; setInterval: Function; diff --git a/modules/angular2/src/core/testability/get_testability.dart b/modules/angular2/src/core/testability/get_testability.dart index b94dd223b0..f7097905d6 100644 --- a/modules/angular2/src/core/testability/get_testability.dart +++ b/modules/angular2/src/core/testability/get_testability.dart @@ -86,5 +86,11 @@ class GetTestability { Testability testability = registry.findTestabilityInTree(elem); return _jsify(new PublicTestability(testability)); }); + js.context['getAllAngularTestabilities'] = _jsify(() { + List testabilities = registry.getAllTestabilities(); + List publicTestabilities = + testabilities.map((testability) => new PublicTestability(testability)); + return _jsify(publicTestabilities); + }); } } diff --git a/modules/angular2/src/core/testability/get_testability.ts b/modules/angular2/src/core/testability/get_testability.ts index c84c8ff3f8..f4a23508e0 100644 --- a/modules/angular2/src/core/testability/get_testability.ts +++ b/modules/angular2/src/core/testability/get_testability.ts @@ -23,5 +23,9 @@ export class GetTestability { } return new PublicTestability(testability); }; + global.getAllAngularTestabilities = function(): List { + var testabilities = registry.getAllTestabilities(); + return testabilities.map((testability) => { return new PublicTestability(testability); }); + }; } } diff --git a/modules/angular2/src/core/testability/testability.ts b/modules/angular2/src/core/testability/testability.ts index 478f6bc740..80e14461de 100644 --- a/modules/angular2/src/core/testability/testability.ts +++ b/modules/angular2/src/core/testability/testability.ts @@ -82,6 +82,8 @@ export class TestabilityRegistry { this._applications.set(token, testability); } + getAllTestabilities(): List { return MapWrapper.values(this._applications); } + findTestabilityInTree(elem: Node): Testability { if (elem == null) { return null;