Skip to content

Commit 8c4a420

Browse files
jbedardnetman92
authored andcommitted
test($interpolate): ensure constant interpolation watchers are removed
Closes angular#11057
1 parent d1bcfa7 commit 8c4a420

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/ng/interpolateSpec.js

+22
Original file line numberDiff line numberDiff 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() {

0 commit comments

Comments
 (0)