From 906fdad0f95465842e336e057ea97d0633712189 Mon Sep 17 00:00:00 2001 From: Matias Niemelä Date: Wed, 22 Jan 2014 19:21:05 -0500 Subject: fix(mocks): remove usage of $animate.flushNext in favour of queing The flushNext method of testing is difficult and highly coupled with the behavior of ngAnimate's $animate workflow. It is much better instead to just queue all $animate animation calls into a queue collection which is available on the $animate service when mock.animate is included as a module within test code. --- src/ngMock/angular-mocks.js | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index a6bcea88..091a8a16 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -790,37 +790,20 @@ if(animateLoaded) { angular.mock.animate = angular.module('mock.animate', ['ng']) .config(['$provide', function($provide) { - $provide.decorator('$animate', function($delegate) { var animate = { queue : [], enabled : $delegate.enabled, - flushNext : function(name) { - var tick = animate.queue.shift(); - - if (!tick) throw new Error('No animation to be flushed'); - if(tick.method !== name) { - throw new Error('The next animation is not "' + name + - '", but is "' + tick.method + '"'); - } - tick.fn(); - return tick; - } }; angular.forEach(['enter','leave','move','addClass','removeClass'], function(method) { animate[method] = function() { - var params = arguments; animate.queue.push({ - method : method, - params : params, - element : angular.isElement(params[0]) && params[0], - parent : angular.isElement(params[1]) && params[1], - after : angular.isElement(params[2]) && params[2], - fn : function() { - $delegate[method].apply($delegate, params); - } + event : method, + element : arguments[0], + args : arguments }); + $delegate[method].apply($delegate, arguments); }; }); -- cgit v1.2.3