aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/directive/ngIfSpec.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/ng/directive/ngIfSpec.js')
-rwxr-xr-xtest/ng/directive/ngIfSpec.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/ng/directive/ngIfSpec.js b/test/ng/directive/ngIfSpec.js
index d40e6812..771e264a 100755
--- a/test/ng/directive/ngIfSpec.js
+++ b/test/ng/directive/ngIfSpec.js
@@ -277,4 +277,42 @@ describe('ngIf animations', function () {
expect(element.children().length).toBe(0);
}));
+ 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) {
+ parent.append(element);
+ }
+ });
+ });
+ inject(function ($compile, $rootScope, $animate) {
+ var item;
+ var $scope = $rootScope.$new();
+ element = $compile(html(
+ '<div>' +
+ '<div ng-if="value">Yo</div>' +
+ '</div>'
+ ))($scope);
+
+ $scope.$apply('value = true');
+
+ var destroyed, inner = element.children(0);
+ inner.on('$destroy', function() {
+ destroyed = true;
+ });
+
+ $scope.$apply('value = false');
+
+ $scope.$apply('value = true');
+
+ $scope.$apply('value = false');
+
+ expect(destroyed).toBe(true);
+ });
+ });
+
});