Skip to content

Commit

Permalink
test($parse): add one-time/interceptor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Jun 13, 2017
1 parent b12a0b7 commit b85926b
Showing 1 changed file with 26 additions and 0 deletions.
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

0 comments on commit b85926b

Please sign in to comment.