diff options
Diffstat (limited to 'test/ng/directive/ngSwitchSpec.js')
| -rw-r--r-- | test/ng/directive/ngSwitchSpec.js | 38 | 
1 files changed, 38 insertions, 0 deletions
| diff --git a/test/ng/directive/ngSwitchSpec.js b/test/ng/directive/ngSwitchSpec.js index e039c4d5..2b771a0c 100644 --- a/test/ng/directive/ngSwitchSpec.js +++ b/test/ng/directive/ngSwitchSpec.js @@ -293,4 +293,42 @@ describe('ngSwitch animations', function() {        expect(item.element.text()).toBe('three');    })); +  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 ng-switch="inc">' + +          '<div ng-switch-when="one">one</div>' + +          '<div ng-switch-when="two">two</div>' + +        '</div>' +      ))($scope); + +      $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); +    }); +  });  }); | 
