diff options
Diffstat (limited to 'test/ng')
| -rwxr-xr-x | test/ng/compileSpec.js | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 09048885..2b6b235f 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -1426,7 +1426,7 @@ describe('$compile', function() { return { restrict: 'CA', link: {pre: function(scope) { - log('log-' + scope.$id + '-' + scope.$parent.$id); + log('log-' + scope.$id + '-' + (scope.$parent && scope.$parent.$id || 'no-parent')); }} }; }); @@ -1443,7 +1443,7 @@ describe('$compile', function() { it('should allow creation of new isolated scopes for directives', inject( function($rootScope, $compile, log) { element = $compile('<div><span iscope><a log></a></span></div>')($rootScope); - expect(log).toEqual('log-002-001; LOG; 002'); + expect(log).toEqual('log-001-no-parent; LOG; 002'); $rootScope.name = 'abc'; expect(iscope.$parent).toBe($rootScope); expect(iscope.name).toBeUndefined(); @@ -2131,6 +2131,62 @@ describe('$compile', function() { expect(componentScope.$parent).toBe(regularScope) })); + it('should not give the isolate scope to other directive template', function() { + module(function() { + directive('otherTplDir', function() { + return { + template: 'value: {{value}}' + }; + }); + }); + + inject(function($rootScope) { + compile('<div my-component other-tpl-dir>'); + + $rootScope.$apply(function() { + $rootScope.value = 'from-parent'; + }); + + expect(element.html()).toBe('value: from-parent'); + }); + }); + + + it('should not give the isolate scope to other directive template (with templateUrl)', function() { + module(function() { + directive('otherTplDir', function() { + return { + templateUrl: 'other.html' + }; + }); + }); + + inject(function($rootScope, $templateCache) { + $templateCache.put('other.html', 'value: {{value}}') + compile('<div my-component other-tpl-dir>'); + + $rootScope.$apply(function() { + $rootScope.value = 'from-parent'; + }); + + expect(element.html()).toBe('value: from-parent'); + }); + }); + + + it('should not give the isolate scope to regular child elements', function() { + inject(function($rootScope) { + compile('<div my-component>value: {{value}}</div>'); + + $rootScope.$apply(function() { + $rootScope.value = 'from-parent'; + }); + + expect(element.html()).toBe('value: from-parent'); + }); + }); + + describe('attribute', function() { it('should copy simple attribute', inject(function() { compile('<div><span my-component attr="some text">'); |
