Updated Branches:
  refs/heads/CB-4077 [created] cb4c49aeb

[CB-4077] Fix tests for cordova-cli


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

Branch: refs/heads/CB-4077
Commit: 88026614da80dca42a98414f724a5e743aa78abe
Parents: f577c4d
Author: Ian Clelland <[email protected]>
Authored: Mon Jul 8 14:08:58 2013 -0400
Committer: Ian Clelland <[email protected]>
Committed: Wed Jul 10 09:44:39 2013 -0400

----------------------------------------------------------------------
 spec/plugin.spec.js | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/88026614/spec/plugin.spec.js
----------------------------------------------------------------------
diff --git a/spec/plugin.spec.js b/spec/plugin.spec.js
index f340151..ddd9b59 100644
--- a/spec/plugin.spec.js
+++ b/spec/plugin.spec.js
@@ -33,7 +33,7 @@ var project_dir = path.join('some','path');
 var plugins_dir = path.join(project_dir, 'plugins');
 
 describe('plugin command', function() {
-    var is_cordova, list_platforms, fire, find_plugins, rm, mkdir, existsSync, 
exec, prep_spy, plugman_install, plugman_fetch, parsers = {}, uninstall;
+    var is_cordova, list_platforms, fire, find_plugins, rm, mkdir, existsSync, 
exec, prep_spy, plugman_install, plugman_fetch, parsers = {}, 
uninstallPlatform, uninstallPlugin;
     beforeEach(function() {
         is_cordova = spyOn(util, 'isCordova').andReturn(project_dir);
         fire = spyOn(hooker.prototype, 'fire').andCallFake(function(e, opts, 
cb) {
@@ -61,7 +61,10 @@ describe('plugin command', function() {
         });
         plugman_install = spyOn(plugman, 'install');
         plugman_fetch = spyOn(plugman, 'fetch').andCallFake(function(target, 
plugins_dir, opts, cb) { cb(false, path.join(plugins_dir, target)); });
-        uninstall = spyOn(plugman, 'uninstall');
+        uninstallPlatform = spyOn(plugman.uninstall, 'uninstallPlatform');
+        uninstallPlugin = spyOn(plugman.uninstall, 
'uninstallPlugin').andCallFake(function(target, plugins_dir, cb) {
+            cb && cb();
+        });
     });
 
     describe('failure', function() {
@@ -141,14 +144,19 @@ describe('plugin command', function() {
                 }).toThrow('Plugin "somethingrandom" not added to project.');
             });
 
-            it('should call plugman.uninstall for every matching 
installedplugin-supportedplatform pair', function() {
+            it('should call plugman.uninstall.uninstallPlatform for every 
matching installedplugin-supportedplatform pair', function() {
                 cordova.plugin('rm', sample_plugins);
                 sample_plugins.forEach(function(plug) {
                     subset.forEach(function(plat) {
-                        expect(uninstall).toHaveBeenCalledWith(plat, 
path.join(project_dir, 'platforms', plat), plug, plugins_dir, 
jasmine.any(Object));
+                        expect(uninstallPlatform).toHaveBeenCalledWith(plat, 
path.join(project_dir, 'platforms', plat), plug, plugins_dir, 
jasmine.any(Object));
                     });
                 });
             });
+            it('should call plugman.uninstall.uninstallPlugin once for every 
removed plugin', function() {
+                uninstallPlugin.reset();
+                cordova.plugin('rm', sample_plugins);
+                expect(uninstallPlugin.callCount).toBe(2);
+            });
         });
     });
     describe('hooks', function() {

Reply via email to