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:50 UTC
[80/91] [abbrv] git commit: tests for uninstall on bb10
tests for uninstall on bb10
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/6e16d968
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/6e16d968
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/6e16d968
Branch: refs/heads/master
Commit: 6e16d96824566e6f4e5a8901f384d943556b2814
Parents: f67d442
Author: Tim Kim <ti...@adobe.com>
Authored: Mon Feb 11 15:58:55 2013 -0800
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Feb 11 15:58:55 2013 -0800
----------------------------------------------------------------------
test/bb10-uninstall.js | 94 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 94 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/6e16d968/test/bb10-uninstall.js
----------------------------------------------------------------------
diff --git a/test/bb10-uninstall.js b/test/bb10-uninstall.js
new file mode 100644
index 0000000..b4fe1e2
--- /dev/null
+++ b/test/bb10-uninstall.js
@@ -0,0 +1,94 @@
+var fs = require('fs')
+ , path = require('path')
+ , shell = require('shelljs')
+ , et = require('elementtree')
+ , osenv = require('osenv')
+ , bb10 = require(path.join(__dirname, '..', 'platforms', 'bb10'))
+ , test_dir = path.join(osenv.tmpdir(), 'test_plugman')
+ , test_project_dir = path.join(test_dir, 'projects', 'BlackBerry10', 'www')
+ , test_plugin_dir = path.join(test_dir, 'plugins', 'cordova.echo')
+ , xml_path = path.join(test_dir, 'plugins', 'cordova.echo', 'plugin.xml')
+ , xml_text, plugin_et
+ , srcDir = path.resolve(test_project_dir, 'ext-qnx/cordova.echo');
+
+exports.setUp = function(callback) {
+ shell.mkdir('-p', test_dir);
+
+ // copy the bb10 test project to a temp directory
+ shell.cp('-r', path.join(__dirname, 'projects'), test_dir);
+
+ // copy the bb10 test plugin to a temp directory
+ shell.cp('-r', path.join(__dirname, 'plugins'), test_dir);
+
+ // parse the plugin.xml into an elementtree object
+ xml_text = fs.readFileSync(xml_path, 'utf-8')
+ plugin_et = new et.ElementTree(et.XML(xml_text));
+
+ callback();
+}
+
+exports.tearDown = function(callback) {
+ // remove the temp files (projects and plugins)
+ shell.rm('-rf', test_dir);
+ callback();
+}
+
+exports['should remove cordova echo plugin'] = function (test) {
+
+ // setting up a DummyPlugin
+ var dummy_plugin_dir = path.join(test_dir, 'plugins', 'cordova.echo')
+ var dummy_xml_path = path.join(test_dir, 'plugins', 'cordova.echo', 'plugin.xml')
+ var dummy_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
+
+ bb10.handlePlugin('install', test_project_dir, dummy_plugin_dir, dummy_plugin_et);
+ bb10.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);
+ ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+ var jsPath = path.join(test_dir, 'projects', 'ios', 'www', 'childbrowser.js');
+ test.ok(!fs.existsSync(jsPath))
+ test.done();
+}
+*/
+
+exports['should remove the source files'] = function (test) {
+ // run the platform-specific function
+ bb10.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+ bb10.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+ test.ok(!fs.existsSync(srcDir + '/index.js'))
+ test.ok(!fs.existsSync(srcDir + '/client.js'))
+ test.ok(!fs.existsSync(srcDir + '/manifest.json'))
+ test.ok(!fs.existsSync(srcDir + '/device/echoJnext.so'))
+ test.ok(!fs.existsSync(srcDir + '/simulator/echoJnext.so'))
+ test.done();
+}
+
+exports['should edit config.xml'] = function (test) {
+ // run the platform-specific function
+ bb10.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+
+ bb10.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+ var configXmlPath = path.join(test_project_dir, 'config.xml');
+ var pluginsTxt = fs.readFileSync(configXmlPath, 'utf-8'),
+ pluginsDoc = new et.ElementTree(et.XML(pluginsTxt)),
+ expected = 'feature[@id="cordova.echo"]';
+ test.ok(!pluginsDoc.find(expected));
+
+ test.done();
+}
+
+exports['should not uninstall a plugin that is not installed'] = function (test) {
+ test.throws(function(){bb10.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et); },
+ /not installed/
+ );
+ test.done();
+}