You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by au...@apache.org on 2017/07/18 16:56:55 UTC
[4/4] cordova-common git commit: CB-12895 : set up eslint and removed
jshint
CB-12895 : set up eslint and removed jshint
Project: http://git-wip-us.apache.org/repos/asf/cordova-common/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-common/commit/54450166
Tree: http://git-wip-us.apache.org/repos/asf/cordova-common/tree/54450166
Diff: http://git-wip-us.apache.org/repos/asf/cordova-common/diff/54450166
Branch: refs/heads/master
Commit: 54450166db4c7facc785064ee5104cad5702faa8
Parents: 1cdc124
Author: Audrey So <au...@apache.org>
Authored: Fri Jun 9 11:02:48 2017 -0700
Committer: Audrey So <au...@apache.org>
Committed: Fri Jul 14 15:28:48 2017 -0700
----------------------------------------------------------------------
.eslintignore | 1 +
.eslintrc.yml | 11 +
.jshintignore | 1 -
package.json | 12 +-
spec/.eslintrc.yml | 2 +
spec/.jshintrc | 11 -
spec/ActionStack.spec.js | 48 ++--
spec/ConfigChanges/ConfigChanges.spec.js | 190 ++++++++--------
spec/ConfigParser/ConfigParser.spec.js | 185 ++++++++--------
spec/CordovaCheck.spec.js | 40 ++--
spec/CordovaLogger.spec.js | 12 +-
spec/FileUpdater.spec.js | 134 ++++++------
spec/PlatformJson.spec.js | 42 ++--
spec/PluginInfo/PluginInfo.spec.js | 8 +-
spec/PluginInfo/PluginInfoProvider.spec.js | 4 +-
spec/PluginManager.spec.js | 66 +++---
spec/events.spec.js | 4 +-
spec/plist-helpers.spec.js | 15 +-
spec/superspawn.spec.js | 56 ++---
spec/util/xml-helpers.spec.js | 150 ++++++-------
src/.jshintrc | 10 -
src/ActionStack.js | 30 +--
src/ConfigChanges/ConfigChanges.js | 118 +++++-----
src/ConfigChanges/ConfigFile.js | 94 ++++----
src/ConfigChanges/ConfigKeeper.js | 9 +-
src/ConfigChanges/munge-util.js | 45 ++--
src/ConfigParser/ConfigParser.js | 219 +++++++++----------
src/CordovaCheck.js | 14 +-
src/CordovaError/CordovaError.js | 25 ++-
.../CordovaExternalToolErrorContext.js | 6 +-
src/CordovaLogger.js | 18 +-
src/FileUpdater.js | 141 ++++++------
src/PlatformJson.js | 65 +++---
src/PluginInfo/PluginInfo.js | 177 +++++++--------
src/PluginInfo/PluginInfoProvider.js | 14 +-
src/PluginManager.js | 91 ++++----
src/events.js | 3 +-
src/superspawn.js | 25 +--
src/util/addProperty.js | 4 +-
src/util/plist-helpers.js | 49 ++---
src/util/xml-helpers.js | 137 ++++++------
41 files changed, 1126 insertions(+), 1160 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/.eslintignore
----------------------------------------------------------------------
diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..161d0c6
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1 @@
+spec/fixtures/*
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/.eslintrc.yml
----------------------------------------------------------------------
diff --git a/.eslintrc.yml b/.eslintrc.yml
new file mode 100644
index 0000000..7701c82
--- /dev/null
+++ b/.eslintrc.yml
@@ -0,0 +1,11 @@
+root: true
+extends: semistandard
+rules:
+ indent:
+ - error
+ - 4
+ camelcase: off
+ padded-blocks: off
+ operator-linebreak: off
+ no-throw-literal: off
+
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/.jshintignore
----------------------------------------------------------------------
diff --git a/.jshintignore b/.jshintignore
deleted file mode 100644
index d606f61..0000000
--- a/.jshintignore
+++ /dev/null
@@ -1 +0,0 @@
-spec/fixtures/*
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 44ccd3c..247c292 100644
--- a/package.json
+++ b/package.json
@@ -17,8 +17,8 @@
"node": ">=4.0.0"
},
"scripts": {
- "test": "npm run jshint && npm run jasmine",
- "jshint": "jshint src && jshint spec",
+ "test": "npm run eslint && npm run jasmine",
+ "eslint": "eslint src && eslint spec",
"jasmine": "jasmine JASMINE_CONFIG_PATH=spec/support/jasmine.json",
"cover": "istanbul cover --root src --print detail jasmine"
},
@@ -38,9 +38,15 @@
"unorm": "^1.3.3"
},
"devDependencies": {
+ "eslint": "^4.0.0",
+ "eslint-config-semistandard": "^11.0.0",
+ "eslint-config-standard": "^10.2.1",
+ "eslint-plugin-import": "^2.3.0",
+ "eslint-plugin-node": "^5.0.0",
+ "eslint-plugin-promise": "^3.5.0",
+ "eslint-plugin-standard": "^3.0.1",
"istanbul": "^0.4.5",
"jasmine": "^2.5.2",
- "jshint": "^2.8.0",
"promise-matchers": "^0.9.6",
"rewire": "^2.5.1"
},
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/.eslintrc.yml
----------------------------------------------------------------------
diff --git a/spec/.eslintrc.yml b/spec/.eslintrc.yml
new file mode 100644
index 0000000..6afba65
--- /dev/null
+++ b/spec/.eslintrc.yml
@@ -0,0 +1,2 @@
+env:
+ jasmine: true
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/.jshintrc
----------------------------------------------------------------------
diff --git a/spec/.jshintrc b/spec/.jshintrc
deleted file mode 100644
index 17eae32..0000000
--- a/spec/.jshintrc
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "node": true
- , "bitwise": true
- , "undef": true
- , "trailing": true
- , "quotmark": true
- , "indent": 4
- , "unused": "vars"
- , "latedef": "nofunc"
- , "jasmine": true
-}
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/ActionStack.spec.js
----------------------------------------------------------------------
diff --git a/spec/ActionStack.spec.js b/spec/ActionStack.spec.js
index 80d6c4d..44df820 100644
--- a/spec/ActionStack.spec.js
+++ b/spec/ActionStack.spec.js
@@ -20,58 +20,58 @@ var path = require('path');
var action_stack = require('../src/ActionStack');
var android_one_project = path.join(__dirname, '..', 'projects', 'android_one');
-describe('action-stack', function() {
+describe('action-stack', function () {
var stack;
- beforeEach(function() {
- stack = new action_stack();
+ beforeEach(function () {
+ stack = new action_stack(); /* eslint new-cap : 0 */
});
- describe('processing of actions', function() {
- it('Test 001 : should process actions one at a time until all are done', function() {
+ describe('processing of actions', function () {
+ it('Test 001 : should process actions one at a time until all are done', function () {
var first_spy = jasmine.createSpy();
var first_args = [1];
var second_spy = jasmine.createSpy();
var second_args = [2];
var third_spy = jasmine.createSpy();
var third_args = [3];
- stack.push(stack.createAction(first_spy, first_args, function(){}, []));
- stack.push(stack.createAction(second_spy, second_args, function(){}, []));
- stack.push(stack.createAction(third_spy, third_args, function(){}, []));
+ stack.push(stack.createAction(first_spy, first_args, function () {}, []));
+ stack.push(stack.createAction(second_spy, second_args, function () {}, []));
+ stack.push(stack.createAction(third_spy, third_args, function () {}, []));
stack.process('android', android_one_project);
expect(first_spy).toHaveBeenCalledWith(first_args[0]);
expect(second_spy).toHaveBeenCalledWith(second_args[0]);
expect(third_spy).toHaveBeenCalledWith(third_args[0]);
});
- it('Test 002 : should revert processed actions if an exception occurs', function(done) {
+ it('Test 002 : should revert processed actions if an exception occurs', function (done) {
spyOn(console, 'log');
var first_spy = jasmine.createSpy();
var first_args = [1];
var first_reverter = jasmine.createSpy();
var first_reverter_args = [true];
var process_err = new Error('process_err');
- var second_spy = jasmine.createSpy().and.callFake(function() {
+ var second_spy = jasmine.createSpy().and.callFake(function () {
throw process_err;
});
var second_args = [2];
var third_spy = jasmine.createSpy();
var third_args = [3];
stack.push(stack.createAction(first_spy, first_args, first_reverter, first_reverter_args));
- stack.push(stack.createAction(second_spy, second_args, function(){}, []));
- stack.push(stack.createAction(third_spy, third_args, function(){}, []));
+ stack.push(stack.createAction(second_spy, second_args, function () {}, []));
+ stack.push(stack.createAction(third_spy, third_args, function () {}, []));
// process should throw
var error;
stack.process('android', android_one_project)
- .then(function(){
- expect(false).toBe(true);
- }).fail(function(err){
- error = err;
- expect(error).toEqual(process_err);
- // first two actions should have been called, but not the third
- expect(first_spy).toHaveBeenCalledWith(first_args[0]);
- expect(second_spy).toHaveBeenCalledWith(second_args[0]);
- expect(third_spy).not.toHaveBeenCalledWith(third_args[0]);
- // first reverter should have been called after second action exploded
- expect(first_reverter).toHaveBeenCalledWith(first_reverter_args[0]);
- }).fin(done);
+ .then(function () {
+ expect(false).toBe(true);
+ }).fail(function (err) {
+ error = err;
+ expect(error).toEqual(process_err);
+ // first two actions should have been called, but not the third
+ expect(first_spy).toHaveBeenCalledWith(first_args[0]);
+ expect(second_spy).toHaveBeenCalledWith(second_args[0]);
+ expect(third_spy).not.toHaveBeenCalledWith(third_args[0]);
+ // first reverter should have been called after second action exploded
+ expect(first_reverter).toHaveBeenCalledWith(first_reverter_args[0]);
+ }).fin(done);
});
});
});
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/ConfigChanges/ConfigChanges.spec.js
----------------------------------------------------------------------
diff --git a/spec/ConfigChanges/ConfigChanges.spec.js b/spec/ConfigChanges/ConfigChanges.spec.js
index 096a8ec..79e109a 100644
--- a/spec/ConfigChanges/ConfigChanges.spec.js
+++ b/spec/ConfigChanges/ConfigChanges.spec.js
@@ -17,29 +17,27 @@
under the License.
*/
-/* jshint sub:true */
-
-var configChanges = require('../../src/ConfigChanges/ConfigChanges'),
- xml_helpers = require('../../src/util/xml-helpers'),
- fs = require('fs'),
- os = require('osenv'),
- et = require('elementtree'),
- path = require('path'),
- shell = require('shelljs'),
- temp = path.join(os.tmpdir(), 'plugman'),
- dummyplugin = path.join(__dirname, '../fixtures/plugins/org.test.plugins.dummyplugin'),
- cbplugin = path.join(__dirname, '../fixtures/plugins/org.test.plugins.childbrowser'),
- childrenplugin = path.join(__dirname, '../fixtures/plugins/org.test.multiple-children'),
- shareddepsplugin = path.join(__dirname, '../fixtures/plugins/org.test.shareddeps'),
- configplugin = path.join(__dirname, '../fixtures/plugins/org.test.configtest'),
- editconfigplugin = path.join(__dirname, '../fixtures/plugins/org.test.editconfigtest'),
- editconfigplugin_two = path.join(__dirname, '../fixtures/plugins/org.test.editconfigtest_two'),
- varplugin = path.join(__dirname, '../fixtures/plugins/com.adobe.vars'),
- plistplugin = path.join(__dirname, '../fixtures/plugins/org.apache.plist'),
- android_two_project = path.join(__dirname, '../fixtures/projects/android_two/*'),
- android_two_no_perms_project = path.join(__dirname, '../fixtures/projects/android_two_no_perms', '*'),
- ios_config_xml = path.join(__dirname, '../fixtures/projects/ios-config-xml/*'),
- plugins_dir = path.join(temp, 'cordova', 'plugins');
+var configChanges = require('../../src/ConfigChanges/ConfigChanges');
+var xml_helpers = require('../../src/util/xml-helpers');
+var fs = require('fs');
+var os = require('osenv');
+var et = require('elementtree');
+var path = require('path');
+var shell = require('shelljs');
+var temp = path.join(os.tmpdir(), 'plugman');
+var dummyplugin = path.join(__dirname, '../fixtures/plugins/org.test.plugins.dummyplugin');
+var cbplugin = path.join(__dirname, '../fixtures/plugins/org.test.plugins.childbrowser');
+var childrenplugin = path.join(__dirname, '../fixtures/plugins/org.test.multiple-children');
+var shareddepsplugin = path.join(__dirname, '../fixtures/plugins/org.test.shareddeps');
+var configplugin = path.join(__dirname, '../fixtures/plugins/org.test.configtest');
+var editconfigplugin = path.join(__dirname, '../fixtures/plugins/org.test.editconfigtest');
+var editconfigplugin_two = path.join(__dirname, '../fixtures/plugins/org.test.editconfigtest_two');
+var varplugin = path.join(__dirname, '../fixtures/plugins/com.adobe.vars');
+var plistplugin = path.join(__dirname, '../fixtures/plugins/org.apache.plist');
+var android_two_project = path.join(__dirname, '../fixtures/projects/android_two/*');
+var android_two_no_perms_project = path.join(__dirname, '../fixtures/projects/android_two_no_perms', '*');
+var ios_config_xml = path.join(__dirname, '../fixtures/projects/ios-config-xml/*');
+var plugins_dir = path.join(temp, 'cordova', 'plugins');
var mungeutil = require('../../src/ConfigChanges/munge-util');
var PlatformJson = require('../../src/PlatformJson');
var PluginInfoProvider = require('../../src/PluginInfo/PluginInfoProvider');
@@ -53,43 +51,43 @@ var cfg = new ConfigParser(xml);
var pluginInfoProvider = new PluginInfoProvider();
-function innerXML(xmltext) {
- return xmltext.replace(/^<[\w\s\-=\/"\.]+>/, '').replace(/<\/[\w\s\-=\/"\.]+>$/,'');
+function innerXML (xmltext) {
+ return xmltext.replace(/^<[\w\s\-=\/"\.]+>/, '').replace(/<\/[\w\s\-=\/"\.]+>$/, ''); /* eslint no-useless-escape : 0 */
}
-function get_munge_change(munge, keys) {
+function get_munge_change (munge, keys) {
return mungeutil.deep_find.apply(null, arguments);
}
-describe('config-changes module', function() {
- beforeEach(function() {
+describe('config-changes module', function () {
+ beforeEach(function () {
shell.mkdir('-p', temp);
shell.mkdir('-p', plugins_dir);
});
- afterEach(function() {
+ afterEach(function () {
shell.rm('-rf', temp);
});
- describe('queue methods', function() {
- describe('addInstalledPluginToPrepareQueue', function() {
- it('Test 001 : should append specified plugin to platform.json', function() {
+ describe('queue methods', function () {
+ describe('addInstalledPluginToPrepareQueue', function () {
+ it('Test 001 : should append specified plugin to platform.json', function () {
var platformJson = new PlatformJson(null, 'android', null);
platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', {});
var json = platformJson.root;
expect(json.prepare_queue.installed[0].plugin).toEqual('org.test.plugins.dummyplugin');
expect(json.prepare_queue.installed[0].vars).toEqual({});
});
- it('Test 002 : should append specified plugin with any variables to platform.json', function() {
+ it('Test 002 : should append specified plugin with any variables to platform.json', function () {
var platformJson = new PlatformJson(null, 'android', null);
- platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', {'dude':'man'});
+ platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', {'dude': 'man'});
var json = platformJson.root;
expect(json.prepare_queue.installed[0].plugin).toEqual('org.test.plugins.dummyplugin');
- expect(json.prepare_queue.installed[0].vars).toEqual({'dude':'man'});
+ expect(json.prepare_queue.installed[0].vars).toEqual({'dude': 'man'});
});
});
- describe('addUninstalledPluginToPrepareQueue', function() {
- it('Test 003 : should append specified plugin to platform.json', function() {
+ describe('addUninstalledPluginToPrepareQueue', function () {
+ it('Test 003 : should append specified plugin to platform.json', function () {
var platformJson = new PlatformJson(null, 'android', null);
platformJson.addUninstalledPluginToPrepareQueue('org.test.plugins.dummyplugin');
var json = platformJson.root;
@@ -98,15 +96,15 @@ describe('config-changes module', function() {
});
});
- describe('load method', function() {
- it('Test 004 : should return an empty config json object if file doesn\'t exist', function() {
+ describe('load method', function () {
+ it('Test 004 : should return an empty config json object if file doesn\'t exist', function () {
var platformJson = PlatformJson.load(plugins_dir, 'android');
expect(platformJson.root).toBeDefined();
expect(platformJson.root.prepare_queue).toBeDefined();
expect(platformJson.root.config_munge).toBeDefined();
expect(platformJson.root.installed_plugins).toBeDefined();
});
- it('Test 005 : should return the json file if it exists', function() {
+ it('Test 005 : should return the json file if it exists', function () {
var filepath = path.join(plugins_dir, 'android.json');
var json = {
prepare_queue: {installed: [], uninstalled: []},
@@ -119,42 +117,42 @@ describe('config-changes module', function() {
});
});
- describe('save method', function() {
- it('Test 006 : should write out specified json', function() {
+ describe('save method', function () {
+ it('Test 006 : should write out specified json', function () {
var filepath = path.join(plugins_dir, 'android.json');
- var platformJson = new PlatformJson(filepath, 'android', {foo:true});
+ var platformJson = new PlatformJson(filepath, 'android', {foo: true});
platformJson.save();
expect(JSON.parse(fs.readFileSync(filepath, 'utf-8'))).toEqual(platformJson.root);
});
});
- describe('generate_plugin_config_munge method', function() {
- describe('for android projects', function() {
- beforeEach(function() {
+ describe('generate_plugin_config_munge method', function () {
+ describe('for android projects', function () {
+ beforeEach(function () {
shell.cp('-rf', android_two_project, temp);
});
- it('Test 007 : should return a flat config hierarchy for simple, one-off config changes', function() {
+ it('Test 007 : should return a flat config hierarchy for simple, one-off config changes', function () {
var xml;
var dummy_xml = new et.ElementTree(et.XML(fs.readFileSync(path.join(dummyplugin, 'plugin.xml'), 'utf-8')));
var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(dummyplugin), {});
expect(munge.files['AndroidManifest.xml']).toBeDefined();
expect(munge.files['AndroidManifest.xml'].parents['/manifest/application']).toBeDefined();
- xml = (new et.ElementTree(dummy_xml.find('./platform[@name="android"]/config-file[@target="AndroidManifest.xml"]'))).write({xml_declaration:false});
+ xml = (new et.ElementTree(dummy_xml.find('./platform[@name="android"]/config-file[@target="AndroidManifest.xml"]'))).write({xml_declaration: false});
xml = innerXML(xml);
expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest/application', xml).count).toEqual(1);
expect(munge.files['res/xml/plugins.xml']).toBeDefined();
expect(munge.files['res/xml/plugins.xml'].parents['/plugins']).toBeDefined();
- xml = (new et.ElementTree(dummy_xml.find('./platform[@name="android"]/config-file[@target="res/xml/plugins.xml"]'))).write({xml_declaration:false});
+ xml = (new et.ElementTree(dummy_xml.find('./platform[@name="android"]/config-file[@target="res/xml/plugins.xml"]'))).write({xml_declaration: false});
xml = innerXML(xml);
expect(get_munge_change(munge, 'res/xml/plugins.xml', '/plugins', xml).count).toEqual(1);
expect(munge.files['res/xml/config.xml']).toBeDefined();
expect(munge.files['res/xml/config.xml'].parents['/cordova/plugins']).toBeDefined();
- xml = (new et.ElementTree(dummy_xml.find('./platform[@name="android"]/config-file[@target="res/xml/config.xml"]'))).write({xml_declaration:false});
+ xml = (new et.ElementTree(dummy_xml.find('./platform[@name="android"]/config-file[@target="res/xml/config.xml"]'))).write({xml_declaration: false});
xml = innerXML(xml);
expect(get_munge_change(munge, 'res/xml/config.xml', '/cordova/plugins', xml).count).toEqual(1);
});
- it('Test 008 : should split out multiple children of config-file elements into individual leaves', function() {
+ it('Test 008 : should split out multiple children of config-file elements into individual leaves', function () {
var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(childrenplugin), {PACKAGE_NAME: 'com.alunny.childapp'});
expect(munge.files['AndroidManifest.xml']).toBeDefined();
@@ -169,23 +167,23 @@ describe('config-changes module', function() {
expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest', '<uses-permission android:name="com.alunny.childapp.permission.C2D_MESSAGE" />')).toBeDefined();
expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest', '<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />')).toBeDefined();
});
- it('Test 009 : should not use xml comments as config munge leaves', function() {
+ it('Test 009 : should not use xml comments as config munge leaves', function () {
var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(childrenplugin), {});
expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest', '<!--library-->')).not.toBeDefined();
expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest', '<!-- GCM connects to Google Services. -->')).not.toBeDefined();
});
- it('Test 010 : should increment config hierarchy leaves if different config-file elements target the same file + selector + xml', function() {
+ it('Test 010 : should increment config hierarchy leaves if different config-file elements target the same file + selector + xml', function () {
var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(configplugin), {});
expect(get_munge_change(munge, 'res/xml/config.xml', '/widget', '<poop />').count).toEqual(2);
});
- it('Test 011 : should take into account interpolation variables', function() {
+ it('Test 011 : should take into account interpolation variables', function () {
var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
- var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(childrenplugin), {PACKAGE_NAME:'ca.filmaj.plugins'});
+ var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(childrenplugin), {PACKAGE_NAME: 'ca.filmaj.plugins'});
expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest', '<uses-permission android:name="ca.filmaj.plugins.permission.C2D_MESSAGE" />')).toBeDefined();
});
- it('Test 012 : should create munges for platform-agnostic config.xml changes', function() {
+ it('Test 012 : should create munges for platform-agnostic config.xml changes', function () {
var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(dummyplugin), {});
expect(get_munge_change(munge, 'config.xml', '/*', '<access origin="build.phonegap.com" />')).toBeDefined();
@@ -194,27 +192,27 @@ describe('config-changes module', function() {
});
});
- describe('processing of plugins (via process method)', function() {
- beforeEach(function() {
+ describe('processing of plugins (via process method)', function () {
+ beforeEach(function () {
shell.cp('-rf', dummyplugin, plugins_dir);
});
- it('Test 014 : should generate config munges for queued plugins', function() {
+ it('Test 014 : should generate config munges for queued plugins', function () {
shell.cp('-rf', android_two_project, temp);
var platformJson = PlatformJson.load(plugins_dir, 'android');
- platformJson.root.prepare_queue.installed = [{'plugin':'org.test.plugins.dummyplugin', 'vars':{}}];
+ platformJson.root.prepare_queue.installed = [{'plugin': 'org.test.plugins.dummyplugin', 'vars': {}}];
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
var spy = spyOn(munger, 'generate_plugin_config_munge').and.returnValue({});
munger.process(plugins_dir);
expect(spy).toHaveBeenCalledWith(jasmine.any(PluginInfo), {});
});
- describe(': installation', function() {
- describe('of xml config files', function() {
- beforeEach(function() {
+ describe(': installation', function () {
+ describe('of xml config files', function () {
+ beforeEach(function () {
shell.cp('-rf', android_two_project, temp);
});
- it('Test 015 : should call graftXML for every new config munge it introduces (every leaf in config munge that does not exist)', function() {
+ it('Test 015 : should call graftXML for every new config munge it introduces (every leaf in config munge that does not exist)', function () {
var platformJson = PlatformJson.load(plugins_dir, 'android');
- platformJson.root.prepare_queue.installed = [{'plugin':'org.test.plugins.dummyplugin', 'vars':{}}];
+ platformJson.root.prepare_queue.installed = [{'plugin': 'org.test.plugins.dummyplugin', 'vars': {}}];
var spy = spyOn(xml_helpers, 'graftXML').and.returnValue(true);
@@ -226,7 +224,7 @@ describe('config-changes module', function() {
expect(spy.calls.argsFor(2)[2]).toEqual('/manifest/application');
expect(spy.calls.argsFor(3)[2]).toEqual('/cordova/plugins');
});
- it('Test 016 : should not call graftXML for a config munge that already exists from another plugin', function() {
+ it('Test 016 : should not call graftXML for a config munge that already exists from another plugin', function () {
shell.cp('-rf', configplugin, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.configtest', {});
@@ -236,7 +234,7 @@ describe('config-changes module', function() {
munger.process(plugins_dir);
expect(spy.calls.count()).toEqual(1);
});
- it('Test 017 : should not call graftXML for a config munge targeting a config file that does not exist', function() {
+ it('Test 017 : should not call graftXML for a config munge targeting a config file that does not exist', function () {
var platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', {});
@@ -246,7 +244,7 @@ describe('config-changes module', function() {
munger.process(plugins_dir);
expect(spy).not.toHaveBeenCalledWith(path.join(temp, 'res', 'xml', 'plugins.xml'), 'utf-8');
});
- it('Test 018 : should call graftXMLMerge for every new config munge with mode \'merge\' it introduces', function() {
+ it('Test 018 : should call graftXMLMerge for every new config munge with mode \'merge\' it introduces', function () {
shell.cp('-rf', editconfigplugin, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest', {});
@@ -258,7 +256,7 @@ describe('config-changes module', function() {
expect(spy.calls.count()).toEqual(1);
expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/application/activity[@android:name=\'org.test.DroidGap\']');
});
- it('Test 019 : should call graftXMLMerge with --force for every new config munge with mode \'merge\' it introduces', function() {
+ it('Test 019 : should call graftXMLMerge with --force for every new config munge with mode \'merge\' it introduces', function () {
shell.cp('-rf', editconfigplugin, plugins_dir);
shell.cp('-rf', editconfigplugin_two, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
@@ -274,7 +272,7 @@ describe('config-changes module', function() {
expect(spy.calls.argsFor(1)[2]).toEqual('/manifest/application/activity[@android:name=\'org.test.DroidGap\']');
expect(spy.calls.argsFor(2)[2]).toEqual('/manifest/uses-sdk');
});
- it('Test 020 : should call graftXMLOverwrite for every new config munge with mode \'overwrite\' it introduces', function() {
+ it('Test 020 : should call graftXMLOverwrite for every new config munge with mode \'overwrite\' it introduces', function () {
shell.cp('-rf', editconfigplugin, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest', {});
@@ -286,7 +284,7 @@ describe('config-changes module', function() {
expect(spy.calls.count()).toEqual(1);
expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/application/activity');
});
- it('Test 021 : should call graftXMLOverwrite with --force for every new config munge with mode \'overwrite\' it introduces', function() {
+ it('Test 021 : should call graftXMLOverwrite with --force for every new config munge with mode \'overwrite\' it introduces', function () {
shell.cp('-rf', editconfigplugin, plugins_dir);
shell.cp('-rf', editconfigplugin_two, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
@@ -301,7 +299,7 @@ describe('config-changes module', function() {
expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/application/activity');
expect(spy.calls.argsFor(1)[2]).toEqual('/manifest/application/activity[@android:name=\'ChildApp\']');
});
- it('Test 022 : should not install plugin when there are edit-config conflicts', function() {
+ it('Test 022 : should not install plugin when there are edit-config conflicts', function () {
shell.cp('-rf', editconfigplugin, plugins_dir);
shell.cp('-rf', editconfigplugin_two, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
@@ -309,9 +307,9 @@ describe('config-changes module', function() {
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest_two', {});
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
- expect(function() {munger.process(plugins_dir);}).toThrow(new Error('There was a conflict trying to modify attributes with <edit-config> in plugin org.test.editconfigtest_two. The conflicting plugin, org.test.editconfigtest, already modified the same attributes. The conflict must be resolved before org.test.editconfigtest_two can be added. You may use --force to add the plugin and overwrite the conflicting attributes.'));
+ expect(function () { munger.process(plugins_dir); }).toThrow(new Error('There was a conflict trying to modify attributes with <edit-config> in plugin org.test.editconfigtest_two. The conflicting plugin, org.test.editconfigtest, already modified the same attributes. The conflict must be resolved before org.test.editconfigtest_two can be added. You may use --force to add the plugin and overwrite the conflicting attributes.'));
});
- it('should call graftXMLMerge for every new config.xml config munge with mode \'merge\' it introduces', function() {
+ it('should call graftXMLMerge for every new config.xml config munge with mode \'merge\' it introduces', function () {
var platformJson = PlatformJson.load(plugins_dir, 'android');
var spy = spyOn(xml_helpers, 'graftXMLMerge').and.returnValue(true);
@@ -322,7 +320,7 @@ describe('config-changes module', function() {
expect(spy.calls.count()).toEqual(1);
expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/uses-sdk');
});
- it('should call graftXMLOverwrite for every new config.xml config munge with mode \'overwrite\' it introduces', function() {
+ it('should call graftXMLOverwrite for every new config.xml config munge with mode \'overwrite\' it introduces', function () {
var platformJson = PlatformJson.load(plugins_dir, 'android');
var spy = spyOn(xml_helpers, 'graftXMLOverwrite').and.returnValue(true);
@@ -333,7 +331,7 @@ describe('config-changes module', function() {
expect(spy.calls.count()).toEqual(1);
expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/uses-sdk');
});
- it('should call pruneXMLRemove for every new config.xml config munge with mode \'remove\' it introduces', function() {
+ it('should call pruneXMLRemove for every new config.xml config munge with mode \'remove\' it introduces', function () {
var platformJson = PlatformJson.load(plugins_dir, 'android');
// var spy = spyOn(xml_helpers, 'pruneXMLRemove').andReturn(true);
@@ -347,7 +345,7 @@ describe('config-changes module', function() {
expect(sdk).toBeDefined();
expect(sdk.attrib['android:maxSdkVersion']).toBeUndefined();
});
- it('should overwrite plugin config munge for every conflicting config.xml config munge', function() {
+ it('should overwrite plugin config munge for every conflicting config.xml config munge', function () {
shell.cp('-rf', editconfigplugin_two, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest_two', {}, true, true);
@@ -361,7 +359,7 @@ describe('config-changes module', function() {
expect(sdk).toBeDefined();
expect(sdk.attrib['android:targetSdkVersion']).toEqual('24');
});
- it('should overwrite config.xml config munge for every new config.xml config munge that has the same target', function() {
+ it('should overwrite config.xml config munge for every new config.xml config munge that has the same target', function () {
var editconfig_cfg = new ConfigParser(editconfig_xml);
var platformJson = PlatformJson.load(plugins_dir, 'android');
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
@@ -376,27 +374,27 @@ describe('config-changes module', function() {
expect(sdk.attrib['android:minSdkVersion']).toEqual('5');
expect(sdk.attrib['android:maxSdkVersion']).toBeUndefined();
});
- it('should throw error for conflicting plugin config munge with config.xml config munge', function() {
+ it('should throw error for conflicting plugin config munge with config.xml config munge', function () {
shell.cp('-rf', editconfigplugin_two, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest_two', {}, true, true);
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.add_config_changes(cfg, true);
- expect(function() {munger.process(plugins_dir);}).toThrow(new Error('org.test.editconfigtest_two cannot be added. <edit-config> changes in this plugin conflicts with <edit-config> changes in config.xml. Conflicts must be resolved before plugin can be added.'));
+ expect(function () { munger.process(plugins_dir); }).toThrow(new Error('org.test.editconfigtest_two cannot be added. <edit-config> changes in this plugin conflicts with <edit-config> changes in config.xml. Conflicts must be resolved before plugin can be added.'));
});
});
- describe('of plist config files', function() {
- it('Test 023 : should write empty string nodes with no whitespace', function() {
+ describe('of plist config files', function () {
+ it('Test 023 : should write empty string nodes with no whitespace', function () {
shell.cp('-rf', ios_config_xml, temp);
shell.cp('-rf', varplugin, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'ios');
platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', {});
configChanges.process(plugins_dir, temp, 'ios', platformJson, pluginInfoProvider);
- expect(fs.readFileSync(path.join(temp, 'SampleApp', 'SampleApp-Info.plist'), 'utf-8')).toMatch(/<key>APluginNode<\/key>\n <string\/>/m);
+ expect(fs.readFileSync(path.join(temp, 'SampleApp', 'SampleApp-Info.plist'), 'utf-8')).toMatch(/<key>APluginNode<\/key>\n {4}<string\/>/m);
});
- it('Test 024 : should merge dictionaries and arrays, removing duplicates', function() {
+ it('Test 024 : should merge dictionaries and arrays, removing duplicates', function () {
shell.cp('-rf', ios_config_xml, temp);
shell.cp('-rf', plistplugin, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'ios');
@@ -407,7 +405,7 @@ describe('config-changes module', function() {
expect(fs.readFileSync(path.join(temp, 'SampleApp', 'SampleApp-Info.plist'), 'utf-8')).not.toMatch(/(<string>schema-a<\/string>[^]*){2,}/);
});
});
- it('Test 025 : should resolve wildcard config-file targets to the project, if applicable', function() {
+ it('Test 025 : should resolve wildcard config-file targets to the project, if applicable', function () {
shell.cp('-rf', ios_config_xml, temp);
shell.cp('-rf', cbplugin, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'ios');
@@ -418,11 +416,11 @@ describe('config-changes module', function() {
munger.process(plugins_dir);
expect(spy).toHaveBeenCalledWith(path.join(temp, 'SampleApp', 'SampleApp-Info.plist').replace(/\\/g, '/'), 'utf8');
});
- it('Test 026 : should move successfully installed plugins from queue to installed plugins section, and include/retain vars if applicable', function() {
+ it('Test 026 : should move successfully installed plugins from queue to installed plugins section, and include/retain vars if applicable', function () {
shell.cp('-rf', android_two_project, temp);
shell.cp('-rf', varplugin, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
- platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', {'API_KEY':'hi'}, true);
+ platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', {'API_KEY': 'hi'}, true);
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
@@ -433,8 +431,8 @@ describe('config-changes module', function() {
});
});
- describe(': uninstallation', function() {
- it('Test 027 : should call pruneXML for every config munge it completely removes from the app (every leaf that is decremented to 0)', function() {
+ describe(': uninstallation', function () {
+ it('Test 027 : should call pruneXML for every config munge it completely removes from the app (every leaf that is decremented to 0)', function () {
shell.cp('-rf', android_two_project, temp);
// Run through an "install"
@@ -453,12 +451,12 @@ describe('config-changes module', function() {
expect(spy.calls.argsFor(2)[2]).toEqual('/manifest/application');
expect(spy.calls.argsFor(3)[2]).toEqual('/cordova/plugins');
});
- it('Test 028 : should generate a config munge that interpolates variables into config changes, if applicable', function() {
+ it('Test 028 : should generate a config munge that interpolates variables into config changes, if applicable', function () {
shell.cp('-rf', android_two_project, temp);
shell.cp('-rf', varplugin, plugins_dir);
// Run through an "install"
var platformJson = PlatformJson.load(plugins_dir, 'android');
- platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', {'API_KEY':'canucks'});
+ platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', {'API_KEY': 'canucks'});
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
@@ -471,7 +469,7 @@ describe('config-changes module', function() {
expect(munge_params[0].dir).toEqual(path.join(plugins_dir, 'com.adobe.vars'));
expect(munge_params[1]['API_KEY']).toEqual('canucks');
});
- it('Test 029 : should not call pruneXML for a config munge that another plugin depends on', function() {
+ it('Test 029 : should not call pruneXML for a config munge that another plugin depends on', function () {
shell.cp('-rf', android_two_no_perms_project, temp);
shell.cp('-rf', childrenplugin, plugins_dir);
shell.cp('-rf', shareddepsplugin, plugins_dir);
@@ -492,7 +490,7 @@ describe('config-changes module', function() {
expect(permission).toBeDefined();
expect(permission.attrib['android:name']).toEqual('android.permission.INTERNET');
});
- it('Test 030 : should not call pruneXML for a config munge targeting a config file that does not exist', function() {
+ it('Test 030 : should not call pruneXML for a config munge targeting a config file that does not exist', function () {
shell.cp('-rf', android_two_project, temp);
// install a plugin
var platformJson = PlatformJson.load(plugins_dir, 'android');
@@ -508,12 +506,12 @@ describe('config-changes module', function() {
expect(spy).not.toHaveBeenCalledWith(path.join(temp, 'res', 'xml', 'plugins.xml'), 'utf-8');
});
- it('Test 031 : should remove uninstalled plugins from installed plugins list', function() {
+ it('Test 031 : should remove uninstalled plugins from installed plugins list', function () {
shell.cp('-rf', android_two_project, temp);
shell.cp('-rf', varplugin, plugins_dir);
// install the var plugin
var platformJson = PlatformJson.load(plugins_dir, 'android');
- platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', {'API_KEY':'eat my shorts'});
+ platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', {'API_KEY': 'eat my shorts'});
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
@@ -524,7 +522,7 @@ describe('config-changes module', function() {
expect(platformJson.root.prepare_queue.uninstalled.length).toEqual(0);
expect(platformJson.root.installed_plugins['com.adobe.vars']).not.toBeDefined();
});
- it('Test 032 : should call pruneXMLRestore for every config munge with mode \'merge\' or \'overwrite\' it removes from the app', function() {
+ it('Test 032 : should call pruneXMLRestore for every config munge with mode \'merge\' or \'overwrite\' it removes from the app', function () {
shell.cp('-rf', android_two_project, temp);
shell.cp('-rf', editconfigplugin, plugins_dir);
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/ConfigParser/ConfigParser.spec.js
----------------------------------------------------------------------
diff --git a/spec/ConfigParser/ConfigParser.spec.js b/spec/ConfigParser/ConfigParser.spec.js
index 034f3d7..1075e83 100644
--- a/spec/ConfigParser/ConfigParser.spec.js
+++ b/spec/ConfigParser/ConfigParser.spec.js
@@ -16,19 +16,20 @@
specific language governing permissions and limitations
under the License.
*/
-var path = require('path'),
- fs = require('fs'),
- ConfigParser = require('../../src/ConfigParser/ConfigParser'),
- xml = path.join(__dirname, '../fixtures/test-config.xml'),
- xml_contents = fs.readFileSync(xml, 'utf-8');
+
+var path = require('path');
+var fs = require('fs');
+var ConfigParser = require('../../src/ConfigParser/ConfigParser');
+var xml = path.join(__dirname, '../fixtures/test-config.xml');
+var xml_contents = fs.readFileSync(xml, 'utf-8');
describe('config.xml parser', function () {
- var readFile;
- beforeEach(function() {
+ var readFile; /* eslint no-unused-vars : 0 */
+ beforeEach(function () {
readFile = spyOn(fs, 'readFileSync').and.returnValue(xml_contents);
});
- it('Test 001 : should create an instance based on an xml file', function() {
+ it('Test 001 : should create an instance based on an xml file', function () {
var cfg;
expect(function () {
cfg = new ConfigParser(xml);
@@ -37,59 +38,59 @@ describe('config.xml parser', function () {
expect(cfg.doc).toBeDefined();
});
- describe('methods', function() {
+ describe('methods', function () {
var cfg;
- beforeEach(function() {
+ beforeEach(function () {
cfg = new ConfigParser(xml);
});
- describe('package name / id', function() {
- it('Test 002 : should get the (default) packagename', function() {
+ describe('package name / id', function () {
+ it('Test 002 : should get the (default) packagename', function () {
expect(cfg.packageName()).toEqual('io.cordova.hellocordova');
});
- it('Test 003 : should allow setting the packagename', function() {
+ it('Test 003 : should allow setting the packagename', function () {
cfg.setPackageName('this.is.bat.country');
expect(cfg.packageName()).toEqual('this.is.bat.country');
});
});
- describe('package name / android-packageName', function() {
- it('Test 004 : should get the android packagename', function() {
+ describe('package name / android-packageName', function () {
+ it('Test 004 : should get the android packagename', function () {
expect(cfg.android_packageName()).toEqual('io.cordova.hellocordova.android');
});
});
- describe('package name / ios-CFBundleIdentifier', function() {
- it('Test 005 : should get the ios packagename', function() {
+ describe('package name / ios-CFBundleIdentifier', function () {
+ it('Test 005 : should get the ios packagename', function () {
expect(cfg.ios_CFBundleIdentifier()).toEqual('io.cordova.hellocordova.ios');
});
});
- describe('version', function() {
- it('Test 006 : should get the version', function() {
+ describe('version', function () {
+ it('Test 006 : should get the version', function () {
expect(cfg.version()).toEqual('0.0.1');
});
- it('Test 007 : should allow setting the version', function() {
+ it('Test 007 : should allow setting the version', function () {
cfg.setVersion('2.0.1');
expect(cfg.version()).toEqual('2.0.1');
});
});
- describe('app name', function() {
- it('Test 008 : should get the (default) app name', function() {
+ describe('app name', function () {
+ it('Test 008 : should get the (default) app name', function () {
expect(cfg.name()).toEqual('Hello Cordova');
});
- it('Test 009 : should allow setting the app name', function() {
+ it('Test 009 : should allow setting the app name', function () {
cfg.setName('this.is.bat.country');
expect(cfg.name()).toEqual('this.is.bat.country');
});
- describe('short name', function() {
- it('should default to the app name', function() {
+ describe('short name', function () {
+ it('should default to the app name', function () {
expect(cfg.shortName()).toEqual('Hello Cordova');
});
- it('should allow setting the app short name', function() {
+ it('should allow setting the app short name', function () {
cfg.setShortName('Hi CDV');
expect(cfg.name()).toEqual('Hello Cordova');
expect(cfg.shortName()).toEqual('Hi CDV');
@@ -97,73 +98,73 @@ describe('config.xml parser', function () {
});
});
- describe('preference', function() {
- it('Test 010 : should return the value of a global preference', function() {
+ describe('preference', function () {
+ it('Test 010 : should return the value of a global preference', function () {
expect(cfg.getPreference('fullscreen')).toEqual('true');
});
- it('Test 011 : should return the value of a platform-specific preference', function() {
+ it('Test 011 : should return the value of a platform-specific preference', function () {
expect(cfg.getPreference('android-minSdkVersion', 'android')).toEqual('10');
});
- it('Test 012 : should return an empty string for a non-existing preference', function() {
+ it('Test 012 : should return an empty string for a non-existing preference', function () {
expect(cfg.getPreference('zimzooo!')).toEqual('');
});
});
- describe('global preference', function() {
- it('Test 013 : should return the value of a global preference', function() {
+ describe('global preference', function () {
+ it('Test 013 : should return the value of a global preference', function () {
expect(cfg.getGlobalPreference('orientation')).toEqual('portrait');
});
- it('Test 014 : should return an empty string for a non-existing preference', function() {
+ it('Test 014 : should return an empty string for a non-existing preference', function () {
expect(cfg.getGlobalPreference('foobar')).toEqual('');
});
});
- describe('platform-specific preference', function() {
- it('Test 015 : should return the value of a platform specific preference', function() {
+ describe('platform-specific preference', function () {
+ it('Test 015 : should return the value of a platform specific preference', function () {
expect(cfg.getPlatformPreference('orientation', 'android')).toEqual('landscape');
});
- it('Test 016 : should return an empty string when querying for a non-existing preference', function() {
+ it('Test 016 : should return an empty string when querying for a non-existing preference', function () {
expect(cfg.getPlatformPreference('foobar', 'android')).toEqual('');
});
- it('Test 017 : should return an empty string when querying with unsupported platform', function() {
+ it('Test 017 : should return an empty string when querying with unsupported platform', function () {
expect(cfg.getPlatformPreference('orientation', 'foobar')).toEqual('');
});
});
- describe('plugin',function(){
- it('Test 018 : should read plugin id list', function() {
- var expectedList = [
- 'org.apache.cordova.pluginwithvars',
- 'org.apache.cordova.pluginwithurl',
- 'org.apache.cordova.pluginwithversion',
- 'org.apache.cordova.pluginwithurlandversion',
- 'org.apache.cordova.justaplugin',
- 'org.apache.cordova.legacyfeatureversion',
- 'org.apache.cordova.legacyfeatureurl',
- 'org.apache.cordova.legacyfeatureversionandurl'
- ];
- var list = cfg.getPluginIdList();
- expect(list.length).toEqual(expectedList.length);
- expectedList.forEach(function(plugin){
- expect(list).toContain(plugin);
- });
- });
- it('Test 019 : should read plugin given id', function(){
+ describe('plugin', function () {
+ it('Test 018 : should read plugin id list', function () {
+ var expectedList = [
+ 'org.apache.cordova.pluginwithvars',
+ 'org.apache.cordova.pluginwithurl',
+ 'org.apache.cordova.pluginwithversion',
+ 'org.apache.cordova.pluginwithurlandversion',
+ 'org.apache.cordova.justaplugin',
+ 'org.apache.cordova.legacyfeatureversion',
+ 'org.apache.cordova.legacyfeatureurl',
+ 'org.apache.cordova.legacyfeatureversionandurl'
+ ];
+ var list = cfg.getPluginIdList();
+ expect(list.length).toEqual(expectedList.length);
+ expectedList.forEach(function (plugin) {
+ expect(list).toContain(plugin);
+ });
+ });
+ it('Test 019 : should read plugin given id', function () {
var plugin = cfg.getPlugin('org.apache.cordova.justaplugin');
expect(plugin).toBeDefined();
expect(plugin.name).toEqual('org.apache.cordova.justaplugin');
expect(plugin.variables).toBeDefined();
});
- it('Test 020 : should not read plugin given undefined id', function(){
+ it('Test 020 : should not read plugin given undefined id', function () {
var plugin = cfg.getPlugin('org.apache.cordova.undefinedplugin');
expect(plugin).not.toBeDefined();
});
- it('Test 021 : should read plugin with src and store it in spec field', function(){
+ it('Test 021 : should read plugin with src and store it in spec field', function () {
var plugin = cfg.getPlugin('org.apache.cordova.pluginwithurl');
expect(plugin.spec).toEqual('http://cordova.apache.org/pluginwithurl');
});
- it('Test 022 : should read plugin with version and store it in spec field', function(){
+ it('Test 022 : should read plugin with version and store it in spec field', function () {
var plugin = cfg.getPlugin('org.apache.cordova.pluginwithversion');
expect(plugin.spec).toEqual('1.1.1');
});
- it('Test 023 : should read plugin with source and version and store source in spec field', function(){
+ it('Test 023 : should read plugin with source and version and store source in spec field', function () {
var plugin = cfg.getPlugin('org.apache.cordova.pluginwithurlandversion');
expect(plugin.spec).toEqual('http://cordova.apache.org/pluginwithurlandversion');
});
@@ -173,22 +174,22 @@ describe('config.xml parser', function () {
expect(plugin.variables.var).toBeDefined();
expect(plugin.variables.var).toEqual('varvalue');
});
- it('Test 025 : should allow adding a new plugin', function(){
- cfg.addPlugin({name:'myplugin'});
+ it('Test 025 : should allow adding a new plugin', function () {
+ cfg.addPlugin({name: 'myplugin'});
var plugins = cfg.doc.findall('plugin');
- var pluginNames = plugins.map(function(plugin){
+ var pluginNames = plugins.map(function (plugin) {
return plugin.attrib.name;
});
expect(pluginNames).toContain('myplugin');
});
- it('Test 026 : should allow adding features with params', function(){
- cfg.addPlugin({name:'aplugin'}, [{name:'paraname',value:'paravalue'}]);
+ it('Test 026 : should allow adding features with params', function () {
+ cfg.addPlugin({name: 'aplugin'}, [{name: 'paraname', value: 'paravalue'}]);
// Additional check for new parameters syntax
- cfg.addPlugin({name:'bplugin'}, {paraname: 'paravalue'});
+ cfg.addPlugin({name: 'bplugin'}, {paraname: 'paravalue'});
var plugins = cfg.doc.findall('plugin')
- .filter(function (plugin) {
- return plugin.attrib.name === 'aplugin' || plugin.attrib.name === 'bplugin';
- });
+ .filter(function (plugin) {
+ return plugin.attrib.name === 'aplugin' || plugin.attrib.name === 'bplugin';
+ });
expect(plugins.length).toBe(2);
plugins.forEach(function (plugin) {
var variables = plugin.findall('variable');
@@ -196,7 +197,7 @@ describe('config.xml parser', function () {
expect(variables[0].attrib.value).toEqual('paravalue');
});
});
- it('Test 027 : should be able to read legacy feature entries with a version', function(){
+ it('Test 027 : should be able to read legacy feature entries with a version', function () {
var plugin = cfg.getPlugin('org.apache.cordova.legacyfeatureversion');
expect(plugin).toBeDefined();
expect(plugin.name).toEqual('org.apache.cordova.legacyfeatureversion');
@@ -204,87 +205,87 @@ describe('config.xml parser', function () {
expect(plugin.variables).toBeDefined();
expect(plugin.variables.aVar).toEqual('aValue');
});
- it('Test 028 : should be able to read legacy feature entries with a url', function(){
+ it('Test 028 : should be able to read legacy feature entries with a url', function () {
var plugin = cfg.getPlugin('org.apache.cordova.legacyfeatureurl');
expect(plugin).toBeDefined();
expect(plugin.name).toEqual('org.apache.cordova.legacyfeatureurl');
expect(plugin.spec).toEqual('http://cordova.apache.org/legacyfeatureurl');
});
- it('Test 029 : should be able to read legacy feature entries with a version and a url', function(){
+ it('Test 029 : should be able to read legacy feature entries with a version and a url', function () {
var plugin = cfg.getPlugin('org.apache.cordova.legacyfeatureversionandurl');
expect(plugin).toBeDefined();
expect(plugin.name).toEqual('org.apache.cordova.legacyfeatureversionandurl');
expect(plugin.spec).toEqual('http://cordova.apache.org/legacyfeatureversionandurl');
});
- it('Test 030 : it should remove given plugin', function(){
+ it('Test 030 : it should remove given plugin', function () {
cfg.removePlugin('org.apache.cordova.justaplugin');
var plugins = cfg.doc.findall('plugin');
- var pluginNames = plugins.map(function(plugin){
+ var pluginNames = plugins.map(function (plugin) {
return plugin.attrib.name;
});
expect(pluginNames).not.toContain('org.apache.cordova.justaplugin');
});
- it('Test 031 : it should remove given legacy feature id', function(){
+ it('Test 031 : it should remove given legacy feature id', function () {
cfg.removePlugin('org.apache.cordova.legacyplugin');
var plugins = cfg.doc.findall('feature');
- var pluginNames = plugins.map(function(plugin){
+ var pluginNames = plugins.map(function (plugin) {
return plugin.attrib.name;
});
expect(pluginNames).not.toContain('org.apache.cordova.legacyplugin');
});
- it('Test 032 : it should read <access> tag entries', function(){
+ it('Test 032 : it should read <access> tag entries', function () {
var accesses = cfg.getAccesses();
expect(accesses.length).not.toEqual(0);
});
- it('Test 033 : it should read <allow-navigation> tag entries', function(){
+ it('Test 033 : it should read <allow-navigation> tag entries', function () {
var navigations = cfg.getAllowNavigations();
expect(navigations.length).not.toEqual(0);
});
- it('Test 034 : it should read <allow-intent> tag entries', function(){
+ it('Test 034 : it should read <allow-intent> tag entries', function () {
var intents = cfg.getAllowIntents();
expect(intents.length).not.toEqual(0);
});
- it('it should read <edit-config> tag entries', function(){
+ it('it should read <edit-config> tag entries', function () {
var editConfigs = cfg.getEditConfigs('android');
expect(editConfigs.length).not.toEqual(0);
});
});
- describe('static resources', function() {
+ describe('static resources', function () {
var hasPlatformPropertyDefined = function (e) { return !!e.platform; };
var hasSrcPropertyDefined = function (e) { return !!e.src; };
var hasTargetPropertyDefined = function (e) { return !!e.target; };
var hasDensityPropertyDefined = function (e) { return !!e.density; };
var hasPlatformPropertyUndefined = function (e) { return !e.platform; };
- it('Test 035 : should fetch shared resources if platform parameter is not specified', function() {
+ it('Test 035 : should fetch shared resources if platform parameter is not specified', function () {
expect(cfg.getStaticResources(null, 'icon').length).toBe(2);
expect(cfg.getStaticResources(null, 'icon').every(hasPlatformPropertyUndefined)).toBeTruthy();
});
- it('Test 036 : should fetch platform-specific resources along with shared if platform parameter is specified', function() {
+ it('Test 036 : should fetch platform-specific resources along with shared if platform parameter is specified', function () {
expect(cfg.getStaticResources('android', 'icon').length).toBe(5);
expect(cfg.getStaticResources('android', 'icon').some(hasPlatformPropertyDefined)).toBeTruthy();
expect(cfg.getStaticResources('android', 'icon').filter(hasPlatformPropertyDefined).length).toBe(3);
expect(cfg.getStaticResources('android', 'icon').some(hasPlatformPropertyUndefined)).toBeTruthy();
});
- it('Test 037 : should parse resources\' attributes', function() {
+ it('Test 037 : should parse resources\' attributes', function () {
expect(cfg.getStaticResources(null, 'icon').every(hasSrcPropertyDefined)).toBeTruthy();
expect(cfg.getStaticResources('windows', 'icon').filter(hasPlatformPropertyDefined).every(hasTargetPropertyDefined)).toBeTruthy();
expect(cfg.getStaticResources('android', 'icon').filter(hasPlatformPropertyDefined).every(hasDensityPropertyDefined)).toBeTruthy();
expect(cfg.getStaticResources('android', 'icon').filter(hasPlatformPropertyDefined).every(hasDensityPropertyDefined)).toBeTruthy();
});
- it('Test 038 : should have defaultResource property', function() {
+ it('Test 038 : should have defaultResource property', function () {
expect(cfg.getStaticResources(null, 'icon').defaultResource).toBeDefined();
expect(cfg.getStaticResources(null, 'icon').defaultResource.src).toBe('icon.png');
});
- it('Test 039 : should have getDefault method returning defaultResource property', function() {
+ it('Test 039 : should have getDefault method returning defaultResource property', function () {
expect(cfg.getStaticResources(null, 'icon').defaultResource).toEqual(cfg.getStaticResources(null, 'icon').getDefault());
});
- it('Test 040 : should have getBySize method returning resource with size specified or null', function() {
+ it('Test 040 : should have getBySize method returning resource with size specified or null', function () {
expect(cfg.getStaticResources('windows', 'icon').getBySize(128)).toBe(null);
expect(cfg.getStaticResources('windows', 'icon').getBySize(72)).toBeDefined();
expect(cfg.getStaticResources('windows', 'icon').getBySize(72).width).toBe(72);
@@ -292,29 +293,29 @@ describe('config.xml parser', function () {
expect(cfg.getStaticResources('windows', 'icon').getBySize(null, 48).height).toBe(48);
});
- it('Test 041 : should have getByDensity method returning resource with density specified or null', function() {
+ it('Test 041 : should have getByDensity method returning resource with density specified or null', function () {
expect(cfg.getStaticResources('android', 'icon').getByDensity('hdpi')).toBe(null);
expect(cfg.getStaticResources('android', 'icon').getByDensity('mdpi')).toBeDefined();
expect(cfg.getStaticResources('android', 'icon').getByDensity('mdpi').src).toBe('logo-android.png');
});
});
- describe('file resources', function() {
+ describe('file resources', function () {
var hasSrcPropertyDefined = function (e) { return !!e.src; };
var hasTargetPropertyDefined = function (e) { return !!e.target; };
var hasArchPropertyDefined = function (e) { return !!e.arch; };
- it('should fetch platform-specific resources', function() {
+ it('should fetch platform-specific resources', function () {
expect(cfg.getFileResources('android').length).toBe(2);
});
- it('should parse resources\' attributes', function() {
+ it('should parse resources\' attributes', function () {
expect(cfg.getFileResources('android').every(hasSrcPropertyDefined)).toBeTruthy();
expect(cfg.getFileResources('android').every(hasTargetPropertyDefined)).toBeTruthy();
expect(cfg.getFileResources('windows').every(hasArchPropertyDefined)).toBeTruthy();
});
- it('should find resources at the top level', function() {
+ it('should find resources at the top level', function () {
expect(cfg.getFileResources('android', true).length).toBe(3);
});
});
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/CordovaCheck.spec.js
----------------------------------------------------------------------
diff --git a/spec/CordovaCheck.spec.js b/spec/CordovaCheck.spec.js
index 8745a40..5a2fdc0 100644
--- a/spec/CordovaCheck.spec.js
+++ b/spec/CordovaCheck.spec.js
@@ -17,43 +17,43 @@
under the License.
*/
-var shell = require('shelljs'),
- path = require('path'),
- CordovaCheck = require('../src/CordovaCheck');
+var shell = require('shelljs');
+var path = require('path');
+var CordovaCheck = require('../src/CordovaCheck');
var cwd = process.cwd();
-var home = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
+var home = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
var origPWD = process.env.PWD;
-describe('findProjectRoot method', function() {
- afterEach(function() {
+describe('findProjectRoot method', function () {
+ afterEach(function () {
process.env.PWD = origPWD;
process.chdir(cwd);
});
- function removeDir(someDirectory) {
+ function removeDir (someDirectory) {
shell.rm('-rf', someDirectory);
}
- it('Test 001 : should return false if it hits the home directory', function() {
+ it('Test 001 : should return false if it hits the home directory', function () {
var somedir = path.join(home, 'somedir');
removeDir(somedir);
shell.mkdir(somedir);
expect(CordovaCheck.findProjectRoot(somedir)).toEqual(false);
});
- it('Test 002 : should return false if it cannot find a .cordova directory up the directory tree', function() {
+ it('Test 002 : should return false if it cannot find a .cordova directory up the directory tree', function () {
var somedir = path.join(home, '..');
expect(CordovaCheck.findProjectRoot(somedir)).toEqual(false);
});
- it('Test 003 : should return the first directory it finds with a .cordova folder in it', function() {
- var somedir = path.join(home,'somedir');
+ it('Test 003 : should return the first directory it finds with a .cordova folder in it', function () {
+ var somedir = path.join(home, 'somedir');
var anotherdir = path.join(somedir, 'anotherdir');
removeDir(somedir);
shell.mkdir('-p', anotherdir);
shell.mkdir('-p', path.join(somedir, 'www', 'config.xml'));
expect(CordovaCheck.findProjectRoot(somedir)).toEqual(somedir);
});
- it('Test 004 : should ignore PWD when its undefined', function() {
+ it('Test 004 : should ignore PWD when its undefined', function () {
delete process.env.PWD;
- var somedir = path.join(home,'somedir');
+ var somedir = path.join(home, 'somedir');
var anotherdir = path.join(somedir, 'anotherdir');
removeDir(somedir);
shell.mkdir('-p', anotherdir);
@@ -62,8 +62,8 @@ describe('findProjectRoot method', function() {
process.chdir(anotherdir);
expect(CordovaCheck.findProjectRoot()).toEqual(somedir);
});
- it('Test 005 : should use PWD when available', function() {
- var somedir = path.join(home,'somedir');
+ it('Test 005 : should use PWD when available', function () {
+ var somedir = path.join(home, 'somedir');
var anotherdir = path.join(somedir, 'anotherdir');
removeDir(somedir);
shell.mkdir('-p', anotherdir);
@@ -72,8 +72,8 @@ describe('findProjectRoot method', function() {
process.chdir(path.sep);
expect(CordovaCheck.findProjectRoot()).toEqual(somedir);
});
- it('Test 006 : should use cwd as a fallback when PWD is not a cordova dir', function() {
- var somedir = path.join(home,'somedir');
+ it('Test 006 : should use cwd as a fallback when PWD is not a cordova dir', function () {
+ var somedir = path.join(home, 'somedir');
var anotherdir = path.join(somedir, 'anotherdir');
removeDir(somedir);
shell.mkdir('-p', anotherdir);
@@ -82,8 +82,8 @@ describe('findProjectRoot method', function() {
process.chdir(anotherdir);
expect(CordovaCheck.findProjectRoot()).toEqual(somedir);
});
- it('Test 007 : should ignore platform www/config.xml', function() {
- var somedir = path.join(home,'somedir');
+ it('Test 007 : should ignore platform www/config.xml', function () {
+ var somedir = path.join(home, 'somedir');
var anotherdir = path.join(somedir, 'anotherdir');
removeDir(somedir);
shell.mkdir('-p', anotherdir);
@@ -92,4 +92,4 @@ describe('findProjectRoot method', function() {
shell.mkdir('-p', path.join(somedir, 'config.xml'));
expect(CordovaCheck.findProjectRoot(anotherdir)).toEqual(somedir);
});
-});
\ No newline at end of file
+});
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/CordovaLogger.spec.js
----------------------------------------------------------------------
diff --git a/spec/CordovaLogger.spec.js b/spec/CordovaLogger.spec.js
index fb46e73..388dad9 100644
--- a/spec/CordovaLogger.spec.js
+++ b/spec/CordovaLogger.spec.js
@@ -23,7 +23,7 @@ var EventEmitter = require('events').EventEmitter;
var DEFAULT_LEVELS = ['verbose', 'normal', 'warn', 'info', 'error', 'results'];
-describe('CordovaLogger class', function() {
+describe('CordovaLogger class', function () {
it('Test 001 : should be constructable', function () {
expect(new CordovaLogger()).toEqual(jasmine.any(CordovaLogger));
});
@@ -99,10 +99,10 @@ describe('CordovaLogger class', function() {
};
var listenerSpy = jasmine.createSpy('listenerSpy')
- .and.callFake(function (eventName) {
- eventName = eventNamesExclusions[eventName] || eventName;
- expect(logger.levels[eventName]).toBeDefined();
- });
+ .and.callFake(function (eventName) {
+ eventName = eventNamesExclusions[eventName] || eventName;
+ expect(logger.levels[eventName]).toBeDefined();
+ });
var emitter = new EventEmitter().on('newListener', listenerSpy);
logger.subscribe(emitter);
@@ -163,7 +163,7 @@ describe('CordovaLogger class', function() {
describe('adjustLevel method', function () {
it('Test 014 : should properly adjust log level', function () {
- var resetLogLevel = function() {
+ var resetLogLevel = function () {
logger.setLevel('normal');
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org