diff options
| author | Matias Niemelä | 2014-01-22 19:21:05 -0500 |
|---|---|---|
| committer | Matias Niemelä | 2014-02-06 01:21:41 -0500 |
| commit | 906fdad0f95465842e336e057ea97d0633712189 (patch) | |
| tree | 0993034fe2ce43ad090203c7d2390662536d1d91 /src/ngMock/angular-mocks.js | |
| parent | a8c1d9c97804f7df98150456c2702fd39e3a22f0 (diff) | |
| download | angular.js-906fdad0f95465842e336e057ea97d0633712189.tar.bz2 | |
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.
Diffstat (limited to 'src/ngMock/angular-mocks.js')
| -rw-r--r-- | src/ngMock/angular-mocks.js | 25 |
1 files changed, 4 insertions, 21 deletions
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); }; }); |
