Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

test($interpolate): ensure constant interpolation watchers are removed #11057

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions test/ng/interpolateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down