You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ra...@apache.org on 2019/06/18 01:20:26 UTC
[cordova-common] 01/04: Proper expected rejection check in
ActionStack spec
This is an automated email from the ASF dual-hosted git repository.
raphinesse pushed a commit to branch clean-spec-promises
in repository https://gitbox.apache.org/repos/asf/cordova-common.git
commit 0c121bb651f1c464568d9c0f8ca049996539664b
Author: Raphael von der GrĂ¼n <ra...@gmail.com>
AuthorDate: Tue Jun 18 01:55:52 2019 +0200
Proper expected rejection check in ActionStack spec
---
spec/ActionStack.spec.js | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/spec/ActionStack.spec.js b/spec/ActionStack.spec.js
index 44df820..496d73b 100644
--- a/spec/ActionStack.spec.js
+++ b/spec/ActionStack.spec.js
@@ -41,7 +41,7 @@ describe('action-stack', function () {
expect(second_spy).toHaveBeenCalledWith(second_args[0]);
expect(third_spy).toHaveBeenCalledWith(third_args[0]);
});
- it('Test 002 : should revert processed actions if an exception occurs', function (done) {
+ it('Test 002 : should revert processed actions if an exception occurs', function () {
spyOn(console, 'log');
var first_spy = jasmine.createSpy();
var first_args = [1];
@@ -57,13 +57,12 @@ describe('action-stack', function () {
stack.push(stack.createAction(first_spy, first_args, first_reverter, first_reverter_args));
stack.push(stack.createAction(second_spy, second_args, function () {}, []));
stack.push(stack.createAction(third_spy, third_args, function () {}, []));
+
// process should throw
- var error;
- stack.process('android', android_one_project)
- .then(function () {
- expect(false).toBe(true);
- }).fail(function (err) {
- error = err;
+ return stack.process('android', android_one_project)
+ .then(() => {
+ fail('Expected promise to be rejected');
+ }, error => {
expect(error).toEqual(process_err);
// first two actions should have been called, but not the third
expect(first_spy).toHaveBeenCalledWith(first_args[0]);
@@ -71,7 +70,7 @@ describe('action-stack', function () {
expect(third_spy).not.toHaveBeenCalledWith(third_args[0]);
// first reverter should have been called after second action exploded
expect(first_reverter).toHaveBeenCalledWith(first_reverter_args[0]);
- }).fin(done);
+ });
});
});
});
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org