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

Commit 220537c

Browse files
committed
test($parse): add one-time/interceptor tests
1 parent 420ceb6 commit 220537c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/ng/parseSpec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3321,6 +3321,32 @@ describe('parser', function() {
33213321
scope.$digest();
33223322
expect(called).toBe(true);
33233323
}));
3324+
3325+
it('should not effect when a one-time binding becomes stable', inject(function($parse) {
3326+
scope.$watch($parse('::x'));
3327+
scope.$watch($parse('::x', identity));
3328+
scope.$watch($parse('::x', function() { return 1; })); //interceptor that returns non-undefined
3329+
3330+
scope.$digest();
3331+
expect(scope.$$watchersCount).toBe(3);
3332+
3333+
scope.x = 1;
3334+
scope.$digest();
3335+
expect(scope.$$watchersCount).toBe(0);
3336+
}));
3337+
3338+
it('should not effect when a one-time literal binding becomes stable', inject(function($parse) {
3339+
scope.$watch($parse('::[x]'));
3340+
scope.$watch($parse('::[x]', identity));
3341+
scope.$watch($parse('::[x]', function() { return 1; })); //interceptor that returns non-literal
3342+
3343+
scope.$digest();
3344+
expect(scope.$$watchersCount).toBe(3);
3345+
3346+
scope.x = 1;
3347+
scope.$digest();
3348+
expect(scope.$$watchersCount).toBe(0);
3349+
}));
33243350
});
33253351

33263352
describe('literals', function() {

0 commit comments

Comments
 (0)