cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject git commit: added tests for action-stack
Date Thu, 16 May 2013 01:06:14 GMT
Updated Branches:
  refs/heads/dependencies 5b8c49a93 -> adec7ca7e


added tests for action-stack


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/adec7ca7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/adec7ca7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/adec7ca7

Branch: refs/heads/dependencies
Commit: adec7ca7eab8ed134cb84282881efabc691a7cb5
Parents: 5b8c49a
Author: Fil Maj <maj.fil@gmail.com>
Authored: Wed May 15 18:06:09 2013 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Wed May 15 18:06:09 2013 -0700

----------------------------------------------------------------------
 spec/util/action-stack.spec.js |   52 +++++++++++++++++++++++++++++++++++
 src/util/action-stack.js       |    2 +-
 2 files changed, 53 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/adec7ca7/spec/util/action-stack.spec.js
----------------------------------------------------------------------
diff --git a/spec/util/action-stack.spec.js b/spec/util/action-stack.spec.js
new file mode 100644
index 0000000..b258a32
--- /dev/null
+++ b/spec/util/action-stack.spec.js
@@ -0,0 +1,52 @@
+var action_stack = require('../../src/util/action-stack'),
+    ios = require('../../src/platforms/ios');
+
+describe('action-stack', function() {
+    var stack;
+    beforeEach(function() {
+        stack = new action_stack();
+    });
+    describe('processing of actions', function() {
+        it('should process actions one at a time until all are done', function() {
+            var first_spy = jasmine.createSpy();
+            var first_args = [1];
+            var second_spy = jasmine.createSpy();
+            var second_args = [2];
+            var third_spy = jasmine.createSpy();
+            var third_args = [3];
+            stack.push(stack.createAction(first_spy, first_args, function(){}, []));
+            stack.push(stack.createAction(second_spy, second_args, function(){}, []));
+            stack.push(stack.createAction(third_spy, third_args, function(){}, []));
+            stack.process('android', 'blah');
+            expect(first_spy).toHaveBeenCalledWith(first_args[0]);
+            expect(second_spy).toHaveBeenCalledWith(second_args[0]);
+            expect(third_spy).toHaveBeenCalledWith(third_args[0]);
+        });
+        it('should revert processed actions if an exception occurs', function() {
+            var first_spy = jasmine.createSpy();
+            var first_args = [1];
+            var first_reverter = jasmine.createSpy();
+            var first_reverter_args = [true];
+            var process_err = 'quit peein\' on my rug, man.';
+            var second_spy = jasmine.createSpy().andCallFake(function() {
+                throw new Error(process_err);
+            });
+            var second_args = [2];
+            var third_spy = jasmine.createSpy();
+            var third_args = [3];
+            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
+            expect(function() {
+                stack.process('android', 'blah');
+            }).toThrow('Uh oh!\n' + process_err);
+            // first two actions should have been called, but not the third
+            expect(first_spy).toHaveBeenCalledWith(first_args[0]);
+            expect(second_spy).toHaveBeenCalledWith(second_args[0]);
+            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]);
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/adec7ca7/src/util/action-stack.js
----------------------------------------------------------------------
diff --git a/src/util/action-stack.js b/src/util/action-stack.js
index 115c6b7..886ff21 100644
--- a/src/util/action-stack.js
+++ b/src/util/action-stack.js
@@ -24,7 +24,7 @@ ActionStack.prototype = {
     },
     process:function(platform, project_dir, callback) {
         if (platform == 'ios') {
-            // parse xcode project file once
+            // parse xcode project files once
             var project_files = ios.parseIOSProjectFiles(project_dir);
         }
         while(this.stack.length) {


Mime
View raw message