cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [4/6] git commit: [CB-4077] Fix tests for cordova-cli, properly uninstall plugin source
Date Wed, 10 Jul 2013 18:03:24 GMT
[CB-4077] Fix tests for cordova-cli, properly uninstall plugin source


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

Branch: refs/heads/master
Commit: 859e275d3e0fb0bf1c25a7b4752a6f0f506aff8e
Parents: 21a102c
Author: Ian Clelland <iclelland@chromium.org>
Authored: Mon Jul 8 14:26:40 2013 -0400
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Wed Jul 10 11:01:28 2013 -0700

----------------------------------------------------------------------
 spec/uninstall.spec.js | 96 ++++++++++++++++++++++++++++++++++++++++++++-
 src/uninstall.js       |  2 +-
 2 files changed, 95 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/859e275d/spec/uninstall.spec.js
----------------------------------------------------------------------
diff --git a/spec/uninstall.spec.js b/spec/uninstall.spec.js
index 61e1c81..aca4e7c 100644
--- a/spec/uninstall.spec.js
+++ b/spec/uninstall.spec.js
@@ -15,6 +15,98 @@ var uninstall = require('../src/uninstall'),
     engineplugin = 'EnginePlugin',
     plugins_dir = path.join(temp, 'plugins');
 
+describe('uninstallPlatform', function() {
+    var exists, get_json, chmod, exec, proc, add_to_queue, prepare, actions_push, c_a, rm;
+    beforeEach(function() {
+        proc = spyOn(actions.prototype, 'process').andCallFake(function(platform, proj, cb)
{
+            cb();
+        });
+        actions_push = spyOn(actions.prototype, 'push');
+        c_a = spyOn(actions.prototype, 'createAction');
+        prepare = spyOn(plugman, 'prepare');
+        exec = spyOn(shell, 'exec').andReturn({code:1});
+        chmod = spyOn(fs, 'chmodSync');
+        exists = spyOn(fs, 'existsSync').andReturn(true);
+        get_json = spyOn(config_changes, 'get_platform_json').andReturn({
+            installed_plugins:{},
+            dependent_plugins:{}
+        });
+        rm = spyOn(shell, 'rm');
+        add_to_queue = spyOn(config_changes, 'add_uninstalled_plugin_to_prepare_queue');
+    });
+    describe('success', function() {
+        it('should call prepare after a successful uninstall', function() {
+            uninstall.uninstallPlatform('android', temp, dummyplugin, plugins_dir, {});
+            expect(prepare).toHaveBeenCalled();
+        });
+        it('should call the config-changes module\'s add_uninstalled_plugin_to_prepare_queue
method after processing an install', function() {
+            uninstall.uninstallPlatform('android', temp, dummyplugin, plugins_dir, {});
+            expect(add_to_queue).toHaveBeenCalledWith(plugins_dir, 'DummyPlugin', 'android',
true);
+        });
+        it('should queue up actions as appropriate for that plugin and call process on the
action stack', function() {
+            uninstall.uninstallPlatform('android', temp, dummyplugin, plugins_dir, {});
+            expect(actions_push.calls.length).toEqual(3);
+            expect(c_a).toHaveBeenCalledWith(jasmine.any(Function), [jasmine.any(Object),
temp, dummy_id], jasmine.any(Function), [jasmine.any(Object), path.join(plugins_dir, dummyplugin),
temp, dummy_id]);
+            expect(proc).toHaveBeenCalled();
+        });
+
+        describe('with dependencies', function() {
+            it('should uninstall "dangling" dependencies');
+            it('should not uninstall any dependencies that are relied on by other plugins');
+        });
+    });
+
+    describe('failure', function() {
+        it('should throw if platform is unrecognized', function() {
+            expect(function() {
+                uninstall.uninstallPlatform('atari', temp, 'SomePlugin', plugins_dir, {});
+            }).toThrow('atari not supported.');
+        });
+        it('should throw if plugin is missing', function() {
+            exists.andReturn(false);
+            expect(function() {
+                uninstall.uninstallPlatform('android', temp, 'SomePluginThatDoesntExist',
plugins_dir, {});
+            }).toThrow('Plugin "SomePluginThatDoesntExist" not found. Already uninstalled?');
+        });
+    });
+});
+
+describe('uninstallPlugin', function() {
+    var exists, get_json, chmod, exec, proc, add_to_queue, prepare, actions_push, c_a, rm;
+    beforeEach(function() {
+        proc = spyOn(actions.prototype, 'process').andCallFake(function(platform, proj, cb)
{
+            cb();
+        });
+        actions_push = spyOn(actions.prototype, 'push');
+        c_a = spyOn(actions.prototype, 'createAction');
+        prepare = spyOn(plugman, 'prepare');
+        exec = spyOn(shell, 'exec').andReturn({code:1});
+        chmod = spyOn(fs, 'chmodSync');
+        exists = spyOn(fs, 'existsSync').andReturn(true);
+        get_json = spyOn(config_changes, 'get_platform_json').andReturn({
+            installed_plugins:{},
+            dependent_plugins:{}
+        });
+        rm = spyOn(shell, 'rm');
+        add_to_queue = spyOn(config_changes, 'add_uninstalled_plugin_to_prepare_queue');
+    });
+    describe('success', function() {
+        it('should remove the plugin directory', function() {
+            uninstall.uninstallPlugin(dummyplugin, plugins_dir);
+            expect(rm).toHaveBeenCalled();
+        });
+    });
+
+    describe('failure', function() {
+        it('should throw if plugin is missing', function() {
+            exists.andReturn(false);
+            expect(function() {
+                uninstall('android', temp, 'SomePluginThatDoesntExist', plugins_dir, {});
+            }).toThrow('Plugin "SomePluginThatDoesntExist" not found. Already uninstalled?');
+        });
+    });
+});
+
 describe('uninstall', function() {
     var exists, get_json, chmod, exec, proc, add_to_queue, prepare, actions_push, c_a, rm;
     beforeEach(function() {
@@ -52,10 +144,10 @@ describe('uninstall', function() {
 
         describe('with dependencies', function() {
             it('should uninstall "dangling" dependencies');
-            it('should not uninstall any dependencies that are relied on by other plugins');

+            it('should not uninstall any dependencies that are relied on by other plugins');
         });
     });
-    
+
     describe('failure', function() {
         it('should throw if platform is unrecognized', function() {
             expect(function() {

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/859e275d/src/uninstall.js
----------------------------------------------------------------------
diff --git a/src/uninstall.js b/src/uninstall.js
index 8728711..6d59e84 100644
--- a/src/uninstall.js
+++ b/src/uninstall.js
@@ -17,7 +17,7 @@ module.exports = function(platform, project_dir, id, plugins_dir, options,
callb
             if (callback) return callback(err);
             else throw err;
         }
-        module.exports.uninstallPlugin(id, plugins_dir, options, callback);
+        module.exports.uninstallPlugin(id, plugins_dir, callback);
     });
 }
 


Mime
View raw message