cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject git commit: Added a spec for uninstalling dependencies.
Date Wed, 10 Jul 2013 03:59:22 GMT
Updated Branches:
  refs/heads/CB-4077 281dba805 -> e2ebbb865


Added a spec for uninstalling dependencies.


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

Branch: refs/heads/CB-4077
Commit: e2ebbb8655c590018b6068def11d334895190af3
Parents: 281dba8
Author: Fil Maj <maj.fil@gmail.com>
Authored: Tue Jul 9 20:59:08 2013 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Tue Jul 9 20:59:08 2013 -0700

----------------------------------------------------------------------
 spec/uninstall.spec.js | 50 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/e2ebbb86/spec/uninstall.spec.js
----------------------------------------------------------------------
diff --git a/spec/uninstall.spec.js b/spec/uninstall.spec.js
index 738e941..3c6a73e 100644
--- a/spec/uninstall.spec.js
+++ b/spec/uninstall.spec.js
@@ -1,6 +1,7 @@
 var uninstall = require('../src/uninstall'),
     actions = require('../src/util/action-stack'),
     config_changes = require('../src/util/config-changes'),
+    dependencies = require('../src/util/dependencies'),
     xml_helpers = require('../src/util/xml-helpers'),
     plugman = require('../plugman'),
     fs      = require('fs'),
@@ -17,6 +18,7 @@ var uninstall = require('../src/uninstall'),
 
 describe('uninstallPlatform', function() {
     var exists, get_json, chmod, exec, proc, add_to_queue, prepare, actions_push, c_a, rm;
+    var gen_deps, get_chain;
     beforeEach(function() {
         proc = spyOn(actions.prototype, 'process').andCallFake(function(platform, proj, cb)
{
             cb();
@@ -33,6 +35,13 @@ describe('uninstallPlatform', function() {
         });
         rm = spyOn(shell, 'rm');
         add_to_queue = spyOn(config_changes, 'add_uninstalled_plugin_to_prepare_queue');
+        dependents = jasmine.createSpy('getChain').andReturn([]),
+        gen_deps = spyOn(dependencies, 'generate_dependency_info').andReturn({
+            graph:{
+                getChain:dependents
+            },
+            top_level_plugins:[]
+        });
     });
     describe('success', function() {
         it('should call prepare after a successful uninstall', function() {
@@ -51,9 +60,46 @@ describe('uninstallPlatform', function() {
         });
 
         describe('with dependencies', function() {
-            it('should uninstall "dangling" dependencies', function() {
+            var uninstall_spy, parseET;
+            beforeEach(function() {
+                uninstall_spy = spyOn(uninstall, 'uninstallPlugin').andCallFake(function(id,
dir, cb) {
+                    cb();
+                });
+                parseET = spyOn(xml_helpers, 'parseElementtreeSync').andReturn({
+                    _root:{
+                        attrib:{}
+                    },
+                    find:function() { return null },
+                    findall:function() { return [] }
+                });
             });
-            it('should remove dangling dependent directories', function() {
+            it('should uninstall "dangling" dependencies', function() {
+                // TODO: this is a terrible way to do conditional mocking, i am sorry.
+                // if you have a better idea on how to mock out this recursive function,
plz patch it
+                var counter = 0;
+                gen_deps.andCallFake(function() {
+                    var obj;
+                    if (counter === 0) {
+                        counter++;
+                        obj = {
+                            graph:{
+                                getChain:function() { return ['one','two'] }
+                            },
+                            top_level_plugins:[]
+                        };
+                    } else {
+                        obj = {
+                            graph:{
+                                getChain:dependents
+                            },
+                            top_level_plugins:[]
+                        };
+                    }
+                    return obj;
+                });
+                uninstall.uninstallPlatform('android', temp, dummyplugin, plugins_dir, {});
+                expect(uninstall_spy).toHaveBeenCalledWith('one', plugins_dir, jasmine.any(Function));
+                expect(uninstall_spy).toHaveBeenCalledWith('two', plugins_dir, jasmine.any(Function));
             });
             it('should not uninstall any dependencies that are relied on by other plugins');
         });


Mime
View raw message