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 /test/ng/compileSpec.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 'test/ng/compileSpec.js')
| -rwxr-xr-x | test/ng/compileSpec.js | 20 | 
1 files changed, 12 insertions, 8 deletions
| 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); | 
