You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mw...@apache.org on 2013/07/16 02:15:47 UTC
git commit: [CB-4261] Add and test success callbacks for plugin
commands.
Updated Branches:
refs/heads/master 261fd29a1 -> 1d9ade2e9
[CB-4261] Add and test success callbacks for plugin commands.
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/1d9ade2e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/1d9ade2e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/1d9ade2e
Branch: refs/heads/master
Commit: 1d9ade2e9e3bc2d32388fbf12b21181a98e39a62
Parents: 261fd29
Author: Michael Brooks <mi...@michaelbrooks.ca>
Authored: Mon Jul 15 17:15:37 2013 -0700
Committer: Michael Brooks <mi...@michaelbrooks.ca>
Committed: Mon Jul 15 17:15:37 2013 -0700
----------------------------------------------------------------------
spec/plugin.spec.js | 20 +++++++++++++++++++-
src/plugin.js | 2 ++
2 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/1d9ade2e/spec/plugin.spec.js
----------------------------------------------------------------------
diff --git a/spec/plugin.spec.js b/spec/plugin.spec.js
index ddd9b59..f20fd5d 100644
--- a/spec/plugin.spec.js
+++ b/spec/plugin.spec.js
@@ -105,7 +105,6 @@ describe('plugin command', function() {
});
cordova.plugin('list');
});
-
it('should list out added plugins in a project', function(done) {
cordova.on('results', function(res) {
expect(res).toEqual(sample_plugins);
@@ -113,6 +112,13 @@ describe('plugin command', function() {
});
cordova.plugin('list');
});
+ it('should trigger callback with list of plugins', function(done) {
+ cordova.plugin('list', [], function(e, plugins) {
+ expect(e).not.toBeDefined();
+ expect(plugins).toEqual(sample_plugins);
+ done();
+ });
+ });
});
describe('`add`', function() {
it('should call plugman.fetch for each plugin', function() {
@@ -129,6 +135,12 @@ describe('plugin command', function() {
});
});
});
+ it('should trigger callback without an error', function(done) {
+ cordova.plugin('add', sample_plugins, function(e) {
+ expect(e).not.toBeDefined();
+ done();
+ });
+ });
});
describe('`remove`',function() {
var plugin_parser;
@@ -157,6 +169,12 @@ describe('plugin command', function() {
cordova.plugin('rm', sample_plugins);
expect(uninstallPlugin.callCount).toBe(2);
});
+ it('should trigger callback without an error', function(done) {
+ cordova.plugin('rm', sample_plugins, function(e) {
+ expect(e).not.toBeDefined();
+ done();
+ });
+ });
});
});
describe('hooks', function() {
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/1d9ade2e/src/plugin.js
----------------------------------------------------------------------
diff --git a/src/plugin.js b/src/plugin.js
index a280277..839314f 100644
--- a/src/plugin.js
+++ b/src/plugin.js
@@ -172,6 +172,8 @@ module.exports = function plugin(command, targets, callback) {
if (err) {
if (callback) callback(err);
else throw err;
+ } else {
+ if (callback) callback(undefined, plugins);
}
});
}