File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -125,6 +125,28 @@ describe('$interpolate', function() {
125125
126126 expect ( $rootScope . $countWatchers ( ) ) . toBe ( 0 ) ;
127127 } ) ) ;
128+
129+ it ( 'should stop watching strings with no expressions after first execution' ,
130+ inject ( function ( $interpolate , $rootScope ) {
131+ var spy = jasmine . createSpy ( ) ;
132+ $rootScope . $watch ( $interpolate ( 'foo' ) , spy ) ;
133+ $rootScope . $digest ( ) ;
134+ expect ( $rootScope . $countWatchers ( ) ) . toBe ( 0 ) ;
135+ expect ( spy ) . toHaveBeenCalledWith ( 'foo' , 'foo' , $rootScope ) ;
136+ expect ( spy . calls . length ) . toBe ( 1 ) ;
137+ } )
138+ ) ;
139+
140+ it ( 'should stop watching strings with only constant expressions after first execution' ,
141+ inject ( function ( $interpolate , $rootScope ) {
142+ var spy = jasmine . createSpy ( ) ;
143+ $rootScope . $watch ( $interpolate ( 'foo {{42}}' ) , spy ) ;
144+ $rootScope . $digest ( ) ;
145+ expect ( $rootScope . $countWatchers ( ) ) . toBe ( 0 ) ;
146+ expect ( spy ) . toHaveBeenCalledWith ( 'foo 42' , 'foo 42' , $rootScope ) ;
147+ expect ( spy . calls . length ) . toBe ( 1 ) ;
148+ } )
149+ ) ;
128150 } ) ;
129151
130152 describe ( 'interpolation escaping' , function ( ) {
You can’t perform that action at this time.
0 commit comments