You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2013/05/16 17:57:16 UTC

[17/20] git commit: added dependency module tests.

added dependency module tests.


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

Branch: refs/heads/master
Commit: 617d776aaacfcbaafcacf2eaa29b8557902051d4
Parents: 62492ab
Author: Fil Maj <ma...@gmail.com>
Authored: Wed May 15 18:32:19 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu May 16 08:55:43 2013 -0700

----------------------------------------------------------------------
 spec/util/dependencies.spec.js |   41 +++++++++++++++++++++++++++++++++++
 src/util/dependencies.js       |    3 +-
 2 files changed, 42 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/617d776a/spec/util/dependencies.spec.js
----------------------------------------------------------------------
diff --git a/spec/util/dependencies.spec.js b/spec/util/dependencies.spec.js
new file mode 100644
index 0000000..bbc7111
--- /dev/null
+++ b/spec/util/dependencies.spec.js
@@ -0,0 +1,41 @@
+var dependencies = require('../../src/util/dependencies'),
+    xml_helpers = require('../../src/util/xml-helpers'),
+    path = require('path'),
+    config = require('../../src/util/config-changes');
+
+describe('dependency module', function() {
+    describe('generate_dependency_info method', function() {
+        it('should return a list of top-level plugins based on what is inside a platform.json file', function() {
+            var tlps = {
+                "hello":"",
+                "isitme":"",
+                "yourelookingfor":""
+            };
+            spyOn(xml_helpers, 'parseElementtreeSync').andReturn({findall:function(){}});
+            var spy = spyOn(config, 'get_platform_json').andReturn({
+                installed_plugins:tlps,
+                dependent_plugins:[]
+            });
+            var obj = dependencies.generate_dependency_info('some dir');
+            expect(obj.top_level_plugins).toEqual(Object.keys(tlps));
+        });
+        it('should return a dependency graph for the plugins', function() {
+            var tlps = {
+                "A":"",
+                "B":""
+            };
+            var deps = {
+                "C":"",
+                "D":"",
+                "E":""
+            };
+            var spy = spyOn(config, 'get_platform_json').andReturn({
+                installed_plugins:tlps,
+                dependent_plugins:[]
+            });
+            var obj = dependencies.generate_dependency_info(path.join(__dirname, '..', 'plugins', 'dependencies'), 'android');
+            expect(obj.graph.getChain('A')).toEqual(['C','D']);
+            expect(obj.graph.getChain('B')).toEqual(['D', 'E']);
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/617d776a/src/util/dependencies.js
----------------------------------------------------------------------
diff --git a/src/util/dependencies.js b/src/util/dependencies.js
index ce77dbf..32e07eb 100644
--- a/src/util/dependencies.js
+++ b/src/util/dependencies.js
@@ -1,8 +1,7 @@
 var dep_graph = require('dep-graph'),
     path = require('path'),
     config_changes = require('./config-changes'),
-    xml_helpers = require('./xml-helpers'),
-    underscore= require('underscore');
+    xml_helpers = require('./xml-helpers');
 
 module.exports = {
     generate_dependency_info:function(plugins_dir, platform) {