diff options
| author | Misko Hevery | 2013-04-11 22:39:15 -0700 |
|---|---|---|
| committer | Misko Hevery | 2013-04-11 23:06:07 -0700 |
| commit | 570463a465fae02efc33e5a1fa963437cdc275dd (patch) | |
| tree | fde71c8e537b0c8985ba5d0f920f8fc67ef2585a /test/ng/directive | |
| parent | 3c3247fe174ce408459bd018c9d83e84490789f5 (diff) | |
| download | angular.js-570463a465fae02efc33e5a1fa963437cdc275dd.tar.bz2 | |
fix(ngAnimate): prevent animation on initial page load
Diffstat (limited to 'test/ng/directive')
| -rw-r--r-- | test/ng/directive/ngIncludeSpec.js | 3 | ||||
| -rw-r--r-- | test/ng/directive/ngRepeatSpec.js | 3 | ||||
| -rw-r--r-- | test/ng/directive/ngShowHideSpec.js | 23 | ||||
| -rw-r--r-- | test/ng/directive/ngSwitchSpec.js | 3 | ||||
| -rw-r--r-- | test/ng/directive/ngViewSpec.js | 10 |
5 files changed, 28 insertions, 14 deletions
diff --git a/test/ng/directive/ngIncludeSpec.js b/test/ng/directive/ngIncludeSpec.js index 4798bacc..9b5319f1 100644 --- a/test/ng/directive/ngIncludeSpec.js +++ b/test/ng/directive/ngIncludeSpec.js @@ -303,8 +303,9 @@ describe('ngInclude ngAnimate', function() { beforeEach(module(function($animationProvider, $provide) { $provide.value('$window', window = angular.mock.createMockWindow()); - return function($sniffer) { + return function($sniffer, $animator) { vendorPrefix = '-' + $sniffer.vendorPrefix + '-'; + $animator.enabled(true); }; })); diff --git a/test/ng/directive/ngRepeatSpec.js b/test/ng/directive/ngRepeatSpec.js index 7376b670..4372f57a 100644 --- a/test/ng/directive/ngRepeatSpec.js +++ b/test/ng/directive/ngRepeatSpec.js @@ -554,8 +554,9 @@ describe('ngRepeat ngAnimate', function() { beforeEach(module(function($animationProvider, $provide) { $provide.value('$window', window = angular.mock.createMockWindow()); - return function($sniffer) { + return function($sniffer, $animator) { vendorPrefix = '-' + $sniffer.vendorPrefix + '-'; + $animator.enabled(true); }; })); 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('<div ng-show="val" ng-animate="\'animation\'">123</div>'))($rootScope); + $rootElement.controller('ngAnimate').running = true; element.css('display','none'); expect(element.css('display')).toBe('none'); @@ -123,6 +130,7 @@ describe('ngShow / ngHide - ngAnimate', function() { expect(element[0].style.display).toBe(''); expect(fired).toBe(false); + $rootElement.controller('ngAnimate').running = false; $rootScope.val = false; $rootScope.$digest(); if ($sniffer.supportsTransitions) { @@ -178,7 +186,7 @@ describe('ngShow / ngHide - ngAnimate', function() { expect(element.attr('class')).not.toContain('custom-show-setup'); })); - it('should skip the initial hide state on the first digest', function() { + it('should disable animation when parent animation is running', function() { var fired = false; module(function($animationProvider) { $animationProvider.register('destructive-animation', function() { @@ -193,6 +201,7 @@ describe('ngShow / ngHide - ngAnimate', function() { inject(function($compile, $rootScope) { $rootScope.val = false; var element = $compile(html('<div ng-hide="val" ng-animate="{ hide:\'destructive-animation\' }">123</div>'))($rootScope); + $rootElement.controller('ngAnimate').running = true; element.css('display','block'); expect(element.css('display')).toBe('block'); diff --git a/test/ng/directive/ngSwitchSpec.js b/test/ng/directive/ngSwitchSpec.js index 5f0a2bb3..ee51e194 100644 --- a/test/ng/directive/ngSwitchSpec.js +++ b/test/ng/directive/ngSwitchSpec.js @@ -236,8 +236,9 @@ describe('ngSwitch ngAnimate', function() { beforeEach(module(function($animationProvider, $provide) { $provide.value('$window', window = angular.mock.createMockWindow()); - return function($sniffer) { + return function($sniffer, $animator) { vendorPrefix = '-' + $sniffer.vendorPrefix + '-'; + $animator.enabled(true); }; })); diff --git a/test/ng/directive/ngViewSpec.js b/test/ng/directive/ngViewSpec.js index c0348568..e9d53110 100644 --- a/test/ng/directive/ngViewSpec.js +++ b/test/ng/directive/ngViewSpec.js @@ -4,8 +4,9 @@ describe('ngView', function() { var element; beforeEach(module(function() { - return function($rootScope, $compile) { + return function($rootScope, $compile, $animator) { element = $compile('<ng:view onload="load()"></ng:view>')($rootScope); + $animator.enabled(true); }; })); @@ -510,8 +511,9 @@ describe('ngAnimate', function() { beforeEach(module(function($provide, $routeProvider) { $provide.value('$window', window = angular.mock.createMockWindow()); $routeProvider.when('/foo', {controller: noop, templateUrl: '/foo.html'}); - return function($templateCache) { + return function($templateCache, $animator) { $templateCache.put('/foo.html', [200, '<div>data</div>', {}]); + $animator.enabled(true); } })); @@ -579,8 +581,8 @@ describe('ngAnimate', function() { element = $compile(html( '<div ' + 'ng-view ' + - 'ng-animate="{enter: \'customEnter\', animateFirst: false}">' + - '</div>' + 'ng-animate="{enter: \'customEnter\'}">' + + '</div>' ))($rootScope); $location.path('/foo'); |
