diff options
Diffstat (limited to 'test/ng/directive/ngIncludeSpec.js')
| -rw-r--r-- | test/ng/directive/ngIncludeSpec.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/ng/directive/ngIncludeSpec.js b/test/ng/directive/ngIncludeSpec.js index 9f37d1fe..510fa38a 100644 --- a/test/ng/directive/ngIncludeSpec.js +++ b/test/ng/directive/ngIncludeSpec.js @@ -663,4 +663,44 @@ describe('ngInclude animations', function() { expect(itemA).not.toEqual(itemB); })); + it('should destroy the previous leave animation if a new one takes place', function() { + module(function($provide) { + $provide.value('$animate', { + enabled : function() { return true; }, + leave : function() { + //DOM operation left blank + }, + enter : function(element, parent, after) { + angular.element(after).after(element); + } + }); + }); + inject(function ($compile, $rootScope, $animate, $templateCache) { + var item; + var $scope = $rootScope.$new(); + element = $compile(html( + '<div>' + + '<div ng-include="inc">Yo</div>' + + '</div>' + ))($scope); + + $templateCache.put('one', [200, '<div>one</div>', {}]); + $templateCache.put('two', [200, '<div>two</div>', {}]); + + $scope.$apply('inc = "one"'); + + var destroyed, inner = element.children(0); + inner.on('$destroy', function() { + destroyed = true; + }); + + $scope.$apply('inc = "two"'); + + $scope.$apply('inc = "one"'); + + $scope.$apply('inc = "two"'); + + expect(destroyed).toBe(true); + }); + }); }); |
