You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ka...@apache.org on 2014/05/02 20:29:58 UTC
[23/70] Split out cordova-lib: move cordova-plugman files
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0318d8cd/spec/adduser.spec.js
----------------------------------------------------------------------
diff --git a/spec/adduser.spec.js b/spec/adduser.spec.js
deleted file mode 100644
index 48b1281..0000000
--- a/spec/adduser.spec.js
+++ /dev/null
@@ -1,11 +0,0 @@
-var adduser = require('../src/adduser'),
- Q = require('q'),
- registry = require('../src/registry/registry');
-
-describe('adduser', function() {
- it('should add a user', function() {
- var sAddUser = spyOn(registry, 'adduser').andReturn(Q());
- adduser();
- expect(sAddUser).toHaveBeenCalled();
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0318d8cd/spec/common.js
----------------------------------------------------------------------
diff --git a/spec/common.js b/spec/common.js
deleted file mode 100644
index b71efbf..0000000
--- a/spec/common.js
+++ /dev/null
@@ -1,62 +0,0 @@
-
-var plugman = require('../plugman'),
- nopt = require('nopt');
-
-var known_opts = {
- 'verbose' : Boolean,
- 'debug' : Number
-}, shortHands = { 'd' : ['--debug'] };
-
-var opt = nopt(known_opts, shortHands);
-var mapNames = {
- 'verbose' : 7,
- 'info' : 6,
- 'notice' : 5,
- 'warn' : 4,
- 'error' : 3
-}
-
-if(opt.verbose)
- opt.debug = 7;
-
-if(opt.debug) {
- for(var i in mapNames) {
- if(mapNames[i] <= opt.debug)
- plugman.on(i, console.log);
- }
-
- if(opt.debug >= 6)
- plugman.on('log', console.log);
-}
-
-module.exports = common = {
- spy: {
- getInstall: function(emitSpy){
- return common.spy.startsWith(emitSpy, 'Install start');
- },
-
- getDeleted: function(emitSpy){
- return common.spy.startsWith(emitSpy, 'Deleted');
- },
-
- startsWith: function(emitSpy, string)
- {
- var match = [], i;
- for(i in emitSpy.argsForCall) {
- if(emitSpy.argsForCall[i][1].substr(0, string.length) === string)
- match.push(emitSpy.argsForCall[i][1]);
- }
- return match;
- },
-
- contains: function(emitSpy, string)
- {
- var match = [], i;
- for(i in emitSpy.argsForCall) {
- if(emitSpy.argsForCall[i][1].indexOf(string) >= 0)
- match.push(emitSpy.argsForCall[i][1]);
- }
- return match;
- }
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0318d8cd/spec/config.spec.js
----------------------------------------------------------------------
diff --git a/spec/config.spec.js b/spec/config.spec.js
deleted file mode 100644
index 65addbf..0000000
--- a/spec/config.spec.js
+++ /dev/null
@@ -1,12 +0,0 @@
-var config = require('../src/config'),
- Q = require('q'),
- registry = require('../src/registry/registry');
-
-describe('config', function() {
- it('should run config', function() {
- var sConfig = spyOn(registry, 'config').andReturn(Q());
- var params = ['set', 'registry', 'http://registry.cordova.io'];
- config(params);
- expect(sConfig).toHaveBeenCalledWith(params);
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0318d8cd/spec/create.spec.js
----------------------------------------------------------------------
diff --git a/spec/create.spec.js b/spec/create.spec.js
deleted file mode 100644
index afc034a..0000000
--- a/spec/create.spec.js
+++ /dev/null
@@ -1,62 +0,0 @@
-var create = require('../src/create'),
- Q = require('q'),
- fs = require('fs'),
- shell = require('shelljs'),
- plugman = require('../plugman');
-
-describe( 'create', function() {
- it( 'should call create', function() {
- var sCreate = spyOn( plugman, 'create' ).andReturn(Q());
- plugman.create();
- expect(sCreate).toHaveBeenCalled();
- });
-});
-
-describe( 'create plugin', function() {
- var done = false,
- existsSync,
- mkdir,
- writeFileSync;
- function createPromise( f ) {
- f.then( function() { done = true; }, function(err) { done = err; } );
- }
- beforeEach( function() {
- existsSync = spyOn( fs, 'existsSync' ).andReturn( false );
- mkdir = spyOn( shell, 'mkdir' ).andReturn( true );
- writeFileSync = spyOn( fs, 'writeFileSync' );
- done = false;
- });
-
- it( 'should be successful', function() {
- runs(function() {
- createPromise( create( 'name', 'org.plugin.id', '0.0.0', '.', [] ) );
- });
- waitsFor(function() { return done; }, 'create promise never resolved', 500);
- runs(function() {
- expect( done ).toBe( true );
- expect( writeFileSync.calls.length ).toEqual( 2 );
- });
- });
-});
-
-describe( 'create plugin in existing plugin', function() {
- var done = false,
- existsSync;
- function createPromise( f ) {
- f.then( function() { done = true; }, function(err) { done = err; } );
- }
- beforeEach( function() {
- existsSync = spyOn( fs, 'existsSync' ).andReturn( true );
- done = false;
- });
-
- it( 'should fail due to an existing plugin.xml', function() {
- runs(function() {
- createPromise( create() );
- });
- waitsFor(function() { return done; }, 'create promise never resolved', 500);
- runs(function() {
- expect(''+ done ).toContain( 'Error: plugin.xml already exists. Are you already in a plugin?' );
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0318d8cd/spec/fetch.spec.js
----------------------------------------------------------------------
diff --git a/spec/fetch.spec.js b/spec/fetch.spec.js
deleted file mode 100644
index 2a0b660..0000000
--- a/spec/fetch.spec.js
+++ /dev/null
@@ -1,211 +0,0 @@
-var fetch = require('../src/fetch'),
- fs = require('fs'),
- os = require('osenv'),
- path = require('path'),
- shell = require('shelljs'),
- xml_helpers = require('../src/util/xml-helpers'),
- metadata = require('../src/util/metadata'),
- temp = path.join(os.tmpdir(), 'plugman'),
- test_plugin = path.join(__dirname, 'plugins', 'ChildBrowser'),
- test_plugin_with_space = path.join(__dirname, 'folder with space', 'plugins', 'ChildBrowser'),
- plugins = require('../src/util/plugins'),
- Q = require('q'),
- registry = require('../src/registry/registry');
-
-describe('fetch', function() {
- function wrapper(p, done, post) {
- p.then(post, function(err) {
- expect(err).toBeUndefined();
- }).fin(done);
- }
-
- describe('local plugins', function() {
- var xml, rm, sym, mkdir, cp, save_metadata;
- beforeEach(function() {
- xml = spyOn(xml_helpers, 'parseElementtreeSync').andReturn({
- getroot:function() { return {attrib:{id:'id'}};}
- });
- rm = spyOn(shell, 'rm');
- sym = spyOn(fs, 'symlinkSync');
- mkdir = spyOn(shell, 'mkdir');
- cp = spyOn(shell, 'cp');
- save_metadata = spyOn(metadata, 'save_fetch_metadata');
- });
-
- it('should copy locally-available plugin to plugins directory', function(done) {
- wrapper(fetch(test_plugin, temp), done, function() {
- expect(cp).toHaveBeenCalledWith('-R', path.join(test_plugin, '*'), path.join(temp, 'id'));
- });
- });
- it('should copy locally-available plugin to plugins directory when spaces in path', function(done) {
- //XXX: added this because plugman tries to fetch from registry when plugin folder does not exist
- spyOn(fs,'existsSync').andReturn(true);
- wrapper(fetch(test_plugin_with_space, temp), done, function() {
- expect(cp).toHaveBeenCalledWith('-R', path.join(test_plugin_with_space, '*'), path.join(temp, 'id'));
- });
- });
- it('should create a symlink if used with `link` param', function(done) {
- wrapper(fetch(test_plugin, temp, { link: true }), done, function() {
- expect(sym).toHaveBeenCalledWith(test_plugin, path.join(temp, 'id'), 'dir');
- });
- });
- it('should fail when the expected ID doesn\'t match', function(done) {
- fetch(test_plugin, temp, { expected_id: 'wrongID' })
- .then(function() {
- expect('this call').toBe('fail');
- }, function(err) {
- expect(''+err).toContain('Expected fetched plugin to have ID "wrongID" but got "id".');
- }).fin(done);
- });
- it('should succeed when the expected ID is correct', function(done) {
- wrapper(fetch(test_plugin, temp, { expected_id: 'id' }), done, function() {
- expect(1).toBe(1);
- });
- });
- });
- describe('git plugins', function() {
- var clone, save_metadata, done, xml;
-
- function fetchPromise(f) {
- f.then(function() { done = true; }, function(err) { done = err; });
- }
-
- beforeEach(function() {
- clone = spyOn(plugins, 'clonePluginGitRepo').andReturn(Q('somedir'));
- save_metadata = spyOn(metadata, 'save_fetch_metadata');
- done = false;
- xml = spyOn(xml_helpers, 'parseElementtreeSync').andReturn({
- getroot:function() { return {attrib:{id:'id'}};}
- });
- });
- it('should call clonePluginGitRepo for https:// and git:// based urls', function() {
- var url = "https://github.com/bobeast/GAPlugin.git";
- runs(function() {
- fetchPromise(fetch(url, temp));
- });
- waitsFor(function() { return done; }, 'fetch promise never resolved', 250);
- runs(function() {
- expect(done).toBe(true);
- expect(clone).toHaveBeenCalledWith(url, temp, '.', undefined);
- expect(save_metadata).toHaveBeenCalledWith('somedir', jasmine.any(Object));
- });
- });
- it('should call clonePluginGitRepo with subdir if applicable', function() {
- var url = "https://github.com/bobeast/GAPlugin.git";
- var dir = 'fakeSubDir';
- runs(function() {
- fetchPromise(fetch(url, temp, { subdir: dir }));
- });
- waitsFor(function() { return done; }, 'fetch promise never resolved', 250);
- runs(function() {
- expect(clone).toHaveBeenCalledWith(url, temp, dir, undefined);
- expect(save_metadata).toHaveBeenCalledWith('somedir', jasmine.any(Object));
- });
- });
- it('should call clonePluginGitRepo with subdir and git ref if applicable', function() {
- var url = "https://github.com/bobeast/GAPlugin.git";
- var dir = 'fakeSubDir';
- var ref = 'fakeGitRef';
- runs(function() {
- fetchPromise(fetch(url, temp, { subdir: dir, git_ref: ref }));
- });
- waitsFor(function() { return done; }, 'fetch promise never resolved', 250);
- runs(function() {
- expect(clone).toHaveBeenCalledWith(url, temp, dir, ref);
- expect(save_metadata).toHaveBeenCalledWith('somedir', jasmine.any(Object));
- });
- });
- it('should extract the git ref from the URL hash, if provided', function() {
- var url = "https://github.com/bobeast/GAPlugin.git#fakeGitRef";
- var baseURL = "https://github.com/bobeast/GAPlugin.git";
- runs(function() {
- fetchPromise(fetch(url, temp, {}));
- });
- waitsFor(function() { return done; }, 'fetch promise never resolved', 250);
- runs(function() {
- expect(clone).toHaveBeenCalledWith(baseURL, temp, '.', 'fakeGitRef');
- expect(save_metadata).toHaveBeenCalledWith('somedir', jasmine.any(Object));
- });
- });
- it('should extract the subdir from the URL hash, if provided', function() {
- var url = "https://github.com/bobeast/GAPlugin.git#:fakeSubDir";
- var baseURL = "https://github.com/bobeast/GAPlugin.git";
- runs(function() {
- fetchPromise(fetch(url, temp, {}));
- });
- waitsFor(function() { return done; }, 'fetch promise never resolved', 250);
- runs(function() {
- expect(clone).toHaveBeenCalledWith(baseURL, temp, 'fakeSubDir', undefined);
- expect(save_metadata).toHaveBeenCalledWith('somedir', jasmine.any(Object));
- });
- });
- it('should extract the git ref and subdir from the URL hash, if provided', function() {
- var url = "https://github.com/bobeast/GAPlugin.git#fakeGitRef:/fake/Sub/Dir/";
- var baseURL = "https://github.com/bobeast/GAPlugin.git";
- runs(function() {
- fetchPromise(fetch(url, temp, {}));
- });
- waitsFor(function() { return done; }, 'fetch promise never resolved', 250);
- runs(function() {
- expect(clone).toHaveBeenCalledWith(baseURL, temp, 'fake/Sub/Dir', 'fakeGitRef');
- expect(save_metadata).toHaveBeenCalledWith('somedir', jasmine.any(Object));
- });
- });
- it('should throw if used with url and `link` param', function() {
- runs(function() {
- fetch("https://github.com/bobeast/GAPlugin.git", temp, {link:true}).then(null, function(err) { done = err; });
- });
- waitsFor(function() { return done; }, 'fetch promise never resolved', 250);
- runs(function() {
- expect(''+done).toContain('--link is not supported for git URLs');
- });
- });
- it('should fail when the expected ID doesn\'t match', function(done) {
- fetch('https://github.com/bobeast/GAPlugin.git', temp, { expected_id: 'wrongID' })
- .then(function() {
- expect('this call').toBe('fail');
- }, function(err) {
- expect(''+err).toContain('Expected fetched plugin to have ID "wrongID" but got "id".');
- }).fin(done);
- });
- it('should succeed when the expected ID is correct', function(done) {
- wrapper(fetch('https://github.com/bobeast/GAPlugin.git', temp, { expected_id: 'id' }), done, function() {
- expect(1).toBe(1);
- });
- });
- });
- describe('registry plugins', function() {
- var pluginId = 'dummyplugin', sFetch;
- var xml, rm, sym, mkdir, cp, save_metadata;
- beforeEach(function() {
- xml = spyOn(xml_helpers, 'parseElementtreeSync').andReturn({
- getroot:function() { return {attrib:{id:'id'}};}
- });
- rm = spyOn(shell, 'rm');
- sym = spyOn(fs, 'symlinkSync');
- mkdir = spyOn(shell, 'mkdir');
- cp = spyOn(shell, 'cp');
- save_metadata = spyOn(metadata, 'save_fetch_metadata');
- sFetch = spyOn(registry, 'fetch').andReturn(Q('somedir'));
- });
-
- it('should get a plugin from registry and set the right client when argument is not a folder nor URL', function(done) {
- wrapper(fetch(pluginId, temp, {client: 'plugman'}), done, function() {
- expect(sFetch).toHaveBeenCalledWith([pluginId], 'plugman');
- });
- });
- it('should fail when the expected ID doesn\'t match', function(done) {
- fetch(pluginId, temp, { expected_id: 'wrongID' })
- .then(function() {
- expect('this call').toBe('fail');
- }, function(err) {
- expect(''+err).toContain('Expected fetched plugin to have ID "wrongID" but got "id".');
- }).fin(done);
- });
- it('should succeed when the expected ID is correct', function(done) {
- wrapper(fetch(pluginId, temp, { expected_id: 'id' }), done, function() {
- expect(1).toBe(1);
- });
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0318d8cd/spec/info.spec.js
----------------------------------------------------------------------
diff --git a/spec/info.spec.js b/spec/info.spec.js
deleted file mode 100644
index 96256c7..0000000
--- a/spec/info.spec.js
+++ /dev/null
@@ -1,15 +0,0 @@
-var search = require('../src/info'),
- Q = require('q'),
- registry = require('../src/registry/registry');
-
-describe('info', function() {
- it('should show plugin info', function() {
- var sSearch = spyOn(registry, 'info').andReturn(Q({
- name: 'fakePlugin',
- version: '1.0.0',
- engines: [{ name: 'plugman', version: '>=0.11' }]
- }));
- search(new Array('myplugin'));
- expect(sSearch).toHaveBeenCalledWith(['myplugin']);
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0318d8cd/spec/install.spec.js
----------------------------------------------------------------------
diff --git a/spec/install.spec.js b/spec/install.spec.js
deleted file mode 100644
index 20a3d37..0000000
--- a/spec/install.spec.js
+++ /dev/null
@@ -1,472 +0,0 @@
-var install = require('../src/install'),
- actions = require('../src/util/action-stack'),
- config_changes = require('../src/util/config-changes'),
- xml_helpers = require('../src/util/xml-helpers'),
- events = require('../src/events'),
- plugman = require('../plugman'),
- platforms = require('../src/platforms/common'),
- common = require('./common'),
- fs = require('fs'),
- os = require('os'),
- path = require('path'),
- shell = require('shelljs'),
- child_process = require('child_process'),
- semver = require('semver'),
- Q = require('q'),
- spec = __dirname,
- done = false,
- srcProject = path.join(spec, 'projects', 'android_install'),
- project = path.join(os.tmpdir(), 'plugman-test', 'android_install'),
-
- plugins_dir = path.join(spec, 'plugins'),
- plugins_install_dir = path.join(project, 'cordova', 'plugins'),
- plugins = {
- 'DummyPlugin' : path.join(plugins_dir, 'DummyPlugin'),
- 'EnginePlugin' : path.join(plugins_dir, 'EnginePlugin'),
- 'EnginePluginAndroid' : path.join(plugins_dir, 'EnginePluginAndroid'),
- 'ChildBrowser' : path.join(plugins_dir, 'ChildBrowser'),
- 'VariablePlugin' : path.join(plugins_dir, 'VariablePlugin'),
- 'A' : path.join(plugins_dir, 'dependencies', 'A'),
- 'B' : path.join(plugins_dir, 'dependencies', 'B'),
- 'C' : path.join(plugins_dir, 'dependencies', 'C'),
- 'F' : path.join(plugins_dir, 'dependencies', 'F'),
- 'G' : path.join(plugins_dir, 'dependencies', 'G')
- },
- promise,
- results = {},
- dummy_id = 'com.phonegap.plugins.dummyplugin';
-
-function installPromise(f) {
- f.then(function(res) { done = true; }, function(err) { done = err; });
-}
-
-var existsSync = fs.existsSync;
-
-// Mocked functions for tests
-var fake = {
- 'existsSync' : {
- 'noPlugins' : function(path){
- // fake installed plugin directories as 'not found'
- if( path.slice(-5) !== '.json' && path.indexOf(plugins_install_dir) >= 0) {
- return false;
- }
-
- return existsSync(path);
- }
- },
- 'fetch' : {
- 'dependencies' : function(id, dir) {
- if(id == plugins['A'])
- return Q(id); // full path to plugin
-
- return Q( path.join(plugins_dir, 'dependencies', id) );
- }
- }
-}
-
-describe('start', function() {
- var prepare, config_queue_add, proc, actions_push, ca, emit;
-
- beforeEach(function() {
- prepare = spyOn(plugman, 'prepare');
- config_queue_add = spyOn(config_changes, 'add_installed_plugin_to_prepare_queue');
- proc = spyOn(actions.prototype, 'process').andReturn( Q(true) );
- actions_push = spyOn(actions.prototype, 'push');
- ca = spyOn(actions.prototype, 'createAction');
- });
- it('start', function() {
- shell.rm('-rf', project);
- shell.cp('-R', path.join(srcProject, '*'), project);
-
- done = false;
- promise = Q()
- .then(
- function(){ return install('android', project, plugins['DummyPlugin']) }
- ).then(
- function(){
- results['actions_callCount'] = actions_push.callCount;
- results['actions_create'] = ca.argsForCall[0];
- results['config_add'] = config_queue_add.argsForCall[0];
-
- return Q();
- }
- ).then(
- function(){ return install('android', project, plugins['EnginePlugin']) }
- ).then(
- function(){
- emit = spyOn(events, 'emit');
- return install('android', project, plugins['ChildBrowser'])
- }
- ).then(
- function(){
- return install('android', project, plugins['VariablePlugin'], plugins_install_dir, { cli_variables:{API_KEY:'batman'} })
- }
- ).then(
- function(){
- done = true;
- results['prepareCount'] = prepare.callCount;
- results['emit_results'] = [];
-
- for(var i in emit.calls) {
- if(emit.calls[i].args[0] === 'results')
- results['emit_results'].push(emit.calls[i].args[1]);
- }
-
- events.emit("verbose", "***** DONE START *****");
- }
- );
- waitsFor(function() { return done; }, 'promise never resolved', 500);
- });
-});
-
-describe('install', function() {
- var chmod, exec, proc, add_to_queue, prepare, actions_push, c_a, mkdir, cp, rm, fetchSpy, emit;
-
- beforeEach(function() {
- prepare = spyOn(plugman, 'prepare').andReturn( Q(true) );
-
- exec = spyOn(child_process, 'exec').andCallFake(function(cmd, cb) {
- cb(false, '', '');
- });
- spyOn(fs, 'mkdirSync').andReturn(true);
- spyOn(shell, 'mkdir').andReturn(true);
- spyOn(platforms, 'copyFile').andReturn(true);
-
- fetchSpy = spyOn(plugman.raw, 'fetch').andReturn( Q( plugins['EnginePlugin'] ) );
- chmod = spyOn(fs, 'chmodSync').andReturn(true);
- fsWrite = spyOn(fs, 'writeFileSync').andReturn(true);
- cp = spyOn(shell, 'cp').andReturn(true);
- rm = spyOn(shell, 'rm').andReturn(true);
- add_to_queue = spyOn(config_changes, 'add_installed_plugin_to_prepare_queue');
- done = false;
- });
-
- describe('success', function() {
- it('should call prepare after a successful install', function() {
- expect(results['prepareCount']).toBe(4);
- });
-
- it('should emit a results event with platform-agnostic <info>', function() {
- // ChildBrowser
- expect(results['emit_results'][0]).toBe('No matter what platform you are installing to, this notice is very important.');
- });
- it('should emit a results event with platform-specific <info>', function() {
- // ChildBrowser
- expect(results['emit_results'][1]).toBe('Please make sure you read this because it is very important to complete the installation of your plugin.');
- });
- it('should interpolate variables into <info> tags', function() {
- // VariableBrowser
- expect(results['emit_results'][2]).toBe('Remember that your api key is batman!');
- });
-
- it('should call fetch if provided plugin cannot be resolved locally', function() {
- fetchSpy.andReturn( Q( plugins['DummyPlugin'] ) );
- spyOn(fs, 'existsSync').andCallFake( fake['existsSync']['noPlugins'] );
-
- runs(function() {
- installPromise(install('android', project, 'CLEANYOURSHORTS' ));
- });
- waitsFor(function() { return done; }, 'install promise never resolved', 200);
- runs(function() {
- expect(done).toBe(true);
- expect(fetchSpy).toHaveBeenCalled();
- });
- });
-
- it('should call the config-changes module\'s add_installed_plugin_to_prepare_queue method after processing an install', function() {
- expect(results['config_add']).toEqual([plugins_install_dir, dummy_id, 'android', {}, true]);
- });
- it('should queue up actions as appropriate for that plugin and call process on the action stack',
- function() {
- expect(results['actions_callCount']).toEqual(3);
- expect(results['actions_create']).toEqual([jasmine.any(Function), [jasmine.any(Object), path.join(plugins_install_dir, dummy_id), project, dummy_id], jasmine.any(Function), [jasmine.any(Object), project, dummy_id]]);
- });
-
- it('should check version if plugin has engine tag', function(){
- var satisfies = spyOn(semver, 'satisfies').andReturn(true);
- exec.andCallFake(function(cmd, cb) {
- cb(null, '2.5.0\n');
- });
-
- runs(function() {
- installPromise( install('android', project, plugins['EnginePlugin']) );
- });
- waitsFor(function() { return done; }, 'install promise never resolved', 200);
- runs(function() {
- expect(satisfies).toHaveBeenCalledWith('2.5.0','>=2.3.0');
- });
- });
- it('should check version and munge it a little if it has "rc" in it so it plays nice with semver (introduce a dash in it)', function() {
- var satisfies = spyOn(semver, 'satisfies').andReturn(true);
- exec.andCallFake(function(cmd, cb) {
- cb(null, '3.0.0rc1\n');
- });
-
- runs(function() {
- installPromise( install('android', project, plugins['EnginePlugin']) );
- });
- waitsFor(function() { return done; }, 'install promise never resolved', 200);
- runs(function() {
- expect(satisfies).toHaveBeenCalledWith('3.0.0-rc1','>=2.3.0');
- });
- });
- it('should check specific platform version over cordova version if specified', function() {
- var spy = spyOn(semver, 'satisfies').andReturn(true);
- exec.andCallFake(function(cmd, cb) {
- cb(null, '3.1.0\n');
- });
- fetchSpy.andReturn( Q( plugins['EnginePluginAndroid'] ) );
-
- runs(function() {
- installPromise( install('android', project, plugins['EnginePluginAndroid']) );
- });
- waitsFor(function() { return done; }, 'install promise never resolved', 200);
- runs(function() {
- expect(spy).toHaveBeenCalledWith('3.1.0','>=3.1.0');
- });
- });
- it('should check platform sdk version if specified', function() {
- var spy = spyOn(semver, 'satisfies').andReturn(true);
- fetchSpy.andReturn( Q( plugins['EnginePluginAndroid'] ) );
- exec.andCallFake(function(cmd, cb) {
- cb(null, '18\n');
- });
-
- runs(function() {
- installPromise( install('android', project, 'EnginePluginAndroid') );
- });
- waitsFor(function() { return done; }, 'install promise never resolved', 200);
- runs(function() {
- // <engine name="cordova" VERSION=">=3.0.0"/>
- // <engine name="cordova-android" VERSION=">=3.1.0"/>
- // <engine name="android-sdk" VERSION=">=18"/>
-
- expect(spy.calls.length).toBe(3);
- expect(spy.calls[0].args).toEqual([ '18.0.0', '>=3.0.0' ]);
- expect(spy.calls[1].args).toEqual([ '18.0.0', '>=3.1.0' ]);
- expect(spy.calls[2].args).toEqual([ '18.0.0','>=18' ]);
- });
- });
- it('should check engine versions', function() {
- var spy = spyOn(semver, 'satisfies').andReturn(true);
- fetchSpy.andReturn( Q( plugins['EnginePlugin'] ) );
-
- runs(function() {
- installPromise( install('android', project, plugins['EnginePlugin']) );
- });
- waitsFor(function() { return done; }, 'install promise never resolved', 200);
- runs(function() {
- // <engine name="cordova" version=">=2.3.0"/>
- // <engine name="cordova-plugman" version=">=0.10.0" />
- // <engine name="mega-fun-plugin" version=">=1.0.0" scriptSrc="megaFunVersion" platform="*" />
- // <engine name="mega-boring-plugin" version=">=3.0.0" scriptSrc="megaBoringVersion" platform="ios|android" />
-
- var plugmanVersion = require('../package.json').version;
-
- expect(spy.calls.length).toBe(4);
- expect(spy.calls[0].args).toEqual([ '', '>=2.3.0' ]);
- expect(spy.calls[1].args).toEqual([ plugmanVersion, '>=0.10.0' ]);
- expect(spy.calls[2].args).toEqual([ '', '>=1.0.0' ]);
- expect(spy.calls[3].args).toEqual([ '', '>=3.0.0' ]);
- });
- });
- it('should not check custom engine version that is not supported for platform', function() {
- var spy = spyOn(semver, 'satisfies').andReturn(true);
- runs(function() {
- installPromise( install('blackberry10', project, plugins['EnginePlugin']) );
- });
- waitsFor(function() { return done; }, 'install promise never resolved', 200);
- runs(function() {
- expect(spy).not.toHaveBeenCalledWith('','>=3.0.0');
- });
- });
-
- describe('with dependencies', function() {
- var emit;
- beforeEach(function() {
- spyOn(fs, 'existsSync').andCallFake( fake['existsSync']['noPlugins'] );
- fetchSpy.andCallFake( fake['fetch']['dependencies'] );
- emit = spyOn(events, 'emit');
- exec.andCallFake(function(cmd, cb) {
- cb(null, '9.0.0\n');
- });
- });
-
- it('should install any dependent plugins if missing', function() {
- runs(function() {
- installPromise( install('android', project, plugins['A']) );
- });
- waitsFor(function() { return done; }, 'install promise never resolved', 200);
- runs(function() {
- // Look for 'Installing plugin ...' in events
- var install = common.spy.getInstall(emit);
-
- expect(install).toEqual([
- 'Install start for "C" on android.',
- 'Install start for "D" on android.',
- 'Install start for "A" on android.'
- ]);
- });
- });
-
- it('should install any dependent plugins from registry when url is not defined', function() {
- // Plugin A depends on C & D
- runs(function() {
- installPromise( install('android', project, plugins['A']) );
- });
- waitsFor(function() { return done; }, 'promise never resolved', 200);
- runs(function() {
- // TODO: this is same test as above? Need test other dependency with url=?
- var install = common.spy.getInstall(emit);
-
- expect(install).toEqual([
- 'Install start for "C" on android.',
- 'Install start for "D" on android.',
- 'Install start for "A" on android.'
- ]);;
- });
- });
-
- it('should process all dependent plugins with alternate routes to the same plugin', function() {
- // Plugin F depends on A, C, D and E
- runs(function () {
- installPromise(install('android', project, plugins['F']));
- });
- waitsFor(function () { return done; }, 'install promise never resolved', 200);
- runs(function () {
- var install = common.spy.getInstall(emit);
-
- expect(install).toEqual([
- 'Install start for "C" on android.',
- 'Install start for "D" on android.',
- 'Install start for "A" on android.',
- 'Install start for "D" on android.',
- 'Install start for "F" on android.'
- ]);
- });
- });
-
- it('should throw if there is a cyclic dependency', function() {
- runs(function () {
- installPromise( install('android', project, plugins['G']) );
- });
- waitsFor(function () { return done; }, 'install promise never resolved', 200);
- runs(function () {
- var install = common.spy.getInstall(emit);
-
- expect(done.message).toEqual('Cyclic dependency from G to H');
- });
- });
-
- it('install subdir relative to top level plugin if no fetch meta', function() {
- runs(function () {
- installPromise(install('android', project, plugins['B']));
- });
- waitsFor(function () { return done; }, 'install promise never resolved', 200);
- runs(function () {
- var install = common.spy.getInstall(emit);
-
- expect(install).toEqual([
- 'Install start for "D" on android.',
- 'Install start for "E" on android.',
- 'Install start for "B" on android.'
- ]);
- });
- });
-
- it('install uses meta data (if available) of top level plugin source', function() {
- // Fake metadata so plugin 'B' appears from 'meta/B'
- var meta = require('../src/util/metadata');
- spyOn(meta, 'get_fetch_metadata').andCallFake(function(){
- return {
- source: {type: 'dir', url: path.join(plugins['B'], '..', 'meta')}
- };
- });
-
- runs(function () {
- installPromise(install('android', project, plugins['B']));
- });
- waitsFor(function () { return done; }, 'install promise never resolved', 200);
- runs(function () {
- var install = common.spy.getInstall(emit);
-
- expect(install).toEqual([
- 'Install start for "D" on android.',
- 'Install start for "E" on android.',
- 'Install start for "B" on android.'
- ]);
-
- var copy = common.spy.startsWith(emit, "Copying from");
- expect(copy.length).toBe(3);
- expect(copy[0].indexOf(path.normalize('meta/D')) > 0).toBe(true);
- expect(copy[1].indexOf(path.normalize('meta/subdir/E')) > 0).toBe(true);
- });
- });
- });
-
- });
-
- xdescribe('failure', function() {
- it('should throw if platform is unrecognized', function() {
- runs(function() {
- installPromise( install('atari', project, 'SomePlugin') );
- });
- waitsFor(function() { return done; }, 'install promise never resolved', 200);
- runs(function() {
- expect(''+done).toContain('atari not supported.');
- });
- });
- it('should throw if variables are missing', function() {
- runs(function() {
- installPromise( install('android', project, plugins['VariablePlugin']) );
- });
- waitsFor(function(){ return done; }, 'install promise never resolved', 200);
- runs(function() {
- expect(''+done).toContain('Variable(s) missing: API_KEY');
- });
- });
- it('should throw if git is not found on the path and a remote url is requested', function() {
- spyOn(fs, 'existsSync').andCallFake( fake['existsSync']['noPlugins'] );
- var which_spy = spyOn(shell, 'which').andReturn(null);
- runs(function() {
- installPromise( install('android', project, 'https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git') );
- });
- waitsFor(function(){ return done; }, 'install promise never resolved', 200);
- runs(function() {
- expect(''+done).toContain('"git" command line tool is not installed: make sure it is accessible on your PATH.');
- });
- });
- it('should throw if plugin version is less than the minimum requirement', function(){
- var spy = spyOn(semver, 'satisfies').andReturn(false);
- exec.andCallFake(function(cmd, cb) {
- cb(null, '0.0.1\n');
- });
- runs(function() {
- installPromise( install('android', project, plugins['EnginePlugin']) );
- });
- waitsFor(function(){ return done; }, 'install promise never resolved', 200);
- runs(function() {
- expect(''+done).toContain('Plugin doesn\'t support this project\'s cordova version. cordova: 0.0.1, failed version requirement: >=2.3.0');
- });
- });
- });
-
-});
-
-
-describe('end', function() {
-
- it('end', function() {
- done = false;
-
- promise.fin(function(err){
- if(err)
- events.emit('error', err);
-
- shell.rm('-rf', project);
- done = true;
- });
-
- waitsFor(function() { return done; }, 'promise never resolved', 500);
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0318d8cd/spec/owner.spec.js
----------------------------------------------------------------------
diff --git a/spec/owner.spec.js b/spec/owner.spec.js
deleted file mode 100644
index 1c6bd2c..0000000
--- a/spec/owner.spec.js
+++ /dev/null
@@ -1,12 +0,0 @@
-var owner = require('../src/owner'),
- Q = require('q'),
- registry = require('../src/registry/registry');
-
-describe('owner', function() {
- it('should run owner', function() {
- var sOwner = spyOn(registry, 'owner').andReturn(Q());
- var params = ['add', 'anis', 'com.phonegap.plugins.dummyplugin'];
- owner(params);
- expect(sOwner).toHaveBeenCalledWith(params);
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0318d8cd/spec/platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform.spec.js b/spec/platform.spec.js
deleted file mode 100644
index 4f8099c..0000000
--- a/spec/platform.spec.js
+++ /dev/null
@@ -1,26 +0,0 @@
-var platforms = require('../src/platforms')
-var pluginTags = ["source-file", "header-file", "lib-file", "resource-file", "framework"];
-
-function getTest(platformId, pluginTag) {
- return function() {
- it('should exist', function() {
- expect(platforms[platformId][pluginTag] ).toBeDefined();
- });
- it('with an install method', function() {
- expect(platforms[platformId][pluginTag].install ).toBeDefined();
- });
- it('with an uninstall method', function() {
- expect(platforms[platformId][pluginTag].uninstall ).toBeDefined();
- });
- }
-}
-
-for(var platformId in platforms) {
- for(var index = 0, len = pluginTags.length; index < len; index++) {
- var funk = getTest(platformId,pluginTags[index]);
- describe(platformId + " should have a " + pluginTags[index] + " object", funk);
- }
-
-}
-
-
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0318d8cd/spec/platforms/amazon-fireos.spec.js
----------------------------------------------------------------------
diff --git a/spec/platforms/amazon-fireos.spec.js b/spec/platforms/amazon-fireos.spec.js
deleted file mode 100644
index 49a8b0d..0000000
--- a/spec/platforms/amazon-fireos.spec.js
+++ /dev/null
@@ -1,139 +0,0 @@
-var amazon_fireos = require('../../src/platforms/amazon-fireos'),
- common = require('../../src/platforms/common'),
- install = require('../../src/install'),
- path = require('path'),
- fs = require('fs'),
- shell = require('shelljs'),
- et = require('elementtree'),
- os = require('osenv'),
- temp = path.join(os.tmpdir(), 'plugman'),
- plugins_dir = path.join(temp, 'cordova', 'plugins'),
- xml_helpers = require('../../src/util/xml-helpers'),
- plugins_module = require('../../src/util/plugins'),
- dummyplugin = path.join(__dirname, '..', 'plugins', 'DummyPlugin'),
- faultyplugin = path.join(__dirname, '..', 'plugins', 'FaultyPlugin'),
- variableplugin = path.join(__dirname, '..', 'plugins', 'VariablePlugin'),
- amazon_fireos_one_project = path.join(__dirname, '..', 'projects', 'android_one', '*'),
- amazon_fireos_two_project = path.join(__dirname, '..', 'projects', 'android_two', '*');
-
-var xml_path = path.join(dummyplugin, 'plugin.xml')
- , xml_text = fs.readFileSync(xml_path, 'utf-8')
- , plugin_et = new et.ElementTree(et.XML(xml_text));
-
-var platformTag = plugin_et.find('./platform[@name="amazon-fireos"]');
-var dummy_id = plugin_et._root.attrib['id'];
-
-var valid_source = platformTag.findall('./source-file'),
- valid_libs = platformTag.findall('./lib-file'),
- assets = plugin_et.findall('./asset'),
- configChanges = platformTag.findall('./config-file');
-
-xml_path = path.join(faultyplugin, 'plugin.xml')
-xml_text = fs.readFileSync(xml_path, 'utf-8')
-plugin_et = new et.ElementTree(et.XML(xml_text));
-
-platformTag = plugin_et.find('./platform[@name="amazon-fireos"]');
-var invalid_source = platformTag.findall('./source-file');
-var faulty_id = plugin_et._root.attrib['id'];
-xml_path = path.join(variableplugin, 'plugin.xml')
-xml_text = fs.readFileSync(xml_path, 'utf-8')
-plugin_et = new et.ElementTree(et.XML(xml_text));
-platformTag = plugin_et.find('./platform[@name="amazon-fireos"]');
-
-var variable_id = plugin_et._root.attrib['id'];
-var variable_configs = platformTag.findall('./config-file');
-
-function copyArray(arr) {
- return Array.prototype.slice.call(arr, 0);
-}
-/*
-describe('amazon-fireos project handler', function() {
- describe('www_dir method', function() {
- it('should return cordova-amazon-fireos project www location using www_dir', function() {
- expect(amazon_fireos.www_dir(path.sep)).toEqual(path.sep + path.join('assets', 'www'));
- });
- });
- describe('package_name method', function() {
- it('should return an amazon-fireos project\'s proper package name', function() {
- expect(amazon_fireos.package_name(path.join(amazon_fireos_one_project, '..'))).toEqual('com.alunny.childapp');
- });
- });
-
- describe('installation', function() {
- beforeEach(function() {
- shell.mkdir('-p', temp);
- });
- afterEach(function() {
- shell.rm('-rf', temp);
- });
- describe('of <lib-file> elements', function() {
- it("should copy jar files to project/libs", function () {
- var s = spyOn(common, 'copyFile');
-
- amazon_fireos['lib-file'].install(valid_libs[0], dummyplugin, temp);
- expect(s).toHaveBeenCalledWith(dummyplugin, 'src/amazon-fireos/TestLib.jar', temp, path.join('libs', 'TestLib.jar'));
- });
- });
- describe('of <source-file> elements', function() {
- beforeEach(function() {
- shell.cp('-rf', amazon_fireos_one_project, temp);
- });
-
- it('should copy stuff from one location to another by calling common.copyFile', function() {
- var source = copyArray(valid_source);
- var s = spyOn(common, 'copyFile');
- amazon_fireos['source-file'].install(source[0], dummyplugin, temp);
- expect(s).toHaveBeenCalledWith(dummyplugin, 'src/amazon-fireos/DummyPlugin.java', temp, path.join('src', 'com', 'phonegap', 'plugins', 'dummyplugin', 'DummyPlugin.java'));
- });
- it('should throw if source file cannot be found', function() {
- var source = copyArray(invalid_source);
- expect(function() {
- amazon_fireos['source-file'].install(source[0], faultyplugin, temp);
- }).toThrow('"' + path.resolve(faultyplugin, 'src/amazon-fireos/NotHere.java') + '" not found!');
- });
- it('should throw if target file already exists', function() {
- // write out a file
- var target = path.resolve(temp, 'src/com/phonegap/plugins/dummyplugin');
- shell.mkdir('-p', target);
- target = path.join(target, 'DummyPlugin.java');
- fs.writeFileSync(target, 'some bs', 'utf-8');
-
- var source = copyArray(valid_source);
- expect(function() {
- amazon_fireos['source-file'].install(source[0], dummyplugin, temp);
- }).toThrow('"' + target + '" already exists!');
- });
- });
- });
-
- describe('uninstallation', function() {
- beforeEach(function() {
- shell.mkdir('-p', temp);
- shell.mkdir('-p', plugins_dir);
- shell.cp('-rf', amazon_fireos_two_project, temp);
- });
- afterEach(function() {
- shell.rm('-rf', temp);
- });
- describe('of <lib-file> elements', function(done) {
- it('should remove jar files', function () {
- var s = spyOn(common, 'removeFile');
- amazon_fireos['lib-file'].install(valid_libs[0], dummyplugin, temp);
- amazon_fireos['lib-file'].uninstall(valid_libs[0], temp, dummy_id);
- expect(s).toHaveBeenCalledWith(temp, path.join('libs', 'TestLib.jar'));
- });
- });
- describe('of <source-file> elements', function() {
- it('should remove stuff by calling common.deleteJava', function(done) {
- var s = spyOn(common, 'deleteJava');
- install('amazon-fireos', temp, dummyplugin, plugins_dir, {})
- .then(function() {
- var source = copyArray(valid_source);
- amazon_fireos['source-file'].uninstall(source[0], temp);
- expect(s).toHaveBeenCalledWith(temp, path.join('src', 'com', 'phonegap', 'plugins', 'dummyplugin', 'DummyPlugin.java'));
- done();
- });
- });
- });
- });
-}); */
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0318d8cd/spec/platforms/android.spec.js
----------------------------------------------------------------------
diff --git a/spec/platforms/android.spec.js b/spec/platforms/android.spec.js
deleted file mode 100644
index 57f45fe..0000000
--- a/spec/platforms/android.spec.js
+++ /dev/null
@@ -1,156 +0,0 @@
-var android = require('../../src/platforms/android'),
- common = require('../../src/platforms/common'),
- install = require('../../src/install'),
- path = require('path'),
- fs = require('fs'),
- shell = require('shelljs'),
- et = require('elementtree'),
- os = require('osenv'),
- temp = path.join(os.tmpdir(), 'plugman'),
- plugins_dir = path.join(temp, 'cordova', 'plugins'),
- xml_helpers = require('../../src/util/xml-helpers'),
- plugins_module = require('../../src/util/plugins'),
- dummyplugin = path.join(__dirname, '..', 'plugins', 'DummyPlugin'),
- faultyplugin = path.join(__dirname, '..', 'plugins', 'FaultyPlugin'),
- variableplugin = path.join(__dirname, '..', 'plugins', 'VariablePlugin'),
- android_one_project = path.join(__dirname, '..', 'projects', 'android_one', '*'),
- android_two_project = path.join(__dirname, '..', 'projects', 'android_two', '*');
-
-var xml_path = path.join(dummyplugin, 'plugin.xml')
- , xml_text = fs.readFileSync(xml_path, 'utf-8')
- , plugin_et = new et.ElementTree(et.XML(xml_text));
-
-var platformTag = plugin_et.find('./platform[@name="android"]');
-var dummy_id = plugin_et._root.attrib['id'];
-var valid_source = platformTag.findall('./source-file'),
- valid_libs = platformTag.findall('./lib-file'),
- valid_resources = platformTag.findall('./resource-file'),
- assets = plugin_et.findall('./asset'),
- configChanges = platformTag.findall('./config-file');
-
-xml_path = path.join(faultyplugin, 'plugin.xml')
-xml_text = fs.readFileSync(xml_path, 'utf-8')
-plugin_et = new et.ElementTree(et.XML(xml_text));
-
-platformTag = plugin_et.find('./platform[@name="android"]');
-var invalid_source = platformTag.findall('./source-file');
-var faulty_id = plugin_et._root.attrib['id'];
-
-xml_path = path.join(variableplugin, 'plugin.xml')
-xml_text = fs.readFileSync(xml_path, 'utf-8')
-plugin_et = new et.ElementTree(et.XML(xml_text));
-platformTag = plugin_et.find('./platform[@name="android"]');
-
-var variable_id = plugin_et._root.attrib['id'];
-var variable_configs = platformTag.findall('./config-file');
-
-function copyArray(arr) {
- return Array.prototype.slice.call(arr, 0);
-}
-
-describe('android project handler', function() {
- describe('www_dir method', function() {
- it('should return cordova-android project www location using www_dir', function() {
- expect(android.www_dir(path.sep)).toEqual(path.sep + path.join('assets', 'www'));
- });
- });
- describe('package_name method', function() {
- it('should return an android project\'s proper package name', function() {
- expect(android.package_name(path.join(android_one_project, '..'))).toEqual('com.alunny.childapp');
- });
- });
-
- describe('installation', function() {
- beforeEach(function() {
- shell.mkdir('-p', temp);
- });
- afterEach(function() {
- shell.rm('-rf', temp);
- });
- describe('of <lib-file> elements', function() {
- it("should copy jar files to project/libs", function () {
- var s = spyOn(common, 'copyFile');
-
- android['lib-file'].install(valid_libs[0], dummyplugin, temp);
- expect(s).toHaveBeenCalledWith(dummyplugin, 'src/android/TestLib.jar', temp, path.join('libs', 'TestLib.jar'));
- });
- });
- describe('of <resource-file> elements', function() {
- it("should copy files", function () {
- var s = spyOn(common, 'copyFile');
-
- android['resource-file'].install(valid_resources[0], dummyplugin, temp);
- expect(s).toHaveBeenCalledWith(dummyplugin, 'android-resource.xml', temp, path.join('res', 'xml', 'dummy.xml'));
- });
- });
- describe('of <source-file> elements', function() {
- beforeEach(function() {
- shell.cp('-rf', android_one_project, temp);
- });
-
- it('should copy stuff from one location to another by calling common.copyFile', function() {
- var source = copyArray(valid_source);
- var s = spyOn(common, 'copyFile');
- android['source-file'].install(source[0], dummyplugin, temp);
- expect(s).toHaveBeenCalledWith(dummyplugin, 'src/android/DummyPlugin.java', temp, path.join('src', 'com', 'phonegap', 'plugins', 'dummyplugin', 'DummyPlugin.java'));
- });
- it('should throw if source file cannot be found', function() {
- var source = copyArray(invalid_source);
- expect(function() {
- android['source-file'].install(source[0], faultyplugin, temp);
- }).toThrow('"' + path.resolve(faultyplugin, 'src/android/NotHere.java') + '" not found!');
- });
- it('should throw if target file already exists', function() {
- // write out a file
- var target = path.resolve(temp, 'src/com/phonegap/plugins/dummyplugin');
- shell.mkdir('-p', target);
- target = path.join(target, 'DummyPlugin.java');
- fs.writeFileSync(target, 'some bs', 'utf-8');
-
- var source = copyArray(valid_source);
- expect(function() {
- android['source-file'].install(source[0], dummyplugin, temp);
- }).toThrow('"' + target + '" already exists!');
- });
- });
- });
-
- describe('uninstallation', function() {
- beforeEach(function() {
- shell.mkdir('-p', temp);
- shell.mkdir('-p', plugins_dir);
- shell.cp('-rf', android_two_project, temp);
- });
- afterEach(function() {
- shell.rm('-rf', temp);
- });
- describe('of <lib-file> elements', function(done) {
- it('should remove jar files', function () {
- var s = spyOn(common, 'removeFile');
- android['lib-file'].install(valid_libs[0], dummyplugin, temp);
- android['lib-file'].uninstall(valid_libs[0], temp, dummy_id);
- expect(s).toHaveBeenCalledWith(temp, path.join('libs', 'TestLib.jar'));
- });
- });
- describe('of <resource-file> elements', function(done) {
- it('should remove files', function () {
- var s = spyOn(common, 'removeFile');
- android['resource-file'].install(valid_resources[0], dummyplugin, temp);
- android['resource-file'].uninstall(valid_resources[0], temp, dummy_id);
- expect(s).toHaveBeenCalledWith(temp, path.join('res', 'xml', 'dummy.xml'));
- });
- });
- describe('of <source-file> elements', function() {
- it('should remove stuff by calling common.deleteJava', function(done) {
- var s = spyOn(common, 'deleteJava');
- install('android', temp, dummyplugin, plugins_dir, {})
- .then(function() {
- var source = copyArray(valid_source);
- android['source-file'].uninstall(source[0], temp);
- expect(s).toHaveBeenCalledWith(temp, path.join('src', 'com', 'phonegap', 'plugins', 'dummyplugin', 'DummyPlugin.java'));
- done();
- });
- });
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0318d8cd/spec/platforms/blackberry10.spec.js
----------------------------------------------------------------------
diff --git a/spec/platforms/blackberry10.spec.js b/spec/platforms/blackberry10.spec.js
deleted file mode 100644
index bfdf926..0000000
--- a/spec/platforms/blackberry10.spec.js
+++ /dev/null
@@ -1,148 +0,0 @@
-var blackberry10 = require('../../src/platforms/blackberry10'),
- common = require('../../src/platforms/common'),
- install = require('../../src/install'),
- path = require('path'),
- fs = require('fs'),
- shell = require('shelljs'),
- et = require('elementtree'),
- os = require('osenv'),
- temp = path.join(os.tmpdir(), 'plugman'),
- plugins_dir = path.join(temp, 'cordova', 'plugins'),
- xml_helpers = require('../../src/util/xml-helpers'),
- plugins_module = require('../../src/util/plugins'),
- blackberry10_project = path.join(__dirname, '..', 'projects', 'blackberry10', '*'),
- plugins = {
- dummy: parsePlugin(path.join(__dirname, '..', 'plugins', 'DummyPlugin')),
- faulty: parsePlugin(path.join(__dirname, '..', 'plugins', 'FaultyPlugin')),
- echo: parsePlugin(path.join(__dirname, '..', 'plugins', 'cordova.echo'))
- };
-
-function copyArray(arr) {
- return Array.prototype.slice.call(arr, 0);
-}
-
-function parsePlugin (pluginPath) {
- var pluginXML = fs.readFileSync(path.join(pluginPath, "plugin.xml"), "utf-8"),
- pluginEt = new et.ElementTree(et.XML(pluginXML)),
- platformTag = pluginEt.find('./platform[@name="blackberry10"]');
-
- return {
- path: pluginPath,
- id: pluginEt._root.attrib.id,
- assets: pluginEt.findall('./asset'),
- srcFiles: platformTag.findall('./source-file'),
- configChanges: platformTag.findall('./config-file'),
- libFiles: platformTag.findall('./lib-file')
- };
-}
-
-
-describe('blackberry10 project handler', function() {
- describe('www_dir method', function() {
- it('should return cordova-blackberry10 project www location using www_dir', function() {
- expect(blackberry10.www_dir(path.sep)).toEqual(path.sep + 'www');
- });
- });
-
- describe('package_name method', function() {
- it('should return a blackberry10 project\'s proper package name', function() {
- expect(blackberry10.package_name(path.join(blackberry10_project, '..'))).toEqual('cordovaExample');
- });
- });
-
- describe('installation', function() {
- beforeEach(function() {
- shell.mkdir('-p', temp);
- shell.cp('-rf', blackberry10_project, temp);
- });
- afterEach(function() {
- shell.rm('-rf', temp);
- });
- describe('of <lib-file> elements', function() {
- it("should copy so files to native/target/plugins", function () {
- var plugin = plugins.echo,
- libs = copyArray(plugin.libFiles),
- s = spyOn(common, 'copyFile');
-
- blackberry10['lib-file'].install(libs[0], plugin.path, temp);
- expect(s).toHaveBeenCalledWith(plugin.path, 'src/blackberry10/native/device/echoJnext.so', temp, path.join('native', 'device', 'plugins', 'jnext', 'echoJnext.so'));
- });
- });
- describe('of <source-file> elements', function() {
- it('should copy stuff from one location to another by calling common.copyFile', function() {
- var plugin = plugins.echo,
- source = copyArray(plugin.srcFiles);
- s = spyOn(common, 'copyFile');
-
- blackberry10['source-file'].install(source[0], plugin.path, temp, plugin.id);
- expect(s).toHaveBeenCalledWith(plugin.path, 'src/blackberry10/index.js', temp, path.join('native', 'device', 'chrome', 'plugin', 'cordova.echo', 'index.js'));
- expect(s).toHaveBeenCalledWith(plugin.path, 'src/blackberry10/index.js', temp, path.join('native', 'simulator', 'chrome', 'plugin', 'cordova.echo', 'index.js'));
- });
- it('defaults to plugin id when dest is not present', function() {
- var source = copyArray(plugins.dummy.srcFiles);
- var s = spyOn(common, 'copyFile');
- blackberry10['source-file'].install(source[0], plugins.dummy.path, temp, plugins.dummy.id);
- expect(s).toHaveBeenCalledWith(plugins.dummy.path, 'src/blackberry10/index.js', temp, path.join('native', 'device', 'chrome', 'plugin', plugins.dummy.id, 'index.js'));
- expect(s).toHaveBeenCalledWith(plugins.dummy.path, 'src/blackberry10/index.js', temp, path.join('native', 'simulator', 'chrome', 'plugin', plugins.dummy.id, 'index.js'));
- });
- it('should throw if source file cannot be found', function() {
- var source = copyArray(plugins.faulty.srcFiles);
- expect(function() {
- blackberry10['source-file'].install(source[0], plugins.faulty.path, temp, plugins.faulty.id);
- }).toThrow('"' + path.resolve(plugins.faulty.path, 'src/blackberry10/index.js') + '" not found!');
- });
- it('should throw if target file already exists', function() {
- // write out a file
- var target = path.resolve(temp, 'native/device/chrome/plugin/com.phonegap.plugins.dummyplugin');
- shell.mkdir('-p', target);
- target = path.join(target, 'index.js');
- fs.writeFileSync(target, 'some bs', 'utf-8');
-
- var source = copyArray(plugins.dummy.srcFiles);
- expect(function() {
- blackberry10['source-file'].install(source[0], plugins.dummy.path, temp, plugins.dummy.id);
- }).toThrow('"' + target + '" already exists!');
- });
- });
- });
-
- describe('uninstallation', function() {
- beforeEach(function() {
- shell.mkdir('-p', temp);
- shell.cp('-rf', blackberry10_project, temp);
- });
- afterEach(function() {
- shell.rm('-rf', temp);
- });
- describe('of <source-file> elements', function() {
- it('should remove stuff by calling common.removeFile', function() {
- var s = spyOn(common, 'removeFile'),
- plugin = plugins.echo;
- var source = copyArray(plugin.srcFiles);
- blackberry10['source-file'].install(source[0], plugin.path, temp, plugin.id);
- blackberry10['source-file'].uninstall(source[0], temp, plugin.id);
- expect(s).toHaveBeenCalledWith(temp, path.join('native', 'device', 'chrome', 'plugin', 'cordova.echo', 'index.js'));
- expect(s).toHaveBeenCalledWith(temp, path.join('native', 'simulator', 'chrome', 'plugin', 'cordova.echo', 'index.js'));
- });
- it('should remove stuff by calling common.removeFile', function() {
- var s = spyOn(common, 'removeFile'),
- plugin = plugins.dummy;
- var source = copyArray(plugin.srcFiles);
- blackberry10['source-file'].install(source[0], plugin.path, temp, plugin.id);
- blackberry10['source-file'].uninstall(source[0], temp, plugin.id);
- expect(s).toHaveBeenCalledWith(temp, path.join('native', 'device', 'chrome', 'plugin', plugin.id, 'index.js'));
- expect(s).toHaveBeenCalledWith(temp, path.join('native', 'simulator', 'chrome', 'plugin', plugin.id, 'index.js'));
- });
- });
- describe('of <lib-file> elements', function(done) {
- it("should remove so files from www/plugins", function () {
- var s = spyOn(common, 'removeFile'),
- plugin = plugins.echo;
- var source = copyArray(plugin.libFiles);
- blackberry10['lib-file'].install(source[0], plugin.path, temp, plugin.id);
- blackberry10['lib-file'].uninstall(source[0], temp, plugin.id);
- expect(s).toHaveBeenCalledWith(temp, path.join('native','device','plugins','jnext','echoJnext.so'));
- });
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0318d8cd/spec/platforms/common.spec.js
----------------------------------------------------------------------
diff --git a/spec/platforms/common.spec.js b/spec/platforms/common.spec.js
deleted file mode 100644
index dcf5f2a..0000000
--- a/spec/platforms/common.spec.js
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-var common = require('../../src/platforms/common')
- , path = require('path')
- , fs = require('fs')
- , osenv = require('osenv')
- , shell = require('shelljs')
- , test_dir = path.join(osenv.tmpdir(), 'test_plugman')
- , project_dir = path.join(test_dir, 'project')
- , src = path.join(project_dir, 'src')
- , dest = path.join(project_dir, 'dest')
- , java_dir = path.join(src, 'one', 'two', 'three')
- , java_file = path.join(java_dir, 'test.java');
-
-describe('common platform handler', function() {
- describe('resolveSrcPath', function() {
- it('should not throw if path exists', function(){
- shell.mkdir('-p', test_dir);
- var target = path.join(test_dir, 'somefile');
- fs.writeFileSync(target, '80085', 'utf-8');
- expect(function(){common.resolveSrcPath(test_dir, 'somefile')}).not.toThrow();
- shell.rm('-rf', test_dir);
- });
- });
-
- describe('resolveTargetPath', function() {
- it('should throw if path exists', function(){
- shell.mkdir('-p', test_dir);
- expect(function(){common.resolveTargetPath(test_dir)}).toThrow();
- shell.rm('-rf', test_dir);
- });
-
- it('should not throw if path cannot be resolved', function(){
- expect(function(){common.resolveTargetPath(test_dir, 'somefile')}).not.toThrow();
- });
- });
-
- describe('copyFile', function() {
- it('should throw if source path cannot be resolved', function(){
- expect(function(){common.copyFile(test_dir, src, project_dir, dest)}).toThrow();
- });
-
- it('should throw if target path exists', function(){
- shell.mkdir('-p', dest);
- expect(function(){common.copyFile(test_dir, src, project_dir, dest)}).toThrow();
- shell.rm('-rf', dest);
- });
-
- it('should call mkdir -p on target path', function(){
- shell.mkdir('-p', java_dir);
- fs.writeFileSync(java_file, 'contents', 'utf-8');
-
- var s = spyOn(shell, 'mkdir').andCallThrough();
- var resolvedDest = common.resolveTargetPath(project_dir, dest);
-
- common.copyFile(test_dir, java_file, project_dir, dest);
-
- expect(s).toHaveBeenCalled();
- expect(s).toHaveBeenCalledWith('-p', path.dirname(resolvedDest));
- shell.rm('-rf', project_dir);
- });
-
- it('should call cp source/dest paths', function(){
- shell.mkdir('-p', java_dir);
- fs.writeFileSync(java_file, 'contents', 'utf-8');
-
- var s = spyOn(shell, 'cp').andCallThrough();
- var resolvedDest = common.resolveTargetPath(project_dir, dest);
-
- common.copyFile(test_dir, java_file, project_dir, dest);
-
- expect(s).toHaveBeenCalled();
- expect(s).toHaveBeenCalledWith('-f', java_file, resolvedDest);
-
- shell.rm('-rf', project_dir);
- });
-
- });
-
- describe('deleteJava', function() {
- it('should call fs.unlinkSync on the provided paths', function(){
- shell.mkdir('-p', java_dir);
- fs.writeFileSync(java_file, 'contents', 'utf-8');
-
- var s = spyOn(fs, 'unlinkSync').andCallThrough();
- common.deleteJava(project_dir, java_file);
- expect(s).toHaveBeenCalled();
- expect(s).toHaveBeenCalledWith(path.resolve(project_dir, java_file));
-
- shell.rm('-rf', java_dir);
- });
-
- it('should delete empty directories after removing source code in a java src path hierarchy', function(){
- shell.mkdir('-p', java_dir);
- fs.writeFileSync(java_file, 'contents', 'utf-8');
-
- common.deleteJava(project_dir, java_file);
- expect(fs.existsSync(java_file)).not.toBe(true);
- expect(fs.existsSync(java_dir)).not.toBe(true);
- expect(fs.existsSync(path.join(src,'one'))).not.toBe(true);
-
- shell.rm('-rf', java_dir);
- });
-
- it('should never delete the top-level src directory, even if all plugins added were removed', function(){
- shell.mkdir('-p', java_dir);
- fs.writeFileSync(java_file, 'contents', 'utf-8');
-
- common.deleteJava(project_dir, java_file);
- expect(fs.existsSync(src)).toBe(true);
-
- shell.rm('-rf', java_dir);
- });
- });
-});