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/directive/ngRepeatSpec.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/directive/ngRepeatSpec.js')
| -rw-r--r-- | test/ng/directive/ngRepeatSpec.js | 60 | 
1 files changed, 36 insertions, 24 deletions
| diff --git a/test/ng/directive/ngRepeatSpec.js b/test/ng/directive/ngRepeatSpec.js index 638f082c..8bcb9283 100644 --- a/test/ng/directive/ngRepeatSpec.js +++ b/test/ng/directive/ngRepeatSpec.js @@ -1182,14 +1182,17 @@ describe('ngRepeat animations', function() {      $rootScope.items = ['1','2','3'];      $rootScope.$digest(); -    item = $animate.flushNext('enter').element; -    expect(item.text()).toBe('1'); +    item = $animate.queue.shift(); +    expect(item.event).toBe('enter'); +    expect(item.element.text()).toBe('1'); -    item = $animate.flushNext('enter').element; -    expect(item.text()).toBe('2'); +    item = $animate.queue.shift(); +    expect(item.event).toBe('enter'); +    expect(item.element.text()).toBe('2'); -    item = $animate.flushNext('enter').element; -    expect(item.text()).toBe('3'); +    item = $animate.queue.shift(); +    expect(item.event).toBe('enter'); +    expect(item.element.text()).toBe('3');    }));    it('should fire off the leave animation', @@ -1207,20 +1210,24 @@ describe('ngRepeat animations', function() {      $rootScope.items = ['1','2','3'];      $rootScope.$digest(); -    item = $animate.flushNext('enter').element; -    expect(item.text()).toBe('1'); +    item = $animate.queue.shift(); +    expect(item.event).toBe('enter'); +    expect(item.element.text()).toBe('1'); -    item = $animate.flushNext('enter').element; -    expect(item.text()).toBe('2'); +    item = $animate.queue.shift(); +    expect(item.event).toBe('enter'); +    expect(item.element.text()).toBe('2'); -    item = $animate.flushNext('enter').element; -    expect(item.text()).toBe('3'); +    item = $animate.queue.shift(); +    expect(item.event).toBe('enter'); +    expect(item.element.text()).toBe('3');      $rootScope.items = ['1','3'];      $rootScope.$digest(); -    item = $animate.flushNext('leave').element; -    expect(item.text()).toBe('2'); +    item = $animate.queue.shift(); +    expect(item.event).toBe('leave'); +    expect(item.element.text()).toBe('2');    }));    it('should fire off the move animation', @@ -1239,23 +1246,28 @@ describe('ngRepeat animations', function() {        $rootScope.items = ['1','2','3'];        $rootScope.$digest(); -      item = $animate.flushNext('enter').element; -      expect(item.text()).toBe('1'); +      item = $animate.queue.shift(); +      expect(item.event).toBe('enter'); +      expect(item.element.text()).toBe('1'); -      item = $animate.flushNext('enter').element; -      expect(item.text()).toBe('2'); +      item = $animate.queue.shift(); +      expect(item.event).toBe('enter'); +      expect(item.element.text()).toBe('2'); -      item = $animate.flushNext('enter').element; -      expect(item.text()).toBe('3'); +      item = $animate.queue.shift(); +      expect(item.event).toBe('enter'); +      expect(item.element.text()).toBe('3');        $rootScope.items = ['2','3','1'];        $rootScope.$digest(); -      item = $animate.flushNext('move').element; -      expect(item.text()).toBe('2'); +      item = $animate.queue.shift(); +      expect(item.event).toBe('move'); +      expect(item.element.text()).toBe('2'); -      item = $animate.flushNext('move').element; -      expect(item.text()).toBe('1'); +      item = $animate.queue.shift(); +      expect(item.event).toBe('move'); +      expect(item.element.text()).toBe('3');    }));  }); | 
