diff options
Diffstat (limited to 'test/ng/directive')
| -rw-r--r-- | test/ng/directive/ngIncludeSpec.js | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/test/ng/directive/ngIncludeSpec.js b/test/ng/directive/ngIncludeSpec.js index 59f8b4ae..2d115e8b 100644 --- a/test/ng/directive/ngIncludeSpec.js +++ b/test/ng/directive/ngIncludeSpec.js @@ -465,10 +465,22 @@ describe('ngInclude', function() { }); describe('ngInclude and transcludes', function() { + var element, directive; + + beforeEach(module(function($compileProvider) { + element = null; + directive = $compileProvider.directive; + })); + + afterEach(function() { + if (element) { + dealoc(element); + } + }); + it('should allow access to directive controller from children when used in a replace template', function() { var controller; - module(function($compileProvider) { - var directive = $compileProvider.directive; + module(function() { directive('template', valueFn({ template: '<div ng-include="\'include.html\'"></div>', replace: true, @@ -485,13 +497,33 @@ describe('ngInclude and transcludes', function() { }); inject(function($compile, $rootScope, $httpBackend) { $httpBackend.expectGET('include.html').respond('<div><div test></div></div>'); - var element = $compile('<div><div template></div></div>')($rootScope); + element = $compile('<div><div template></div></div>')($rootScope); $rootScope.$apply(); $httpBackend.flush(); expect(controller.flag).toBe(true); - dealoc(element); }); }); + + it("should compile it's content correctly (although we remove it later)", function() { + var testElement; + module(function() { + directive('test', function() { + return { + link: function(scope, element) { + testElement = element; + } + }; + }); + }); + inject(function($compile, $rootScope, $httpBackend) { + $httpBackend.expectGET('include.html').respond(' '); + element = $compile('<div><div ng-include="\'include.html\'"><div test></div></div></div>')($rootScope); + $rootScope.$apply(); + $httpBackend.flush(); + expect(testElement[0].nodeName).toBe('DIV'); + }); + + }); }); describe('ngInclude animations', function() { |
