You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mm...@apache.org on 2013/11/27 19:33:15 UTC
[10/12] git commit: Add plugin test
Add plugin test
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/37a782c2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/37a782c2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/37a782c2
Branch: refs/heads/master
Commit: 37a782c2eeb01c70d173def2b9b82473b5eb5c7e
Parents: c4fe519
Author: Mark Koudritsky <ka...@gmail.com>
Authored: Sun Nov 17 23:13:07 2013 -0500
Committer: Mark Koudritsky <ka...@gmail.com>
Committed: Sun Nov 17 23:13:07 2013 -0500
----------------------------------------------------------------------
e2e/fixtures/plugins/fake1/plugin.xml | 10 +++++
e2e/plugin.spec.js | 67 ++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/37a782c2/e2e/fixtures/plugins/fake1/plugin.xml
----------------------------------------------------------------------
diff --git a/e2e/fixtures/plugins/fake1/plugin.xml b/e2e/fixtures/plugins/fake1/plugin.xml
new file mode 100644
index 0000000..ffdc650
--- /dev/null
+++ b/e2e/fixtures/plugins/fake1/plugin.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
+ id="org.apache.cordova.fakeplugin1"
+ version="0.1.0-dev">
+ <name>Fake1</name>
+ <description>Cordova fake plugin for tests</description>
+ <license>Apache 2.0</license>
+ <keywords>cordova,cli,test</keywords>
+</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/37a782c2/e2e/plugin.spec.js
----------------------------------------------------------------------
diff --git a/e2e/plugin.spec.js b/e2e/plugin.spec.js
index e69de29..f07b1d2 100644
--- a/e2e/plugin.spec.js
+++ b/e2e/plugin.spec.js
@@ -0,0 +1,67 @@
+
+var helpers = require('./helpers'),
+ path = require('path'),
+ fs = require('fs'),
+ shell = require('shelljs'),
+ Q = require('q'),
+ events = require('../src/events'),
+ cordova = require('../cordova');
+
+var tmpDir = helpers.tmpDir();
+var project = path.join(tmpDir, 'project');
+var pluginsDir = path.join(__dirname, 'fixtures', 'plugins');
+var pluginId = 'org.apache.cordova.fakeplugin1';
+
+describe('plugin end-to-end', function() {
+ var results;
+
+ beforeEach(function() {
+ shell.rm('-rf', project);
+ });
+ afterEach(function() {
+ //shell.rm('-rf', project);
+ });
+
+ // The flow tested is: ls, add, ls, rm, ls.
+ // Plugin dependencies are not tested as that should be corvered in plugman tests.
+ // TODO (kamrik): Test the 'plugin search' command.
+ it('should successfully run', function(done) {
+ // cp then mv because we need to copy everything, but that means it'll copy the whole directory.
+ // Using /* doesn't work because of hidden files.
+ shell.cp('-R', path.join(__dirname, 'fixtures', 'base'), tmpDir);
+ shell.mv(path.join(tmpDir, 'base'), project);
+ // Copy some platform to avoid working on a project with no platforms.
+ shell.cp('-R', path.join(__dirname, 'fixtures', 'platforms', helpers.testPlatform), path.join(project, 'platforms'));
+ process.chdir(project);
+
+ events.on('results', function(res) { results = res; });
+
+ // Check there are no plugins yet.
+ cordova.raw.plugin('list').then(function() {
+ expect(results).toMatch(/No plugins added/gi);
+ }).then(function() {
+ // Add a fake plugin from fixtures.
+ return cordova.raw.plugin('add', path.join(pluginsDir, 'fake1'));
+ }).then(function() {
+ expect(path.join(project, 'plugins', pluginId, 'plugin.xml')).toExist();
+ }).then(function() {
+ return cordova.raw.plugin('ls');
+ }).then(function() {
+ expect(results).toContain(pluginId);
+ expect(results.length).toEqual(1);
+ }).then(function() {
+ // And now remove it.
+ return cordova.raw.plugin('rm', pluginId);
+ }).then(function() {
+ // The whole dir should be gone.
+ expect(path.join(project, 'plugins', pluginId)).not.toExist();
+ }).then(function() {
+ return cordova.raw.plugin('ls');
+ }).then(function() {
+ expect(results).toMatch(/No plugins added/gi);
+ }).fail(function(err) {
+ console.log(err);
+ expect(err).toBeUndefined();
+ }).fin(done);
+ });
+});