Skip to content

Commit b85926b

Browse files
committed
test($parse): add one-time/interceptor tests
1 parent b12a0b7 commit b85926b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/ng/parseSpec.js

+26
Original file line numberDiff line numberDiff line change
@@ -3340,6 +3340,32 @@ describe('parser', function() {
33403340
scope.$digest();
33413341
expect(called).toBe(true);
33423342
}));
3343+
3344+
it('should not affect when a one-time binding becomes stable', inject(function($parse) {
3345+
scope.$watch($parse('::x'));
3346+
scope.$watch($parse('::x', identity));
3347+
scope.$watch($parse('::x', function() { return 1; })); //interceptor that returns non-undefined
3348+
3349+
scope.$digest();
3350+
expect(scope.$$watchersCount).toBe(3);
3351+
3352+
scope.x = 1;
3353+
scope.$digest();
3354+
expect(scope.$$watchersCount).toBe(0);
3355+
}));
3356+
3357+
it('should not affect when a one-time literal binding becomes stable', inject(function($parse) {
3358+
scope.$watch($parse('::[x]'));
3359+
scope.$watch($parse('::[x]', identity));
3360+
scope.$watch($parse('::[x]', function() { return 1; })); //interceptor that returns non-literal
3361+
3362+
scope.$digest();
3363+
expect(scope.$$watchersCount).toBe(3);
3364+
3365+
scope.x = 1;
3366+
scope.$digest();
3367+
expect(scope.$$watchersCount).toBe(0);
3368+
}));
33433369
});
33443370

33453371
describe('literals', function() {

0 commit comments

Comments
 (0)