From 570463a465fae02efc33e5a1fa963437cdc275dd Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 11 Apr 2013 22:39:15 -0700 Subject: fix(ngAnimate): prevent animation on initial page load --- test/ng/directive/ngShowHideSpec.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'test/ng/directive/ngShowHideSpec.js') diff --git a/test/ng/directive/ngShowHideSpec.js b/test/ng/directive/ngShowHideSpec.js index 17c47255..ecc5b2dc 100644 --- a/test/ng/directive/ngShowHideSpec.js +++ b/test/ng/directive/ngShowHideSpec.js @@ -45,11 +45,12 @@ describe('ngShow / ngHide', function() { describe('ngShow / ngHide - ngAnimate', function() { var window; var vendorPrefix; - var body, element; + var body, element, $rootElement; function html(html) { - body.html(html); - element = body.children().eq(0); + body.append($rootElement); + $rootElement.html(html); + element = $rootElement.children().eq(0); return element; } @@ -61,12 +62,15 @@ describe('ngShow / ngHide - ngAnimate', function() { afterEach(function(){ dealoc(body); dealoc(element); + body.removeAttr('ng-animation-running'); }); beforeEach(module(function($animationProvider, $provide) { $provide.value('$window', window = angular.mock.createMockWindow()); - return function($sniffer) { + return function($sniffer, _$rootElement_, $animator) { vendorPrefix = '-' + $sniffer.vendorPrefix + '-'; + $rootElement = _$rootElement_; + $animator.enabled(true); }; })); @@ -111,11 +115,14 @@ describe('ngShow / ngHide - ngAnimate', function() { expect(element.attr('class')).not.toContain('custom-hide-setup'); })); - it('should skip the initial show state on the first digest', function() { + it('should skip animation if parent animation running', function() { var fired = false; - inject(function($compile, $rootScope, $sniffer) { + inject(function($animator, $compile, $rootScope, $sniffer) { + $animator.enabled(true); + $rootScope.$digest(); $rootScope.val = true; var element = $compile(html('