@@ -28,8 +28,12 @@ var functions = {};
28
28
functions . waitForAngular = function ( selector , callback ) {
29
29
var el = document . querySelector ( selector ) ;
30
30
try {
31
- angular . element ( el ) . injector ( ) . get ( '$browser' ) .
32
- notifyWhenNoOutstandingRequests ( callback ) ;
31
+ if ( angular . getTestability ) {
32
+ angular . getTestability ( el ) . whenStable ( callback ) ;
33
+ } else {
34
+ angular . element ( el ) . injector ( ) . get ( '$browser' ) .
35
+ notifyWhenNoOutstandingRequests ( callback ) ;
36
+ }
33
37
} catch ( e ) {
34
38
callback ( e ) ;
35
39
}
@@ -46,6 +50,10 @@ functions.waitForAngular = function(selector, callback) {
46
50
*/
47
51
functions . findBindings = function ( binding , exactMatch , using ) {
48
52
using = using || document ;
53
+ if ( angular . getTestability ) {
54
+ return angular . getTestability ( using ) .
55
+ findBindings ( using , binding , exactMatch ) ;
56
+ }
49
57
var bindings = using . getElementsByClassName ( 'ng-binding' ) ;
50
58
var matches = [ ] ;
51
59
for ( var i = 0 ; i < bindings . length ; ++ i ) {
@@ -338,6 +346,10 @@ functions.findRepeaterColumn = function(repeater, binding, using) {
338
346
*/
339
347
functions . findByModel = function ( model , using ) {
340
348
using = using || document ;
349
+ if ( angular . getTestability ) {
350
+ return angular . getTestability ( using ) .
351
+ findModels ( using , model ) ;
352
+ }
341
353
var prefixes = [ 'ng-' , 'ng_' , 'data-ng-' , 'x-ng-' , 'ng\\:' ] ;
342
354
for ( var p = 0 ; p < prefixes . length ; ++ p ) {
343
355
var selector = '[' + prefixes [ p ] + 'model="' + model + '"]' ;
@@ -515,6 +527,10 @@ functions.allowAnimations = function(element, value) {
515
527
*/
516
528
functions . getLocationAbsUrl = function ( selector ) {
517
529
var el = document . querySelector ( selector ) ;
530
+ if ( angular . getTestability ) {
531
+ return angular . getTestability ( el ) .
532
+ getLocation ( ) ;
533
+ }
518
534
return angular . element ( el ) . injector ( ) . get ( '$location' ) . absUrl ( ) ;
519
535
} ;
520
536
@@ -527,6 +543,10 @@ functions.getLocationAbsUrl = function(selector) {
527
543
*/
528
544
functions . setLocation = function ( selector , url ) {
529
545
var el = document . querySelector ( selector ) ;
546
+ if ( angular . getTestability ) {
547
+ return angular . getTestability ( el ) .
548
+ setLocation ( url ) ;
549
+ }
530
550
var $injector = angular . element ( el ) . injector ( ) ;
531
551
var $location = $injector . get ( '$location' ) ;
532
552
var $rootScope = $injector . get ( '$rootScope' ) ;
0 commit comments