feat(testability): Expose function getAllAngularTestabilities

This commit is contained in:
Hank Duan 2015-07-30 15:51:06 -07:00
parent 71ea19902a
commit 7b94bbf3e4
4 changed files with 13 additions and 0 deletions

View File

@ -26,6 +26,7 @@ interface BrowserNodeGlobal {
Reflect: any;
zone: Zone;
getAngularTestability: Function;
getAllAngularTestabilities: Function;
setTimeout: Function;
clearTimeout: Function;
setInterval: Function;

View File

@ -86,5 +86,11 @@ class GetTestability {
Testability testability = registry.findTestabilityInTree(elem);
return _jsify(new PublicTestability(testability));
});
js.context['getAllAngularTestabilities'] = _jsify(() {
List<Testability> testabilities = registry.getAllTestabilities();
List<PublicTestability> publicTestabilities =
testabilities.map((testability) => new PublicTestability(testability));
return _jsify(publicTestabilities);
});
}
}

View File

@ -23,5 +23,9 @@ export class GetTestability {
}
return new PublicTestability(testability);
};
global.getAllAngularTestabilities = function(): List<PublicTestability> {
var testabilities = registry.getAllTestabilities();
return testabilities.map((testability) => { return new PublicTestability(testability); });
};
}
}

View File

@ -82,6 +82,8 @@ export class TestabilityRegistry {
this._applications.set(token, testability);
}
getAllTestabilities(): List<Testability> { return MapWrapper.values(this._applications); }
findTestabilityInTree(elem: Node): Testability {
if (elem == null) {
return null;