You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2013/03/04 20:32:51 UTC

[54/91] [abbrv] git commit: adding config.xml tests

adding config.xml 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/ad0129ce
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/ad0129ce
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/ad0129ce

Branch: refs/heads/master
Commit: ad0129ce1ba0d254372ee3f560a490da60350d35
Parents: 395f81c
Author: Anis Kadri <an...@gmail.com>
Authored: Thu Nov 29 15:31:31 2012 -0800
Committer: Anis Kadri <an...@gmail.com>
Committed: Thu Nov 29 15:31:31 2012 -0800

----------------------------------------------------------------------
 test/ios-install.js   |   25 ++++++++++++++++++++++++-
 test/ios-uninstall.js |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ad0129ce/test/ios-install.js
----------------------------------------------------------------------
diff --git a/test/ios-install.js b/test/ios-install.js
index c35819b..84f045e 100644
--- a/test/ios-install.js
+++ b/test/ios-install.js
@@ -44,7 +44,7 @@ exports['should install webless plugin'] = function (test) {
     // setting up a DummyPlugin
     var dummy_plugin_dir = path.join(test_dir, 'plugins', 'WeblessPlugin')
     var dummy_xml_path = path.join(test_dir, 'plugins', 'WeblessPlugin', 'plugin.xml')
-    dummy_plugin_et  = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
+    var dummy_plugin_et  = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
 
     ios.handlePlugin('install', test_project_dir, dummy_plugin_dir, dummy_plugin_et);
 
@@ -121,6 +121,29 @@ exports['should edit PhoneGap.plist'] = function (test) {
     test.done();
 }
 
+exports['should edit config.xml'] = function (test) {
+    // setting up WebNotification (with config.xml) 
+    var dummy_plugin_dir = path.join(test_dir, 'plugins', 'WebNotifications')
+    var dummy_xml_path = path.join(test_dir, 'plugins', 'WebNotifications', 'plugin.xml')
+    
+    // overriding some params
+    var project_dir = path.join(test_dir, 'projects', 'ios-config-xml')
+    var dummy_plugin_et  = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
+
+    // run the platform-specific function
+    ios.handlePlugin('install', project_dir, dummy_plugin_dir, dummy_plugin_et);
+    
+    var configXmlPath = path.join(project_dir, 'SampleApp', 'config.xml');
+    var pluginsTxt = fs.readFileSync(configXmlPath, 'utf-8'),
+        pluginsDoc = new et.ElementTree(et.XML(pluginsTxt)),
+        expected = 'plugins/plugin[@name="WebNotifications"]' +
+                    '[@value="WebNotifications"]';
+
+    test.ok(pluginsDoc.find(expected));
+
+    test.done();
+}
+
 exports['should edit the pbxproj file'] = function (test) {
     // run the platform-specific function
     ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ad0129ce/test/ios-uninstall.js
----------------------------------------------------------------------
diff --git a/test/ios-uninstall.js b/test/ios-uninstall.js
index c8fab48..e6a3e38 100644
--- a/test/ios-uninstall.js
+++ b/test/ios-uninstall.js
@@ -39,6 +39,19 @@ exports.tearDown = function(callback) {
     callback();
 }
 
+exports['should remove webless plugin'] = function (test) {
+    
+    // setting up a DummyPlugin
+    var dummy_plugin_dir = path.join(test_dir, 'plugins', 'WeblessPlugin')
+    var dummy_xml_path = path.join(test_dir, 'plugins', 'WeblessPlugin', 'plugin.xml')
+    var dummy_plugin_et  = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
+
+    ios.handlePlugin('install', test_project_dir, dummy_plugin_dir, dummy_plugin_et);
+    ios.handlePlugin('uninstall', test_project_dir, dummy_plugin_dir, dummy_plugin_et);
+
+    test.done();
+}
+
 exports['should remove the js file'] = function (test) {
     // run the platform-specific function
     ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
@@ -109,6 +122,31 @@ exports['should edit PhoneGap.plist'] = function (test) {
     test.done();
 }
 
+exports['should edit config.xml'] = function (test) {
+    // setting up WebNotification (with config.xml) 
+    var dummy_plugin_dir = path.join(test_dir, 'plugins', 'WebNotifications')
+    var dummy_xml_path = path.join(test_dir, 'plugins', 'WebNotifications', 'plugin.xml')
+    
+    // overriding some params
+    var project_dir = path.join(test_dir, 'projects', 'ios-config-xml')
+    var dummy_plugin_et  = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
+
+    // run the platform-specific function
+    ios.handlePlugin('install', project_dir, dummy_plugin_dir, dummy_plugin_et);
+    
+    ios.handlePlugin('uninstall', project_dir, dummy_plugin_dir, dummy_plugin_et);
+    
+    var configXmlPath = path.join(project_dir, 'SampleApp', 'config.xml');
+    var pluginsTxt = fs.readFileSync(configXmlPath, 'utf-8'),
+        pluginsDoc = new et.ElementTree(et.XML(pluginsTxt)),
+        expected = 'plugins/plugin[@name="WebNotifications"]' +
+                    '[@value="WebNotifications"]';
+
+    test.ok(!pluginsDoc.find(expected));
+
+    test.done();
+}
+
 exports['should edit the pbxproj file'] = function (test) {
     // run the platform-specific function
     ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);