From 2f8e4a10eeb729c956d533c4be420d7bb16e467c Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Fri, 13 Feb 2015 21:31:56 -0800 Subject: [PATCH] test($interpolate): ensure constant interpolation watchers are removed --- test/ng/interpolateSpec.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/ng/interpolateSpec.js b/test/ng/interpolateSpec.js index 232244ede492..dfab860b1e3b 100644 --- a/test/ng/interpolateSpec.js +++ b/test/ng/interpolateSpec.js @@ -125,6 +125,28 @@ describe('$interpolate', function() { expect($rootScope.$countWatchers()).toBe(0); })); + + it('should stop watching strings with no expressions after first execution', + inject(function($interpolate, $rootScope) { + var spy = jasmine.createSpy(); + $rootScope.$watch($interpolate('foo'), spy); + $rootScope.$digest(); + expect($rootScope.$countWatchers()).toBe(0); + expect(spy).toHaveBeenCalledWith('foo', 'foo', $rootScope); + expect(spy.calls.length).toBe(1); + }) + ); + + it('should stop watching strings with only constant expressions after first execution', + inject(function($interpolate, $rootScope) { + var spy = jasmine.createSpy(); + $rootScope.$watch($interpolate('foo {{42}}'), spy); + $rootScope.$digest(); + expect($rootScope.$countWatchers()).toBe(0); + expect(spy).toHaveBeenCalledWith('foo 42', 'foo 42', $rootScope); + expect(spy.calls.length).toBe(1); + }) + ); }); describe('interpolation escaping', function() {