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

test($parse): add one-time/interceptor tests #16043

Merged
merged 1 commit into from
Jun 13, 2017
Merged
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
26 changes: 26 additions & 0 deletions test/ng/parseSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3340,6 +3340,32 @@ describe('parser', function() {
scope.$digest();
expect(called).toBe(true);
}));

it('should not affect when a one-time binding becomes stable', inject(function($parse) {
scope.$watch($parse('::x'));
scope.$watch($parse('::x', identity));
scope.$watch($parse('::x', function() { return 1; })); //interceptor that returns non-undefined

scope.$digest();
expect(scope.$$watchersCount).toBe(3);

scope.x = 1;
scope.$digest();
expect(scope.$$watchersCount).toBe(0);
}));

it('should not affect when a one-time literal binding becomes stable', inject(function($parse) {
scope.$watch($parse('::[x]'));
scope.$watch($parse('::[x]', identity));
scope.$watch($parse('::[x]', function() { return 1; })); //interceptor that returns non-literal

scope.$digest();
expect(scope.$$watchersCount).toBe(3);

scope.x = 1;
scope.$digest();
expect(scope.$$watchersCount).toBe(0);
}));
});

describe('literals', function() {
Expand Down