incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [14/78] [abbrv] git commit: todos, callback for plugin module, moar tests.
Date Fri, 27 Jul 2012 00:29:15 GMT
todos, callback for plugin module, moar tests.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/commit/85a094e0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/tree/85a094e0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/diff/85a094e0

Branch: refs/heads/cordova-client
Commit: 85a094e06609482db156bb34b6743bc5b6aeab17
Parents: 650af9f
Author: Fil Maj <maj.fil@gmail.com>
Authored: Tue Jul 24 13:04:04 2012 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Tue Jul 24 13:04:04 2012 -0700

----------------------------------------------------------------------
 spec/fixtures/plugins/test/plugin.xml |   11 +++
 spec/plugin.spec.js                   |  124 ++++++++++++++++++++++++++++
 src/platform.js                       |    7 ++
 src/plugin.js                         |    4 +-
 4 files changed, 144 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/85a094e0/spec/build.spec.js
----------------------------------------------------------------------
diff --git a/spec/build.spec.js b/spec/build.spec.js
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/85a094e0/spec/emulate.spec.js
----------------------------------------------------------------------
diff --git a/spec/emulate.spec.js b/spec/emulate.spec.js
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/85a094e0/spec/fixtures/plugins/test/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/fixtures/plugins/test/plugin.xml b/spec/fixtures/plugins/test/plugin.xml
new file mode 100644
index 0000000..ed33b8a
--- /dev/null
+++ b/spec/fixtures/plugins/test/plugin.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    id="com.phonegap.plugins.childbrowser"
+    version="3.0.0">
+
+    <name>Test Plugin</name>
+
+    <asset src="www/test.js" target="test.js" />
+</plugin>
+

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/85a094e0/spec/fixtures/plugins/test/www/test.js
----------------------------------------------------------------------
diff --git a/spec/fixtures/plugins/test/www/test.js b/spec/fixtures/plugins/test/www/test.js
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/85a094e0/spec/plugin.spec.js
----------------------------------------------------------------------
diff --git a/spec/plugin.spec.js b/spec/plugin.spec.js
new file mode 100644
index 0000000..5085636
--- /dev/null
+++ b/spec/plugin.spec.js
@@ -0,0 +1,124 @@
+var cordova = require('../cordova'),
+    wrench = require('wrench'),
+    mkdirp = wrench.mkdirSyncRecursive,
+    path = require('path'),
+    rmrf = wrench.rmdirSyncRecursive,
+    fs = require('fs'),
+    tempDir = path.join(__dirname, '..', 'temp'),
+    fixturesDir = path.join(__dirname, 'fixtures'),
+    testPlugin = path.join(fixturesDir, 'plugins', 'test');
+
+describe('plugin command', function() {
+    beforeEach(function() {
+        // Make a temp directory
+        try { rmrf(tempDir); } catch(e) {}
+        mkdirp(tempDir);
+    });
+
+    it('should run inside a Cordova-based project', function() {
+        var cwd = process.cwd();
+        this.after(function() {
+            process.chdir(cwd);
+        });
+
+        cordova.create(tempDir);
+
+        process.chdir(tempDir);
+
+        expect(function() {
+            cordova.plugin();
+        }).not.toThrow();
+    });
+    it('should not run outside of a Cordova-based project', function() {
+        var cwd = process.cwd();
+        this.after(function() {
+            process.chdir(cwd);
+        });
+
+        process.chdir(tempDir);
+
+        expect(function() {
+            cordova.plugin();
+        }).toThrow();
+    });
+
+    describe('ls', function() {
+        var cwd = process.cwd();
+
+        beforeEach(function() {
+            cordova.create(tempDir);
+        });
+
+        afterEach(function() {
+            process.chdir(cwd);
+        });
+
+        it('should list out no plugins for a fresh project', function() {
+            process.chdir(tempDir);
+
+            expect(cordova.plugin('ls')).toEqual('No plugins added. Use `cordova plugin add
<plugin>`.');
+        });
+
+        it('should list out added plugins in a project', function() {
+            var cb = jasmine.createSpy().andCallFake(function() {
+                expect(cordova.plugin('ls')).toEqual('android');
+            });
+
+            process.chdir(tempDir);
+            runs(function() {
+                cordova.plugin('add', '', cb);
+            });
+            waitsFor(function() { return cb.wasCalled; }, "create callback", 17500);
+        });
+    });
+
+    describe('add', function() {
+        var cwd = process.cwd();
+
+        beforeEach(function() {
+            cordova.create(tempDir);
+        });
+
+        afterEach(function() {
+            process.chdir(cwd);
+        });
+
+        it('should add a supported platform', function() {
+            var cb = jasmine.createSpy().andCallFake(function() {
+                expect(cordova.platform('ls')).toEqual('android');
+            });
+
+            process.chdir(tempDir);
+            runs(function() {
+                cordova.platform('add', 'android', cb);
+            });
+            waitsFor(function() { return cb.wasCalled; }, "create callback", 17500);
+        });
+    });
+
+    describe('remove', function() {
+        var cwd = process.cwd();
+
+        beforeEach(function() {
+            cordova.create(tempDir);
+        });
+
+        afterEach(function() {
+            process.chdir(cwd);
+        });
+
+        it('should remove a supported and added platform', function() {
+            var cb = jasmine.createSpy().andCallFake(function() {
+                cordova.platform('remove', 'android');
+                expect(cordova.platform('ls')).toEqual('No platforms added. Use `cordova
platform add <platform>`.');
+            });
+
+            process.chdir(tempDir);
+            runs(function() {
+                cordova.platform('add', 'android', cb);
+            });
+            waitsFor(function() { return cb.wasCalled; }, "create callback", 17500);
+        });
+    });
+});
+

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/85a094e0/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index 16da06b..6e09f42 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -64,6 +64,13 @@ module.exports = function platform(command, target, callback) {
                 // Shell out to git.
                 var outPath = path.join(__dirname, '..', 'lib', target);
                 var cmd = util.format('git clone %s %s', repos[target], outPath);
+                
+                // TODO: refactor post-clone hooks
+                // make sure we run "make install" if we're cloning ios
+                if (target == 'ios') {
+                    cmd += ' && cd "' + output + '" && make install';
+                }
+
                 console.log('Cloning ' + repos[target] + ', this may take a while...');
                 exec(cmd, function(err, stderr, stdout) {
                     if (err) {

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/85a094e0/src/plugin.js
----------------------------------------------------------------------
diff --git a/src/plugin.js b/src/plugin.js
index 8e77d3b..8f54bff 100644
--- a/src/plugin.js
+++ b/src/plugin.js
@@ -8,7 +8,7 @@ var cordova_util = require('./util'),
     exec = require('child_process').exec,
     ls = fs.readdirSync;
 
-module.exports = function plugin(command, target) {
+module.exports = function plugin(command, target, callback) {
     var projectRoot = cordova_util.isCordova(process.cwd());
 
     if (!projectRoot) {
@@ -32,7 +32,7 @@ module.exports = function plugin(command, target) {
         case 'ls':
             if (plugins.length) {
                 return plugins.join('\n');
-            } else return 'No plugins added. Use `cordova plugin add <plugin>.';
+            } else return 'No plugins added. Use `cordova plugin add <plugin>`.';
             break;
         case 'add':
             // Check if we already have the plugin.


Mime
View raw message