From 4c4537e65e6cf911c9659b562d89e3330ce3ffae Mon Sep 17 00:00:00 2001 From: Matias Niemelä Date: Mon, 24 Feb 2014 19:43:57 -0500 Subject: perf($animate): use rAF instead of timeouts to issue animation callbacks --- test/ng/directive/ngClassSpec.js | 5 +++-- test/ng/directive/ngIncludeSpec.js | 14 +++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'test/ng') diff --git a/test/ng/directive/ngClassSpec.js b/test/ng/directive/ngClassSpec.js index b11c4766..83cd3000 100644 --- a/test/ng/directive/ngClassSpec.js +++ b/test/ng/directive/ngClassSpec.js @@ -345,6 +345,7 @@ describe('ngClass animations', function() { //mocks are not used since the enter delegation method is called before addClass and //it makes it impossible to test to see that addClass is called first module('ngAnimate'); + module('ngAnimateMock'); var digestQueue = []; module(function($animateProvider) { @@ -367,7 +368,7 @@ describe('ngClass animations', function() { }; }; }); - inject(function($compile, $rootScope, $rootElement, $animate, $timeout, $document) { + inject(function($compile, $rootScope, $browser, $rootElement, $animate, $timeout, $document) { // Enable animations by triggering the first item in the postDigest queue digestQueue.shift()(); @@ -407,7 +408,7 @@ describe('ngClass animations', function() { //is spaced-out then it is required so that the original digestion //is kicked into gear $rootScope.$digest(); - $timeout.flush(); + $animate.triggerCallbacks(); expect(element.data('state')).toBe('crazy-enter'); expect(enterComplete).toBe(true); diff --git a/test/ng/directive/ngIncludeSpec.js b/test/ng/directive/ngIncludeSpec.js index ebb35147..9f37d1fe 100644 --- a/test/ng/directive/ngIncludeSpec.js +++ b/test/ng/directive/ngIncludeSpec.js @@ -368,7 +368,7 @@ describe('ngInclude', function() { expect(autoScrollSpy).not.toHaveBeenCalled(); expect($animate.queue.shift().event).toBe('enter'); - $timeout.flush(); + $animate.triggerCallbacks(); expect(autoScrollSpy).toHaveBeenCalledOnce(); })); @@ -385,7 +385,7 @@ describe('ngInclude', function() { }); expect($animate.queue.shift().event).toBe('enter'); - $timeout.flush(); + $animate.triggerCallbacks(); $rootScope.$apply(function () { $rootScope.tpl = 'another.html'; @@ -394,7 +394,7 @@ describe('ngInclude', function() { expect($animate.queue.shift().event).toBe('leave'); expect($animate.queue.shift().event).toBe('enter'); - $timeout.flush(); + $animate.triggerCallbacks(); $rootScope.$apply(function() { $rootScope.tpl = 'template.html'; @@ -403,7 +403,7 @@ describe('ngInclude', function() { expect($animate.queue.shift().event).toBe('leave'); expect($animate.queue.shift().event).toBe('enter'); - $timeout.flush(); + $animate.triggerCallbacks(); expect(autoScrollSpy).toHaveBeenCalled(); expect(autoScrollSpy.callCount).toBe(3); @@ -419,7 +419,7 @@ describe('ngInclude', function() { }); expect($animate.queue.shift().event).toBe('enter'); - $timeout.flush(); + $animate.triggerCallbacks(); expect(autoScrollSpy).not.toHaveBeenCalled(); })); @@ -435,7 +435,7 @@ describe('ngInclude', function() { }); expect($animate.queue.shift().event).toBe('enter'); - $timeout.flush(); + $animate.triggerCallbacks(); $rootScope.$apply(function () { $rootScope.tpl = 'template.html'; @@ -457,7 +457,7 @@ describe('ngInclude', function() { $rootScope.$apply("tpl = 'template.html'"); expect($animate.queue.shift().event).toBe('enter'); - $timeout.flush(); + $animate.triggerCallbacks(); expect(autoScrollSpy).toHaveBeenCalledOnce(); })); -- cgit v1.2.3