You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2013/04/24 00:02:37 UTC
git commit: refactored plugins tests and made a small fix to the
plugins.js
Updated Branches:
refs/heads/future c0de3de12 -> a0665733a
refactored plugins tests and made a small fix to the plugins.js
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/a0665733
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/a0665733
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/a0665733
Branch: refs/heads/future
Commit: a0665733af2b0f7ae2049ad7d0cdfd2eadcbadb0
Parents: c0de3de
Author: Tim Kim <ti...@adobe.com>
Authored: Tue Apr 23 15:02:11 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Tue Apr 23 15:02:26 2013 -0700
----------------------------------------------------------------------
spec/util/plugins.spec.js | 70 ++++++++++++++++------------------------
src/util/plugins.js | 2 +-
2 files changed, 29 insertions(+), 43 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a0665733/spec/util/plugins.spec.js
----------------------------------------------------------------------
diff --git a/spec/util/plugins.spec.js b/spec/util/plugins.spec.js
index 8990955..e028dc3 100644
--- a/spec/util/plugins.spec.js
+++ b/spec/util/plugins.spec.js
@@ -27,52 +27,38 @@ var http = require('http'),
describe('plugins', function(){
describe('server', function(){
- it('should be able to retrieve information for an existing plugin', function(done){
- plugins.getPluginInfo('ChildBrowser', function(error, plugin) {
- expect(error).toBe(null);
- expect(plugin).not.toBe(null);
- expect(plugin.url).toBe('https://github.com/imhotep/ChildBrowser');
- expect(plugin.name).toBe('ChildBrowser');
- expect(plugin.description).toBe('ChildBrowser plugin');
- done();
- });
+ it('should receive the correct request when searching for a plugin', function(){
+ var mySpy = spyOn(http, 'get').andCallThrough();
+ // this clears the timeout in plugins.js
+ var spyTimeout = spyOn(global, 'setTimeout');
+
+ plugins.getPluginInfo('ChildBrowser', function() {});
+
+ expect(mySpy).toHaveBeenCalled();
+ expect(mySpy.argsForCall[0][0]).toBe('http://plugins.cordova.io/cordova_plugins/_design/cordova_plugins/_view/by_name?key="ChildBrowser"');
});
-
- it('should error if searching for a non-existant plugin', function(done){
- plugins.getPluginInfo('MEAT_POPSICLE', function(error, plugin) {
- expect(error).not.toBe(null);
- expect(error).toBe('Could not find information on MEAT_POPSICLE plugin');
- done();
- });
- });
-
- it('should list all plugins', function(done){
- plugins.listAllPlugins(function(plugin){
- expect(plugin).not.toBe(null);
- expect(plugin.length).toBeGreaterThan(0);
- done();
- });
+
+ it('should receive the correct request when searching for a list of plugins', function(){
+ var mySpy = spyOn(http, 'get').andCallThrough();
+ // this clears the timeout in plugins.js
+ var spyTimeout = spyOn(global, 'setTimeout');
+
+ plugins.listAllPlugins(function(){});
+
+ expect(mySpy).toHaveBeenCalled();
+ expect(mySpy.argsForCall[0][0]).toBe('http://plugins.cordova.io/cordova_plugins/_design/cordova_plugins/_view/by_name');
});
- it('should be able to clone to local from url', function(done){
- plugins.getPluginInfo('ChildBrowser', function(error, plugin) {
- shell.mkdir('-p', temp);
- plugins.clonePluginGitRepo(plugin.url, temp, function(error){
- expect(error).toBe(null);
- done();
- });
- shell.rm('-rf', temp);
- });
+ it('should be able to receive the correct git clone arguments', function(){
+ var mySpy = spyOn(plugins, 'clonePluginGitRepo');
+ var plugin_git_url = 'https://github.com/imhotep/ChildBrowser'
+ var myFunction = function(){};
+
+ plugins.clonePluginGitRepo(plugin_git_url, temp, myFunction);
+
+ expect(mySpy).toHaveBeenCalled();
+ expect(mySpy).toHaveBeenCalledWith(plugin_git_url, temp, myFunction);
});
-
- it('should error if cloning a non-existant plugin', function(done){
- shell.mkdir('-p', temp);
- plugins.clonePluginGitRepo('MEAT_POPSICLE', temp, function(error){
- expect(error).not.toBe(null);
- done();
- });
- shell.rm('-rf', temp);
- });
});
});
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a0665733/src/util/plugins.js
----------------------------------------------------------------------
diff --git a/src/util/plugins.js b/src/util/plugins.js
index 045f48c..1ad4936 100644
--- a/src/util/plugins.js
+++ b/src/util/plugins.js
@@ -54,7 +54,7 @@ module.exports = {
setTimeout(function() {
if (!responded) {
console.log('timed out');
- error('timed out')
+ callback('timed out')
}
}, 3000);
},