From e31104fa6c9e5efd93ac69cd70c70cffaf200843 Mon Sep 17 00:00:00 2001 From: Matias Niemelä Date: Thu, 25 Jul 2013 21:19:20 -0400 Subject: fix($animate): make animation onComplete callbacks async --- test/ngAnimate/animateSpec.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'test/ngAnimate') diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index e896686b..25f4dccc 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -32,12 +32,6 @@ describe("ngAnimate", function() { describe("enable / disable", function() { - beforeEach(function() { - module(function($animateProvider, $provide) { - $provide.value('$window', angular.mock.createMockWindow()); - }); - }); - it("should disable and enable the animations", function() { var $animate, initialState = null; @@ -259,8 +253,8 @@ describe("ngAnimate", function() { $animate.removeClass(element, 'ng-hide'); if($sniffer.transitions) { - $timeout.flushNext(1); $timeout.flushNext(0); + $timeout.flushNext(1); } $timeout.flushNext(0); expect(element.text()).toBe('memento'); @@ -510,7 +504,7 @@ describe("ngAnimate", function() { })); it("should skip animations if disabled and run when enabled", - inject(function($animate, $rootScope, $compile, $sniffer) { + inject(function($animate, $rootScope, $compile, $sniffer, $timeout) { $animate.enabled(false); var style = 'animation: some_animation 2s linear 0s 1 alternate;' + vendorPrefix + 'animation: some_animation 2s linear 0s 1 alternate;' @@ -519,6 +513,7 @@ describe("ngAnimate", function() { element.addClass('ng-hide'); expect(element).toBeHidden(); $animate.removeClass(element, 'ng-hide'); + $timeout.flush(); expect(element).toBeShown(); })); @@ -563,9 +558,9 @@ describe("ngAnimate", function() { element.addClass('ng-hide'); expect(element).toBeHidden(); $animate.removeClass(element, 'ng-hide'); - expect(element).toBeShown(); - $timeout.flushNext(0); + $timeout.flushNext(0); + expect(element).toBeShown(); $animate.enabled(true); @@ -591,6 +586,7 @@ describe("ngAnimate", function() { $timeout.flushNext(1); $timeout.flushNext(2000); } + $timeout.flush(); expect(element).toBeShown(); })); @@ -604,10 +600,10 @@ describe("ngAnimate", function() { element.addClass('ng-hide'); $animate.removeClass(element, 'ng-hide'); + $timeout.flushNext(0); + $timeout.flushNext(0); expect(element).toBeShown(); - $timeout.flushNext(0); //callback which is called - $animate.enabled(true); element.addClass('ng-hide'); @@ -618,7 +614,7 @@ describe("ngAnimate", function() { $timeout.flushNext(1); $timeout.flushNext(3000); } - $timeout.flushNext(0); + $timeout.flush(); expect(element).toBeShown(); })); -- cgit v1.2.3