aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng
diff options
context:
space:
mode:
Diffstat (limited to 'test/ng')
-rwxr-xr-xtest/ng/compileSpec.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js
index 5110c4d6..96d3c18b 100755
--- a/test/ng/compileSpec.js
+++ b/test/ng/compileSpec.js
@@ -1914,15 +1914,14 @@ describe('$compile', function() {
describe('interpolation', function() {
- var observeSpy, directiveAttrs;
+ var observeSpy, directiveAttrs, deregisterObserver;
beforeEach(module(function() {
directive('observer', function() {
return function(scope, elm, attr) {
directiveAttrs = attr;
observeSpy = jasmine.createSpy('$observe attr');
-
- expect(attr.$observe('someAttr', observeSpy)).toBe(observeSpy);
+ deregisterObserver = attr.$observe('someAttr', observeSpy);
};
});
directive('replaceSomeAttr', valueFn({
@@ -2020,6 +2019,18 @@ describe('$compile', function() {
}));
+ it('should return a deregistration function while observing an attribute', inject(function($rootScope, $compile) {
+ $compile('<div some-attr="{{value}}" observer></div>')($rootScope);
+
+ $rootScope.$apply('value = "first-value"');
+ expect(observeSpy).toHaveBeenCalledWith('first-value');
+
+ deregisterObserver();
+ $rootScope.$apply('value = "new-value"');
+ expect(observeSpy).not.toHaveBeenCalledWith('new-value');
+ }));
+
+
it('should set interpolated attrs to initial interpolation value', inject(function($rootScope, $compile) {
$rootScope.whatever = 'test value';
$compile('<div some-attr="{{whatever}}" observer></div>')($rootScope);