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. --- test/ng/compileSpec.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'test/ng/compileSpec.js') diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 557fb85c..c8cb70f8 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -4506,8 +4506,9 @@ describe('$compile', function() { $rootScope.val2 = 'rice'; $rootScope.$digest(); - data = $animate.flushNext('addClass'); - expect(data.params[1]).toBe('ice rice'); + data = $animate.queue.shift(); + expect(data.event).toBe('addClass'); + expect(data.args[1]).toBe('ice rice'); expect(element.hasClass('ice')).toBe(true); expect(element.hasClass('rice')).toBe(true); @@ -4516,10 +4517,12 @@ describe('$compile', function() { $rootScope.val2 = 'dice'; $rootScope.$digest(); - data = $animate.flushNext('removeClass'); - expect(data.params[1]).toBe('rice'); - data = $animate.flushNext('addClass'); - expect(data.params[1]).toBe('dice'); + data = $animate.queue.shift(); + expect(data.event).toBe('removeClass'); + expect(data.args[1]).toBe('rice'); + data = $animate.queue.shift(); + expect(data.event).toBe('addClass'); + expect(data.args[1]).toBe('dice'); expect(element.hasClass('ice')).toBe(true); expect(element.hasClass('dice')).toBe(true); @@ -4529,8 +4532,9 @@ describe('$compile', function() { $rootScope.val2 = ''; $rootScope.$digest(); - data = $animate.flushNext('removeClass'); - expect(data.params[1]).toBe('ice dice'); + data = $animate.queue.shift(); + expect(data.event).toBe('removeClass'); + expect(data.args[1]).toBe('ice dice'); expect(element.hasClass('ice')).toBe(false); expect(element.hasClass('dice')).toBe(false); -- cgit v1.2.3