aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/directive/ngShowHideSpec.js
diff options
context:
space:
mode:
authorMatias Niemelä2014-01-22 19:21:05 -0500
committerMatias Niemelä2014-02-06 01:21:41 -0500
commit906fdad0f95465842e336e057ea97d0633712189 (patch)
tree0993034fe2ce43ad090203c7d2390662536d1d91 /test/ng/directive/ngShowHideSpec.js
parenta8c1d9c97804f7df98150456c2702fd39e3a22f0 (diff)
downloadangular.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/ngShowHideSpec.js')
-rw-r--r--test/ng/directive/ngShowHideSpec.js28
1 files changed, 16 insertions, 12 deletions
diff --git a/test/ng/directive/ngShowHideSpec.js b/test/ng/directive/ngShowHideSpec.js
index 30397c4c..8a25843c 100644
--- a/test/ng/directive/ngShowHideSpec.js
+++ b/test/ng/directive/ngShowHideSpec.js
@@ -91,16 +91,18 @@ describe('ngShow / ngHide animations', function() {
))($scope);
$scope.$digest();
- item = $animate.flushNext('removeClass').element;
- expect(item.text()).toBe('data');
- expect(item).toBeShown();
+ item = $animate.queue.shift();
+ expect(item.event).toBe('removeClass');
+ expect(item.element.text()).toBe('data');
+ expect(item.element).toBeShown();
$scope.on = false;
$scope.$digest();
- item = $animate.flushNext('addClass').element;
- expect(item.text()).toBe('data');
- expect(item).toBeHidden();
+ item = $animate.queue.shift();
+ expect(item.event).toBe('addClass');
+ expect(item.element.text()).toBe('data');
+ expect(item.element).toBeHidden();
}));
});
@@ -114,16 +116,18 @@ describe('ngShow / ngHide animations', function() {
))($scope);
$scope.$digest();
- item = $animate.flushNext('addClass').element;
- expect(item.text()).toBe('datum');
- expect(item).toBeHidden();
+ item = $animate.queue.shift();
+ expect(item.event).toBe('addClass');
+ expect(item.element.text()).toBe('datum');
+ expect(item.element).toBeHidden();
$scope.off = false;
$scope.$digest();
- item = $animate.flushNext('removeClass').element;
- expect(item.text()).toBe('datum');
- expect(item).toBeShown();
+ item = $animate.queue.shift();
+ expect(item.event).toBe('removeClass');
+ expect(item.element.text()).toBe('datum');
+ expect(item.element).toBeShown();
}));
});
});