You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by er...@apache.org on 2020/03/15 10:02:17 UTC
[cordova-common] branch master updated: refactor: transform var to
let/const (#137)
This is an automated email from the ASF dual-hosted git repository.
erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-common.git
The following commit(s) were added to refs/heads/master by this push:
new 1cdf107 refactor: transform var to let/const (#137)
1cdf107 is described below
commit 1cdf107f860078625094ff80566ccecf8e5d2e46
Author: エリス <er...@users.noreply.github.com>
AuthorDate: Sun Mar 15 19:02:07 2020 +0900
refactor: transform var to let/const (#137)
---
spec/ActionStack.spec.js | 38 ++---
spec/ConfigChanges/ConfigChanges.spec.js | 220 ++++++++++++++---------------
spec/ConfigChanges/ConfigFile.spec.js | 26 ++--
spec/ConfigParser/ConfigParser.spec.js | 78 +++++-----
spec/CordovaCheck.spec.js | 36 ++---
spec/CordovaLogger.spec.js | 28 ++--
spec/FileUpdater.spec.js | 146 +++++++++----------
spec/PlatformJson.spec.js | 22 +--
spec/PluginInfo/PluginInfo.spec.js | 20 +--
spec/PluginInfo/PluginInfoProvider.spec.js | 10 +-
spec/PluginManager.spec.js | 38 ++---
spec/plist-helpers.spec.js | 12 +-
spec/superspawn.spec.js | 10 +-
spec/util/xml-helpers.spec.js | 174 +++++++++++------------
14 files changed, 429 insertions(+), 429 deletions(-)
diff --git a/spec/ActionStack.spec.js b/spec/ActionStack.spec.js
index d651dc9..4987f05 100644
--- a/spec/ActionStack.spec.js
+++ b/spec/ActionStack.spec.js
@@ -16,23 +16,23 @@
specific language governing permissions and limitations
under the License.
*/
-var path = require('path');
-var ActionStack = require('../src/ActionStack');
-var android_one_project = path.join(__dirname, '..', 'projects', 'android_one');
+const path = require('path');
+const ActionStack = require('../src/ActionStack');
+const android_one_project = path.join(__dirname, '..', 'projects', 'android_one');
describe('action-stack', function () {
- var stack;
+ let stack;
beforeEach(function () {
stack = new ActionStack();
});
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];
+ const first_spy = jasmine.createSpy();
+ const first_args = [1];
+ const second_spy = jasmine.createSpy();
+ const second_args = [2];
+ const third_spy = jasmine.createSpy();
+ const 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 () {}, []));
@@ -43,17 +43,17 @@ describe('action-stack', function () {
});
it('Test 002 : should revert processed actions if an exception occurs', function () {
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 () {
+ const first_spy = jasmine.createSpy();
+ const first_args = [1];
+ const first_reverter = jasmine.createSpy();
+ const first_reverter_args = [true];
+ const process_err = new Error('process_err');
+ const second_spy = jasmine.createSpy().and.callFake(function () {
throw process_err;
});
- var second_args = [2];
- var third_spy = jasmine.createSpy();
- var third_args = [3];
+ const second_args = [2];
+ const third_spy = jasmine.createSpy();
+ const 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 () {}, []));
diff --git a/spec/ConfigChanges/ConfigChanges.spec.js b/spec/ConfigChanges/ConfigChanges.spec.js
index 84b2b35..ac6f5ca 100644
--- a/spec/ConfigChanges/ConfigChanges.spec.js
+++ b/spec/ConfigChanges/ConfigChanges.spec.js
@@ -86,19 +86,19 @@ describe('config-changes module', 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);
+ const platformJson = new PlatformJson(null, 'android', null);
platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', {});
- var json = platformJson.root;
+ const 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 () {
- var platformJson = new PlatformJson(null, 'android', null);
+ const platformJson = new PlatformJson(null, 'android', null);
platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', { dude: 'man' });
- var json = platformJson.root;
+ const 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' });
});
@@ -106,10 +106,10 @@ describe('config-changes module', function () {
describe('addUninstalledPluginToPrepareQueue', function () {
it('Test 003 : should append specified plugin to platform.json', function () {
- var platformJson = new PlatformJson(null, 'android', null);
+ const platformJson = new PlatformJson(null, 'android', null);
platformJson.addUninstalledPluginToPrepareQueue('org.test.plugins.dummyplugin');
- var json = platformJson.root;
+ const json = platformJson.root;
expect(json.prepare_queue.uninstalled[0].plugin).toEqual('org.test.plugins.dummyplugin');
});
});
@@ -117,7 +117,7 @@ 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 () {
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
expect(platformJson.root).toBeDefined();
expect(platformJson.root.prepare_queue).toBeDefined();
expect(platformJson.root.config_munge).toBeDefined();
@@ -125,8 +125,8 @@ describe('config-changes module', function () {
});
it('Test 005 : should return the json file if it exists', function () {
- var filepath = path.join(plugins_dir, 'android.json');
- var json = {
+ const filepath = path.join(plugins_dir, 'android.json');
+ const json = {
prepare_queue: { installed: [], uninstalled: [] },
config_munge: { files: { some_file: { parents: { some_parent: [{ xml: 'some_change', count: 1 }] } } } },
installed_plugins: {},
@@ -134,15 +134,15 @@ describe('config-changes module', function () {
};
fs.writeFileSync(filepath, JSON.stringify(json), 'utf-8');
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
expect(JSON.stringify(json)).toEqual(JSON.stringify(platformJson.root));
});
});
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 });
+ const filepath = path.join(plugins_dir, 'android.json');
+ const platformJson = new PlatformJson(filepath, 'android', { foo: true });
platformJson.save();
expect(JSON.parse(fs.readFileSync(filepath, 'utf-8'))).toEqual(platformJson.root);
});
@@ -155,10 +155,10 @@ describe('config-changes module', 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), {});
+ let xml;
+ const dummy_xml = new et.ElementTree(et.XML(fs.readFileSync(path.join(dummyplugin, 'plugin.xml'), 'utf-8')));
+ const munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
+ const 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 });
@@ -177,8 +177,8 @@ describe('config-changes module', 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' });
+ const munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
+ const munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(childrenplugin), { PACKAGE_NAME: 'com.alunny.childapp' });
expect(munge.files['AndroidManifest.xml']).toBeDefined();
expect(munge.files['AndroidManifest.xml'].parents['/manifest']).toBeDefined();
expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest', '<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />')).toBeDefined();
@@ -193,27 +193,27 @@ describe('config-changes module', 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), {});
+ const munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
+ const 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 () {
- var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
- var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(configplugin), {});
+ const munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
+ const 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 () {
- 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' });
+ const munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
+ const 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 () {
- var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
- var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(dummyplugin), {});
+ const munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
+ const munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(dummyplugin), {});
expect(get_munge_change(munge, 'config.xml', '/*', '<access origin="build.phonegap.com" />')).toBeDefined();
expect(get_munge_change(munge, 'config.xml', '/*', '<access origin="s3.amazonaws.com" />')).toBeDefined();
});
@@ -227,10 +227,10 @@ describe('config-changes module', function () {
it('Test 014 : should generate config munges for queued plugins', function () {
fs.copySync(android_two_project, temp);
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
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({});
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const spy = spyOn(munger, 'generate_plugin_config_munge').and.returnValue({});
munger.process(plugins_dir);
expect(spy).toHaveBeenCalledWith(jasmine.any(PluginInfo), {});
});
@@ -242,12 +242,12 @@ describe('config-changes module', 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');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.root.prepare_queue.installed = [{ plugin: 'org.test.plugins.dummyplugin', vars: {} }];
- var spy = spyOn(xml_helpers, 'graftXML').and.returnValue(true);
+ const spy = spyOn(xml_helpers, 'graftXML').and.returnValue(true);
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
expect(spy.calls.count()).toEqual(4);
expect(spy.calls.argsFor(0)[2]).toEqual('/*');
@@ -258,22 +258,22 @@ describe('config-changes module', function () {
it('Test 016 : should not call graftXML for a config munge that already exists from another plugin', function () {
install_plugin(configplugin);
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.configtest', {});
- var spy = spyOn(xml_helpers, 'graftXML').and.returnValue(true);
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const spy = spyOn(xml_helpers, 'graftXML').and.returnValue(true);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
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 () {
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', {});
- var spy = spyOn(fs, 'readFileSync').and.callThrough();
+ const spy = spyOn(fs, 'readFileSync').and.callThrough();
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
expect(spy).not.toHaveBeenCalledWith(path.join(temp, 'res', 'xml', 'plugins.xml'), 'utf-8');
});
@@ -281,12 +281,12 @@ describe('config-changes module', function () {
it('Test 018 : should call graftXMLMerge for every new config munge with mode \'merge\' it introduces', function () {
install_plugin(editconfigplugin);
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest', {});
- var spy = spyOn(xml_helpers, 'graftXMLMerge').and.returnValue(true);
+ const spy = spyOn(xml_helpers, 'graftXMLMerge').and.returnValue(true);
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
expect(spy.calls.count()).toEqual(1);
expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/application/activity[@android:name=\'org.test.DroidGap\']');
@@ -296,13 +296,13 @@ describe('config-changes module', function () {
install_plugin(editconfigplugin);
install_plugin(editconfigplugin_two);
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest', {});
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest_two', {}, true, true);
- var spy = spyOn(xml_helpers, 'graftXMLMerge').and.returnValue(true);
+ const spy = spyOn(xml_helpers, 'graftXMLMerge').and.returnValue(true);
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
expect(spy.calls.count()).toEqual(3);
expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/application/activity[@android:name=\'org.test.DroidGap\']');
@@ -313,12 +313,12 @@ describe('config-changes module', function () {
it('Test 020 : should call graftXMLOverwrite for every new config munge with mode \'overwrite\' it introduces', function () {
install_plugin(editconfigplugin);
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest', {});
- var spy = spyOn(xml_helpers, 'graftXMLOverwrite').and.returnValue(true);
+ const spy = spyOn(xml_helpers, 'graftXMLOverwrite').and.returnValue(true);
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
expect(spy.calls.count()).toEqual(1);
expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/application/activity');
@@ -328,13 +328,13 @@ describe('config-changes module', function () {
install_plugin(editconfigplugin);
install_plugin(editconfigplugin_two);
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest', {});
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest_two', {}, true, true);
- var spy = spyOn(xml_helpers, 'graftXMLOverwrite').and.returnValue(true);
+ const spy = spyOn(xml_helpers, 'graftXMLOverwrite').and.returnValue(true);
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
expect(spy.calls.count()).toEqual(2);
expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/application/activity');
@@ -345,20 +345,20 @@ describe('config-changes module', function () {
install_plugin(editconfigplugin);
install_plugin(editconfigplugin_two);
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest', {});
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest_two', {});
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const 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.'));
});
it('should call graftXMLMerge for every new config.xml config munge with mode \'merge\' it introduces', function () {
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
- var spy = spyOn(xml_helpers, 'graftXMLMerge').and.returnValue(true);
+ const spy = spyOn(xml_helpers, 'graftXMLMerge').and.returnValue(true);
- var munger = new configChanges.PlatformMunger('android', temp, platformJson);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson);
munger.add_config_changes(cfg, true);
expect(spy.calls.count()).toEqual(1);
@@ -366,11 +366,11 @@ describe('config-changes module', 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');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
- var spy = spyOn(xml_helpers, 'graftXMLOverwrite').and.returnValue(true);
+ const spy = spyOn(xml_helpers, 'graftXMLOverwrite').and.returnValue(true);
- var munger = new configChanges.PlatformMunger('android', temp, platformJson);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson);
munger.add_config_changes(cfg, true);
expect(spy.calls.count()).toEqual(1);
@@ -378,15 +378,15 @@ describe('config-changes module', 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');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
// var spy = spyOn(xml_helpers, 'pruneXMLRemove').andReturn(true);
- var munger = new configChanges.PlatformMunger('android', temp, platformJson);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson);
munger.add_config_changes(cfg, true).save_all();
- var am_xml = new et.ElementTree(et.XML(fs.readFileSync(path.join(temp, 'AndroidManifest.xml'), 'utf-8')));
- var sdk = am_xml.find('./uses-sdk');
+ const am_xml = new et.ElementTree(et.XML(fs.readFileSync(path.join(temp, 'AndroidManifest.xml'), 'utf-8')));
+ const sdk = am_xml.find('./uses-sdk');
expect(sdk).toBeDefined();
expect(sdk.attrib['android:maxSdkVersion']).toBeUndefined();
@@ -395,28 +395,28 @@ describe('config-changes module', function () {
it('should overwrite plugin config munge for every conflicting config.xml config munge', function () {
install_plugin(editconfigplugin_two);
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest_two', {}, true, true);
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
munger.add_config_changes(cfg, true).save_all();
- var am_xml = new et.ElementTree(et.XML(fs.readFileSync(path.join(temp, 'AndroidManifest.xml'), 'utf-8')));
- var sdk = am_xml.find('./uses-sdk');
+ const am_xml = new et.ElementTree(et.XML(fs.readFileSync(path.join(temp, 'AndroidManifest.xml'), 'utf-8')));
+ const sdk = am_xml.find('./uses-sdk');
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 () {
- var editconfig_cfg = new ConfigParser(editconfig_xml);
- var platformJson = PlatformJson.load(plugins_dir, 'android');
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const editconfig_cfg = new ConfigParser(editconfig_xml);
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.add_config_changes(cfg, true).save_all();
munger.add_config_changes(editconfig_cfg, true).save_all();
- var am_xml = new et.ElementTree(et.XML(fs.readFileSync(path.join(temp, 'AndroidManifest.xml'), 'utf-8')));
- var sdk = am_xml.find('./uses-sdk');
+ const am_xml = new et.ElementTree(et.XML(fs.readFileSync(path.join(temp, 'AndroidManifest.xml'), 'utf-8')));
+ const sdk = am_xml.find('./uses-sdk');
expect(sdk).toBeDefined();
expect(sdk.attrib['android:targetSdkVersion']).toEqual('23');
expect(sdk.attrib['android:minSdkVersion']).toEqual('5');
@@ -424,33 +424,33 @@ describe('config-changes module', function () {
});
it('should append new children to XML document tree', function () {
- var configfile_cfg = new ConfigParser(configfile_xml);
- var platformJson = PlatformJson.load(plugins_dir, 'android');
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const configfile_cfg = new ConfigParser(configfile_xml);
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.add_config_changes(configfile_cfg, true).save_all();
- var am_xml = new et.ElementTree(et.XML(fs.readFileSync(path.join(temp, 'AndroidManifest.xml'), 'utf-8')));
- var activity = am_xml.find('./application/activity[@android:name="com.foo.Bar"]');
+ const am_xml = new et.ElementTree(et.XML(fs.readFileSync(path.join(temp, 'AndroidManifest.xml'), 'utf-8')));
+ const activity = am_xml.find('./application/activity[@android:name="com.foo.Bar"]');
expect(activity).toBeDefined();
expect(activity.attrib['android:label']).toEqual('@string/app_name');
});
// testing the "after" attribute of the <config-file> tag in config.xml
it('should append new children to XML document tree in the correct order', function () {
- var configfile_cfg = new ConfigParser(configfile_xml);
- var platformJson = PlatformJson.load(plugins_dir, 'android');
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const configfile_cfg = new ConfigParser(configfile_xml);
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.add_config_changes(configfile_cfg, true).save_all();
- var am_file = fs.readFileSync(path.join(temp, 'AndroidManifest.xml'), 'utf-8');
+ const am_file = fs.readFileSync(path.join(temp, 'AndroidManifest.xml'), 'utf-8');
expect(am_file.indexOf('android:name="zoo"')).toBeLessThan(am_file.indexOf('android:name="com.foo.Bar"'));
});
it('should throw error for conflicting plugin config munge with config.xml config munge', function () {
install_plugin(editconfigplugin_two);
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest_two', {}, true, true);
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const 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.'));
});
@@ -461,7 +461,7 @@ describe('config-changes module', function () {
fs.copySync(ios_config_xml, temp);
install_plugin(varplugin);
- var platformJson = PlatformJson.load(plugins_dir, 'ios');
+ const 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\t<string\/>/m);
@@ -471,7 +471,7 @@ describe('config-changes module', function () {
fs.copySync(ios_config_xml, temp);
install_plugin(plistplugin);
- var platformJson = PlatformJson.load(plugins_dir, 'ios');
+ const platformJson = PlatformJson.load(plugins_dir, 'ios');
platformJson.addInstalledPluginToPrepareQueue('org.apache.plist', {});
configChanges.process(plugins_dir, temp, 'ios', platformJson, pluginInfoProvider);
expect(fs.readFileSync(path.join(temp, 'SampleApp', 'SampleApp-Info.plist'), 'utf-8')).toMatch(/<key>UINewsstandIcon<\/key>[\s\S]*<key>CFBundlePrimaryIcon<\/key>/);
@@ -485,10 +485,10 @@ describe('config-changes module', function () {
fs.copySync(ios_config_xml, temp);
install_plugin(bplistplugin);
- var platformJson = PlatformJson.load(plugins_dir, 'ios');
+ const platformJson = PlatformJson.load(plugins_dir, 'ios');
platformJson.addInstalledPluginToPrepareQueue('org.apache.bplist', {});
configChanges.process(plugins_dir, temp, 'ios', platformJson, pluginInfoProvider);
- var edited_plist = fs.readFileSync(path.join(temp, 'SampleApp', 'SampleApp-binary.plist'), 'utf-8');
+ const edited_plist = fs.readFileSync(path.join(temp, 'SampleApp', 'SampleApp-binary.plist'), 'utf-8');
expect(edited_plist).toMatch(/<key>UINewsstandIcon<\/key>[\s\S]*<key>CFBundlePrimaryIcon<\/key>/);
expect(fs.readFileSync(path.join(temp, 'SampleApp', 'SampleApp-binary.plist'), 'utf-8')).toMatch(/<string>schema-b<\/string>/);
expect(fs.readFileSync(path.join(temp, 'SampleApp', 'SampleApp-binary.plist'), 'utf-8')).not.toMatch(/(<string>schema-a<\/string>[^]*){2,}/);
@@ -499,11 +499,11 @@ describe('config-changes module', function () {
fs.copySync(ios_config_xml, temp);
install_plugin(cbplugin);
- var platformJson = PlatformJson.load(plugins_dir, 'ios');
+ const platformJson = PlatformJson.load(plugins_dir, 'ios');
platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.childbrowser', {});
- var spy = spyOn(fs, 'readFileSync').and.callThrough();
+ const spy = spyOn(fs, 'readFileSync').and.callThrough();
- var munger = new configChanges.PlatformMunger('ios', temp, platformJson, pluginInfoProvider);
+ const munger = new configChanges.PlatformMunger('ios', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
expect(spy).toHaveBeenCalledWith(path.join(temp, 'SampleApp', 'SampleApp-Info.plist'), 'utf8');
});
@@ -512,10 +512,10 @@ describe('config-changes module', function () {
fs.copySync(android_two_project, temp);
install_plugin(varplugin);
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', { API_KEY: 'hi' }, true);
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
expect(platformJson.root.prepare_queue.installed.length).toEqual(0);
@@ -529,15 +529,15 @@ describe('config-changes module', function () {
fs.copySync(android_two_project, temp);
// Run through an "install"
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', {});
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
// Now set up an uninstall and make sure prunexml is called properly
platformJson.addUninstalledPluginToPrepareQueue('org.test.plugins.dummyplugin');
- var spy = spyOn(xml_helpers, 'pruneXML').and.returnValue(true);
+ const spy = spyOn(xml_helpers, 'pruneXML').and.returnValue(true);
munger.process(plugins_dir);
expect(spy.calls.count()).toEqual(4);
expect(spy.calls.argsFor(0)[2]).toEqual('/*');
@@ -551,18 +551,18 @@ describe('config-changes module', function () {
install_plugin(varplugin);
// Run through an "install"
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', { API_KEY: 'canucks' });
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
// Now set up an uninstall and make sure prunexml is called properly
platformJson.addUninstalledPluginToPrepareQueue('com.adobe.vars');
- var spy = spyOn(munger, 'generate_plugin_config_munge').and.returnValue({});
+ const spy = spyOn(munger, 'generate_plugin_config_munge').and.returnValue({});
munger.process(plugins_dir);
- var munge_params = spy.calls.argsFor(0);
+ const munge_params = spy.calls.argsFor(0);
expect(munge_params[0]).toEqual(jasmine.any(PluginInfo));
expect(munge_params[0].dir).toEqual(path.join(plugins_dir, 'com.adobe.vars'));
expect(munge_params[1].API_KEY).toEqual('canucks');
@@ -574,11 +574,11 @@ describe('config-changes module', function () {
install_plugin(shareddepsplugin);
// Run through and "install" two plugins (they share a permission for INTERNET)
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.multiple-children', {});
platformJson.addInstalledPluginToPrepareQueue('org.test.shareddeps', {});
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
// Now set up an uninstall for multi-child plugin
@@ -586,8 +586,8 @@ describe('config-changes module', function () {
munger.process(plugins_dir);
munger.save_all();
- var am_xml = new et.ElementTree(et.XML(fs.readFileSync(path.join(temp, 'AndroidManifest.xml'), 'utf-8')));
- var permission = am_xml.find('./uses-permission');
+ const am_xml = new et.ElementTree(et.XML(fs.readFileSync(path.join(temp, 'AndroidManifest.xml'), 'utf-8')));
+ const permission = am_xml.find('./uses-permission');
expect(permission).toBeDefined();
expect(permission.attrib['android:name']).toEqual('android.permission.INTERNET');
});
@@ -595,15 +595,15 @@ describe('config-changes module', function () {
it('Test 030 : should not call pruneXML for a config munge targeting a config file that does not exist', function () {
fs.copySync(android_two_project, temp);
// install a plugin
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', {});
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
// set up an uninstall for the same plugin
platformJson.addUninstalledPluginToPrepareQueue('org.test.plugins.dummyplugin');
- var spy = spyOn(fs, 'readFileSync').and.callThrough();
+ const spy = spyOn(fs, 'readFileSync').and.callThrough();
munger.process(plugins_dir);
expect(spy).not.toHaveBeenCalledWith(path.join(temp, 'res', 'xml', 'plugins.xml'), 'utf-8');
@@ -614,9 +614,9 @@ describe('config-changes module', function () {
install_plugin(varplugin);
// install the var plugin
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', { API_KEY: 'eat my shorts' });
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
// queue up an uninstall for the same plugin
@@ -632,16 +632,16 @@ describe('config-changes module', function () {
install_plugin(editconfigplugin);
// Run through an "install"
- var platformJson = PlatformJson.load(plugins_dir, 'android');
+ const platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest', {});
- var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
+ const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
// Now set up an uninstall and make sure pruneXMLMerge is called properly
platformJson.addUninstalledPluginToPrepareQueue('org.test.editconfigtest');
- var spy = spyOn(xml_helpers, 'pruneXMLRestore').and.returnValue(true);
+ const spy = spyOn(xml_helpers, 'pruneXMLRestore').and.returnValue(true);
munger.process(plugins_dir);
expect(spy.calls.count()).toEqual(2);
diff --git a/spec/ConfigChanges/ConfigFile.spec.js b/spec/ConfigChanges/ConfigFile.spec.js
index e47f7e0..51a2d44 100644
--- a/spec/ConfigChanges/ConfigFile.spec.js
+++ b/spec/ConfigChanges/ConfigFile.spec.js
@@ -15,9 +15,9 @@
under the License.
*/
-var rewire = require('rewire');
-var fs = require('fs-extra');
-var path = require('path');
+const rewire = require('rewire');
+const fs = require('fs-extra');
+const path = require('path');
const readChunk = require('read-chunk');
describe('ConfigFile tests', function () {
@@ -59,46 +59,46 @@ describe('ConfigFile tests', function () {
const projectDir = path.join('project_dir', 'app', 'src', 'main');
it('should return file path', function () {
- var filePath = path.join('project_dir', 'file');
+ const filePath = path.join('project_dir', 'file');
expect(ConfigFile.resolveConfigFilePath('project_dir', 'platform', 'file')).toBe(filePath);
});
it('should return AndroidManifest.xml file path', function () {
- var androidManifestPath = path.join(projectDir, 'AndroidManifest.xml');
+ const androidManifestPath = path.join(projectDir, 'AndroidManifest.xml');
expect(ConfigFile.resolveConfigFilePath('project_dir', 'android', 'AndroidManifest.xml')).toBe(androidManifestPath);
});
it('should return android config.xml file path', function () {
- var configPath = path.join(projectDir, 'res', 'xml', 'config.xml');
+ const configPath = path.join(projectDir, 'res', 'xml', 'config.xml');
expect(ConfigFile.resolveConfigFilePath('project_dir', 'android', 'config.xml')).toBe(configPath);
});
it('should return android strings.xml file path', function () {
- var stringsPath = path.join(projectDir, 'res', 'values', 'strings.xml');
+ const stringsPath = path.join(projectDir, 'res', 'values', 'strings.xml');
expect(ConfigFile.resolveConfigFilePath('project_dir', 'android', 'strings.xml')).toBe(stringsPath);
});
it('should return ios config.xml file path', function () {
spyOn(ConfigFile, 'getIOSProjectname').and.returnValue('iospath');
- var configPath = path.join('project_dir', 'iospath', 'config.xml');
+ const configPath = path.join('project_dir', 'iospath', 'config.xml');
expect(ConfigFile.resolveConfigFilePath('project_dir', 'ios', 'config.xml')).toBe(configPath);
});
it('should return osx config.xml file path', function () {
spyOn(ConfigFile, 'getIOSProjectname').and.returnValue('osxpath');
- var configPath = path.join('project_dir', 'osxpath', 'config.xml');
+ const configPath = path.join('project_dir', 'osxpath', 'config.xml');
expect(ConfigFile.resolveConfigFilePath('project_dir', 'osx', 'config.xml')).toBe(configPath);
});
it('should return android resource file path when path is normalized', function () {
- var file = path.join('res', 'xml');
- var configPath = path.join('project_dir', 'app', 'src', 'main', file, 'xml');
+ const file = path.join('res', 'xml');
+ const configPath = path.join('project_dir', 'app', 'src', 'main', file, 'xml');
expect(ConfigFile.resolveConfigFilePath('project_dir', 'android', file)).toBe(configPath);
});
it('should return android resource file path when path is not normalized', function () {
- var file = 'res/xml';
- var configPath = path.join('project_dir', 'app', 'src', 'main', file, 'xml');
+ const file = 'res/xml';
+ const configPath = path.join('project_dir', 'app', 'src', 'main', file, 'xml');
expect(ConfigFile.resolveConfigFilePath('project_dir', 'android', file)).toBe(configPath);
});
diff --git a/spec/ConfigParser/ConfigParser.spec.js b/spec/ConfigParser/ConfigParser.spec.js
index 6d9541c..4649343 100644
--- a/spec/ConfigParser/ConfigParser.spec.js
+++ b/spec/ConfigParser/ConfigParser.spec.js
@@ -17,11 +17,11 @@
under the License.
*/
-var path = require('path');
-var fs = require('fs-extra');
-var ConfigParser = require('../../src/ConfigParser/ConfigParser');
-var xml = path.join(__dirname, '../fixtures/test-config.xml');
-var xml_contents = fs.readFileSync(xml, 'utf-8');
+const path = require('path');
+const fs = require('fs-extra');
+const ConfigParser = require('../../src/ConfigParser/ConfigParser');
+const xml = path.join(__dirname, '../fixtures/test-config.xml');
+const xml_contents = fs.readFileSync(xml, 'utf-8');
describe('config.xml parser', function () {
beforeEach(function () {
@@ -29,7 +29,7 @@ describe('config.xml parser', function () {
});
it('Test 001 : should create an instance based on an xml file', function () {
- var cfg;
+ let cfg;
expect(function () {
cfg = new ConfigParser(xml);
}).not.toThrow();
@@ -38,7 +38,7 @@ describe('config.xml parser', function () {
});
describe('methods', function () {
- var cfg;
+ let cfg;
beforeEach(function () {
cfg = new ConfigParser(xml);
});
@@ -156,7 +156,7 @@ describe('config.xml parser', function () {
});
describe('plugin', function () {
it('Test 018 : should read plugin id list', function () {
- var expectedList = [
+ const expectedList = [
'org.apache.cordova.pluginwithvars',
'org.apache.cordova.pluginwithurl',
'org.apache.cordova.pluginwithversion',
@@ -166,44 +166,44 @@ describe('config.xml parser', function () {
'org.apache.cordova.legacyfeatureurl',
'org.apache.cordova.legacyfeatureversionandurl'
];
- var list = cfg.getPluginIdList();
+ const 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');
+ const 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 () {
- var plugin = cfg.getPlugin('org.apache.cordova.undefinedplugin');
+ const 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 () {
- var plugin = cfg.getPlugin('org.apache.cordova.pluginwithurl');
+ const 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 () {
- var plugin = cfg.getPlugin('org.apache.cordova.pluginwithversion');
+ const 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 () {
- var plugin = cfg.getPlugin('org.apache.cordova.pluginwithurlandversion');
+ const plugin = cfg.getPlugin('org.apache.cordova.pluginwithurlandversion');
expect(plugin.spec).toEqual('http://cordova.apache.org/pluginwithurlandversion');
});
it('Test 024 : should read plugin variables', function () {
- var plugin = cfg.getPlugin('org.apache.cordova.pluginwithvars');
+ const plugin = cfg.getPlugin('org.apache.cordova.pluginwithvars');
expect(plugin.variables).toBeDefined();
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' });
- var plugins = cfg.doc.findall('plugin');
- var pluginNames = plugins.map(function (plugin) {
+ const plugins = cfg.doc.findall('plugin');
+ const pluginNames = plugins.map(function (plugin) {
return plugin.attrib.name;
});
expect(pluginNames).toContain('myplugin');
@@ -212,19 +212,19 @@ describe('config.xml parser', function () {
cfg.addPlugin({ name: 'aplugin' }, [{ name: 'paraname', value: 'paravalue' }]);
// Additional check for new parameters syntax
cfg.addPlugin({ name: 'bplugin' }, { paraname: 'paravalue' });
- var plugins = cfg.doc.findall('plugin')
+ const plugins = cfg.doc.findall('plugin')
.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');
+ const variables = plugin.findall('variable');
expect(variables[0].attrib.name).toEqual('paraname');
expect(variables[0].attrib.value).toEqual('paravalue');
});
});
it('Test 027 : should be able to read legacy feature entries with a version', function () {
- var plugin = cfg.getPlugin('org.apache.cordova.legacyfeatureversion');
+ const plugin = cfg.getPlugin('org.apache.cordova.legacyfeatureversion');
expect(plugin).toBeDefined();
expect(plugin.name).toEqual('org.apache.cordova.legacyfeatureversion');
expect(plugin.spec).toEqual('1.2.3');
@@ -232,60 +232,60 @@ describe('config.xml parser', function () {
expect(plugin.variables.aVar).toEqual('aValue');
});
it('Test 028 : should be able to read legacy feature entries with a url', function () {
- var plugin = cfg.getPlugin('org.apache.cordova.legacyfeatureurl');
+ const 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 () {
- var plugin = cfg.getPlugin('org.apache.cordova.legacyfeatureversionandurl');
+ const 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 () {
cfg.removePlugin('org.apache.cordova.justaplugin');
- var plugins = cfg.doc.findall('plugin');
- var pluginNames = plugins.map(function (plugin) {
+ const plugins = cfg.doc.findall('plugin');
+ const 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 () {
cfg.removePlugin('org.apache.cordova.legacyplugin');
- var plugins = cfg.doc.findall('feature');
- var pluginNames = plugins.map(function (plugin) {
+ const plugins = cfg.doc.findall('feature');
+ const 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 () {
- var accesses = cfg.getAccesses();
+ const accesses = cfg.getAccesses();
expect(accesses.length).not.toEqual(0);
});
it('Test 033 : it should read <allow-navigation> tag entries', function () {
- var navigations = cfg.getAllowNavigations();
+ const navigations = cfg.getAllowNavigations();
expect(navigations.length).not.toEqual(0);
});
it('Test 034 : it should read <allow-intent> tag entries', function () {
- var intents = cfg.getAllowIntents();
+ const intents = cfg.getAllowIntents();
expect(intents.length).not.toEqual(0);
});
it('Test 035: it should read <edit-config> tag entries', function () {
- var editConfigs = cfg.getEditConfigs('android');
+ const editConfigs = cfg.getEditConfigs('android');
expect(editConfigs.length).not.toEqual(0);
});
it('Test 036: it should read <config-file> tag entries', function () {
- var configFiles = cfg.getConfigFiles('android');
+ const configFiles = cfg.getConfigFiles('android');
expect(configFiles.length).not.toEqual(0);
});
});
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; };
+ const hasPlatformPropertyDefined = function (e) { return !!e.platform; };
+ const hasSrcPropertyDefined = function (e) { return !!e.src; };
+ const hasTargetPropertyDefined = function (e) { return !!e.target; };
+ const hasDensityPropertyDefined = function (e) { return !!e.density; };
+ const hasPlatformPropertyUndefined = function (e) { return !e.platform; };
it('Test 035 : should fetch shared resources if platform parameter is not specified', function () {
expect(cfg.getStaticResources(null, 'icon').length).toBe(2);
@@ -331,9 +331,9 @@ describe('config.xml parser', 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; };
+ const hasSrcPropertyDefined = function (e) { return !!e.src; };
+ const hasTargetPropertyDefined = function (e) { return !!e.target; };
+ const hasArchPropertyDefined = function (e) { return !!e.arch; };
it('should fetch platform-specific resources', function () {
expect(cfg.getFileResources('android').length).toBe(2);
diff --git a/spec/CordovaCheck.spec.js b/spec/CordovaCheck.spec.js
index ea12d03..f956547 100644
--- a/spec/CordovaCheck.spec.js
+++ b/spec/CordovaCheck.spec.js
@@ -17,13 +17,13 @@
under the License.
*/
-var fs = require('fs-extra');
-var path = require('path');
-var CordovaCheck = require('../src/CordovaCheck');
+const fs = require('fs-extra');
+const path = require('path');
+const CordovaCheck = require('../src/CordovaCheck');
-var cwd = process.cwd();
-var home = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
-var origPWD = process.env.PWD;
+const cwd = process.cwd();
+const home = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
+const origPWD = process.env.PWD;
describe('findProjectRoot method', function () {
afterEach(function () {
@@ -32,17 +32,17 @@ describe('findProjectRoot method', function () {
});
it('Test 001 : should return false if it hits the home directory', function () {
- var somedir = path.join(home, 'somedir');
+ const somedir = path.join(home, 'somedir');
fs.emptyDirSync(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 () {
- var somedir = path.join(home, '..');
+ const 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');
- var anotherdir = path.join(somedir, 'anotherdir');
+ const somedir = path.join(home, 'somedir');
+ const anotherdir = path.join(somedir, 'anotherdir');
fs.removeSync(somedir);
fs.ensureDirSync(anotherdir);
fs.ensureFileSync(path.join(somedir, 'www', 'config.xml'));
@@ -50,8 +50,8 @@ describe('findProjectRoot method', function () {
});
it('Test 004 : should ignore PWD when its undefined', function () {
delete process.env.PWD;
- var somedir = path.join(home, 'somedir');
- var anotherdir = path.join(somedir, 'anotherdir');
+ const somedir = path.join(home, 'somedir');
+ const anotherdir = path.join(somedir, 'anotherdir');
fs.removeSync(somedir);
fs.ensureDirSync(anotherdir);
fs.ensureDirSync(path.join(somedir, 'www'));
@@ -60,8 +60,8 @@ describe('findProjectRoot method', function () {
expect(CordovaCheck.findProjectRoot()).toEqual(somedir);
});
it('Test 005 : should use PWD when available', function () {
- var somedir = path.join(home, 'somedir');
- var anotherdir = path.join(somedir, 'anotherdir');
+ const somedir = path.join(home, 'somedir');
+ const anotherdir = path.join(somedir, 'anotherdir');
fs.removeSync(somedir);
fs.ensureDirSync(anotherdir);
fs.ensureFileSync(path.join(somedir, 'www', 'config.xml'));
@@ -70,8 +70,8 @@ describe('findProjectRoot method', function () {
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');
- var anotherdir = path.join(somedir, 'anotherdir');
+ const somedir = path.join(home, 'somedir');
+ const anotherdir = path.join(somedir, 'anotherdir');
fs.removeSync(somedir);
fs.ensureDirSync(anotherdir);
fs.ensureFileSync(path.join(somedir, 'www', 'config.xml'));
@@ -80,8 +80,8 @@ describe('findProjectRoot method', function () {
expect(CordovaCheck.findProjectRoot()).toEqual(somedir);
});
it('Test 007 : should ignore platform www/config.xml', function () {
- var somedir = path.join(home, 'somedir');
- var anotherdir = path.join(somedir, 'anotherdir');
+ const somedir = path.join(home, 'somedir');
+ const anotherdir = path.join(somedir, 'anotherdir');
fs.removeSync(somedir);
fs.ensureFileSync(path.join(anotherdir, 'www', 'config.xml'));
fs.ensureDirSync(path.join(somedir, 'www'));
diff --git a/spec/CordovaLogger.spec.js b/spec/CordovaLogger.spec.js
index 3b40656..e42d716 100644
--- a/spec/CordovaLogger.spec.js
+++ b/spec/CordovaLogger.spec.js
@@ -17,11 +17,11 @@
under the License.
*/
-var CordovaError = require('../src/CordovaError');
-var CordovaLogger = require('../src/CordovaLogger');
-var EventEmitter = require('events').EventEmitter;
+const CordovaError = require('../src/CordovaError');
+const CordovaLogger = require('../src/CordovaLogger');
+const EventEmitter = require('events').EventEmitter;
-var DEFAULT_LEVELS = ['verbose', 'normal', 'warn', 'info', 'error', 'results'];
+const DEFAULT_LEVELS = ['verbose', 'normal', 'warn', 'info', 'error', 'results'];
describe('CordovaLogger class', function () {
it('Test 001 : should be constructable', function () {
@@ -30,7 +30,7 @@ describe('CordovaLogger class', function () {
it('Test 002 : should expose default levels as constants', function () {
DEFAULT_LEVELS.forEach(function (level) {
- var constant = level.toUpperCase();
+ const constant = level.toUpperCase();
expect(CordovaLogger[constant]).toBeDefined();
expect(CordovaLogger[constant]).toBe(level);
});
@@ -43,7 +43,7 @@ describe('CordovaLogger class', function () {
});
describe('instance', function () {
- var logger;
+ let logger;
beforeEach(function () {
logger = new CordovaLogger();
@@ -71,7 +71,7 @@ describe('CordovaLogger class', function () {
});
it('Test 006 : should not add a shortcut method fi the property with the same name already exists', function () {
- var logMethod = logger.log;
+ const logMethod = logger.log;
logger.addLevel('log', 500);
expect(logger.log).toBe(logMethod); // "log" method remains unchanged
});
@@ -91,26 +91,26 @@ describe('CordovaLogger class', function () {
});
it('Test 009 : should attach corresponding listeners to supplied emitter', function () {
- var eventNamesExclusions = {
+ const eventNamesExclusions = {
log: 'normal',
warning: 'warn'
};
- var listenerSpy = jasmine.createSpy('listenerSpy')
+ const listenerSpy = jasmine.createSpy('listenerSpy')
.and.callFake(function (eventName) {
eventName = eventNamesExclusions[eventName] || eventName;
expect(logger.levels[eventName]).toBeDefined();
});
- var emitter = new EventEmitter().on('newListener', listenerSpy);
+ const emitter = new EventEmitter().on('newListener', listenerSpy);
logger.subscribe(emitter);
});
});
describe('log method', function () {
function CursorSpy (name) {
- var cursorMethods = ['reset', 'write'];
- var spy = jasmine.createSpyObj(name, cursorMethods);
+ const cursorMethods = ['reset', 'write'];
+ const spy = jasmine.createSpyObj(name, cursorMethods);
// Make spy methods chainable, as original Cursor acts
cursorMethods.forEach(function (method) { spy[method].and.returnValue(spy); });
@@ -149,7 +149,7 @@ describe('CordovaLogger class', function () {
});
it('Test 013 : should handle CordovaError instances separately from Error ones', function () {
- var errorMock = new CordovaError();
+ const errorMock = new CordovaError();
spyOn(errorMock, 'toString').and.returnValue('error_message');
logger.setLevel('verbose').log('verbose', errorMock);
@@ -160,7 +160,7 @@ describe('CordovaLogger class', function () {
describe('adjustLevel method', function () {
it('Test 014 : should properly adjust log level', function () {
- var resetLogLevel = function () {
+ const resetLogLevel = function () {
logger.setLevel('normal');
};
diff --git a/spec/FileUpdater.spec.js b/spec/FileUpdater.spec.js
index 81c9f4f..6cc8d82 100644
--- a/spec/FileUpdater.spec.js
+++ b/spec/FileUpdater.spec.js
@@ -17,11 +17,11 @@
under the License.
*/
-var path = require('path');
-var rewire = require('rewire');
+const path = require('path');
+const rewire = require('rewire');
const { Stats } = require('@nodelib/fs.macchiato');
-var FileUpdater = rewire('../src/FileUpdater');
+const FileUpdater = rewire('../src/FileUpdater');
// Normally these are internal to the module; these lines use rewire to expose them for testing.
FileUpdater.mapDirectory = FileUpdater.__get__('mapDirectory');
@@ -65,7 +65,7 @@ class SystemError extends Error {
// Create a mock to replace the fs-extra module used by the FileUpdater,
// so the tests don't have to actually touch the filesystem.
-var mockFs = {
+const mockFs = {
mkdirPaths: [],
cpPaths: [],
rmPaths: [],
@@ -85,13 +85,13 @@ var mockFs = {
},
readdirSync: function (dirPath) {
- var result = this._getEntry(this.dirMap, dirPath);
+ const result = this._getEntry(this.dirMap, dirPath);
if (!result) throw new SystemError('ENOENT', 'Directory path not found: ' + dirPath);
return result;
},
statSync: function (fileOrDirPath) {
- var result = this._getEntry(this.statMap, fileOrDirPath);
+ const result = this._getEntry(this.statMap, fileOrDirPath);
if (!result) throw new SystemError('ENOENT', 'File or directory path not found: ' + fileOrDirPath);
return result;
},
@@ -121,22 +121,22 @@ var mockFs = {
FileUpdater.__set__('fs', mockFs);
// Define some constants used in the test cases.
-var testRootDir = 'testRootDir';
-var testSourceDir = 'testSourceDir';
-var testSourceDir2 = 'testSourceDir2';
-var testSourceDir3 = 'testSourceDir3';
-var testTargetDir = 'testTargetDir';
-var testSourceFile = 'testSourceFile';
-var testSourceFile2 = 'testSourceFile2';
-var testTargetFile = 'testTargetFile';
-var testTargetFile2 = 'testTargetFile2';
-var testSubDir = 'testSubDir';
-var now = new Date();
-var oneHourAgo = new Date(now.getTime() - 1 * 60 * 60 * 1000);
-var testDirStats = mockDirStats();
-var testFileStats = mockFileStats(now);
-var testFileStats2 = mockFileStats(now);
-var testFileStats3 = mockFileStats(now);
+const testRootDir = 'testRootDir';
+const testSourceDir = 'testSourceDir';
+const testSourceDir2 = 'testSourceDir2';
+const testSourceDir3 = 'testSourceDir3';
+const testTargetDir = 'testTargetDir';
+const testSourceFile = 'testSourceFile';
+const testSourceFile2 = 'testSourceFile2';
+const testTargetFile = 'testTargetFile';
+const testTargetFile2 = 'testTargetFile2';
+const testSubDir = 'testSubDir';
+const now = new Date();
+const oneHourAgo = new Date(now.getTime() - 1 * 60 * 60 * 1000);
+const testDirStats = mockDirStats();
+const testFileStats = mockFileStats(now);
+const testFileStats2 = mockFileStats(now);
+const testFileStats3 = mockFileStats(now);
describe('FileUpdater class', function () {
beforeEach(function () {
@@ -147,7 +147,7 @@ describe('FileUpdater class', function () {
describe('updatePathWithStats method', function () {
it('Test 001 : should do nothing when a directory exists at source and target', function () {
- var updated = FileUpdater.updatePathWithStats(
+ const updated = FileUpdater.updatePathWithStats(
testSourceDir, mockDirStats(), testTargetDir, mockDirStats());
expect(updated).toBe(false);
expect(mockFs.mkdirPaths.length).toBe(0);
@@ -155,7 +155,7 @@ describe('FileUpdater class', function () {
});
it('Test 002 : should create a directory that exists at source and not at target', function () {
- var updated = FileUpdater.updatePathWithStats(
+ const updated = FileUpdater.updatePathWithStats(
testSourceDir, mockDirStats(), testTargetDir, null);
expect(updated).toBe(true);
expect(mockFs.mkdirPaths.length).toBe(1);
@@ -164,7 +164,7 @@ describe('FileUpdater class', function () {
});
it('Test 003 : should remove a directory that exists at target and not at source', function () {
- var updated = FileUpdater.updatePathWithStats(
+ const updated = FileUpdater.updatePathWithStats(
testSourceDir, null, testTargetDir, mockDirStats());
expect(updated).toBe(true);
expect(mockFs.mkdirPaths.length).toBe(0);
@@ -174,7 +174,7 @@ describe('FileUpdater class', function () {
it('Test 004 : should copy when a file exists at source and target and times are the same',
function () {
- var updated = FileUpdater.updatePathWithStats(
+ const updated = FileUpdater.updatePathWithStats(
testSourceFile, mockFileStats(now), testTargetFile, mockFileStats(now));
expect(updated).toBe(true);
expect(mockFs.cpPaths.length).toBe(1);
@@ -184,7 +184,7 @@ describe('FileUpdater class', function () {
it('Test 005 : should copy when a file exists at source and target and target is older',
function () {
- var updated = FileUpdater.updatePathWithStats(
+ const updated = FileUpdater.updatePathWithStats(
testSourceFile, mockFileStats(now), testTargetFile, mockFileStats(oneHourAgo));
expect(updated).toBe(true);
expect(mockFs.cpPaths.length).toBe(1);
@@ -194,7 +194,7 @@ describe('FileUpdater class', function () {
it('Test 006 : should do nothing when a file exists at source and target and target is newer',
function () {
- var updated = FileUpdater.updatePathWithStats(
+ const updated = FileUpdater.updatePathWithStats(
testSourceFile, mockFileStats(oneHourAgo), testTargetFile, mockFileStats(now));
expect(updated).toBe(false);
expect(mockFs.cpPaths.length).toBe(0);
@@ -202,7 +202,7 @@ describe('FileUpdater class', function () {
});
it('Test 007 : should copy when a file exists at source and target and forcing update', function () {
- var updated = FileUpdater.updatePathWithStats(
+ const updated = FileUpdater.updatePathWithStats(
testSourceFile, mockFileStats(now), testTargetFile, mockFileStats(now),
{ all: true });
expect(updated).toBe(true);
@@ -213,7 +213,7 @@ describe('FileUpdater class', function () {
it('Test 008 : should copy when a file exists at source and target and target is newer ' +
'and forcing update', function () {
- var updated = FileUpdater.updatePathWithStats(
+ const updated = FileUpdater.updatePathWithStats(
testSourceFile, mockFileStats(oneHourAgo), testTargetFile, mockFileStats(now),
{ all: true });
expect(updated).toBe(true);
@@ -223,7 +223,7 @@ describe('FileUpdater class', function () {
});
it('Test 009 : should copy when a file exists at source and target and source is newer', function () {
- var updated = FileUpdater.updatePathWithStats(
+ const updated = FileUpdater.updatePathWithStats(
testSourceFile, mockFileStats(now), testTargetFile, mockFileStats(oneHourAgo));
expect(updated).toBe(true);
expect(mockFs.cpPaths.length).toBe(1);
@@ -232,7 +232,7 @@ describe('FileUpdater class', function () {
});
it('Test 010 : should copy when a file exists at source and not at target', function () {
- var updated = FileUpdater.updatePathWithStats(
+ const updated = FileUpdater.updatePathWithStats(
testSourceFile, mockFileStats(now), testTargetFile, null);
expect(updated).toBe(true);
expect(mockFs.cpPaths.length).toBe(1);
@@ -241,7 +241,7 @@ describe('FileUpdater class', function () {
});
it('Test 011 : should remove when a file exists at target and not at source', function () {
- var updated = FileUpdater.updatePathWithStats(
+ const updated = FileUpdater.updatePathWithStats(
testSourceFile, null, testTargetFile, mockFileStats(now));
expect(updated).toBe(true);
expect(mockFs.cpPaths.length).toBe(0);
@@ -250,7 +250,7 @@ describe('FileUpdater class', function () {
});
it('Test 012 : should remove and mkdir when source is a directory and target is a file', function () {
- var updated = FileUpdater.updatePathWithStats(
+ const updated = FileUpdater.updatePathWithStats(
testSourceDir, mockDirStats(), testTargetDir, mockFileStats(now));
expect(updated).toBe(true);
expect(mockFs.cpPaths.length).toBe(0);
@@ -261,7 +261,7 @@ describe('FileUpdater class', function () {
});
it('Test 013 : should remove and copy when source is a file and target is a directory', function () {
- var updated = FileUpdater.updatePathWithStats(
+ const updated = FileUpdater.updatePathWithStats(
testSourceFile, mockFileStats(now), testTargetFile, mockDirStats());
expect(updated).toBe(true);
expect(mockFs.rmPaths.length).toBe(1);
@@ -282,9 +282,9 @@ describe('FileUpdater class', function () {
});
it('Test 015 : should log dir creation', function () {
- var loggedSource = 0;
- var loggedTarget = 0;
- var loggedRoot = 0;
+ let loggedSource = 0;
+ let loggedTarget = 0;
+ let loggedRoot = 0;
FileUpdater.updatePathWithStats(
testSourceDir, mockDirStats(now), testTargetDir, null, { rootDir: testRootDir },
function (message) {
@@ -298,9 +298,9 @@ describe('FileUpdater class', function () {
});
it('Test 016 : should log dir removal', function () {
- var loggedSource = 0;
- var loggedTarget = 0;
- var loggedRoot = 0;
+ let loggedSource = 0;
+ let loggedTarget = 0;
+ let loggedRoot = 0;
FileUpdater.updatePathWithStats(
testSourceDir, null, testTargetDir, mockDirStats(now), { rootDir: testRootDir },
function (message) {
@@ -314,9 +314,9 @@ describe('FileUpdater class', function () {
});
it('Test 017 : should log file copy', function () {
- var loggedSource = 0;
- var loggedTarget = 0;
- var loggedRoot = 0;
+ let loggedSource = 0;
+ let loggedTarget = 0;
+ let loggedRoot = 0;
FileUpdater.updatePathWithStats(
testSourceFile, mockFileStats(now), testTargetFile, null, { rootDir: testRootDir },
function (message) {
@@ -330,10 +330,10 @@ describe('FileUpdater class', function () {
});
it('Test 018: should log file removal', function () {
- var loggedSource = 0;
- var loggedTarget = 0;
- var loggedRoot = 0;
- var messages = [];
+ let loggedSource = 0;
+ let loggedTarget = 0;
+ let loggedRoot = 0;
+ const messages = [];
FileUpdater.updatePathWithStats(
testSourceFile, null, testTargetFile, mockFileStats(now), { rootDir: testRootDir },
function (message) {
@@ -352,7 +352,7 @@ describe('FileUpdater class', function () {
it('Test 019 : should map an empty directory', function () {
mockFs.statMap[path.join(testRootDir, testSourceDir)] = testDirStats;
mockFs.dirMap[path.join(testRootDir, testSourceDir)] = [];
- var dirMap = FileUpdater.mapDirectory(testRootDir, testSourceDir, ['**'], []);
+ const dirMap = FileUpdater.mapDirectory(testRootDir, testSourceDir, ['**'], []);
expect(Object.keys(dirMap)).toEqual(['']);
expect(dirMap[''].subDir).toBe(testSourceDir);
expect(dirMap[''].stats).toBe(testDirStats);
@@ -362,7 +362,7 @@ describe('FileUpdater class', function () {
mockFs.statMap[path.join(testRootDir, testSourceDir)] = testDirStats;
mockFs.dirMap[path.join(testRootDir, testSourceDir)] = [testSourceFile];
mockFs.statMap[path.join(testRootDir, testSourceDir, testSourceFile)] = testFileStats;
- var dirMap = FileUpdater.mapDirectory(testRootDir, testSourceDir, ['**'], []);
+ const dirMap = FileUpdater.mapDirectory(testRootDir, testSourceDir, ['**'], []);
expect(Object.keys(dirMap).sort()).toEqual(['', testSourceFile]);
expect(dirMap[''].subDir).toBe(testSourceDir);
expect(dirMap[''].stats).toBe(testDirStats);
@@ -375,7 +375,7 @@ describe('FileUpdater class', function () {
mockFs.dirMap[testSourceDir] = [testSubDir];
mockFs.statMap[path.join(testSourceDir, testSubDir)] = testDirStats;
mockFs.dirMap[path.join(testSourceDir, testSubDir)] = [];
- var dirMap = FileUpdater.mapDirectory('', testSourceDir, ['**'], []);
+ const dirMap = FileUpdater.mapDirectory('', testSourceDir, ['**'], []);
expect(Object.keys(dirMap).sort()).toEqual(['', testSubDir]);
expect(dirMap[''].subDir).toBe(testSourceDir);
expect(dirMap[''].stats).toBe(testDirStats);
@@ -392,7 +392,7 @@ describe('FileUpdater class', function () {
mockFs.dirMap[path.join(testSourceDir, testSubDir, testSubDir)] = [testSourceFile];
mockFs.statMap[path.join(testSourceDir, testSubDir, testSubDir, testSourceFile)] =
testFileStats;
- var dirMap = FileUpdater.mapDirectory('', testSourceDir, ['**'], []);
+ const dirMap = FileUpdater.mapDirectory('', testSourceDir, ['**'], []);
expect(Object.keys(dirMap).sort()).toEqual([
'',
testSubDir,
@@ -415,7 +415,7 @@ describe('FileUpdater class', function () {
mockFs.dirMap[testSourceDir] = [testSourceFile, testSourceFile2];
mockFs.statMap[path.join(testSourceDir, testSourceFile)] = testFileStats;
mockFs.statMap[path.join(testSourceDir, testSourceFile2)] = testFileStats;
- var dirMap = FileUpdater.mapDirectory('', testSourceDir, [testSourceFile], []);
+ const dirMap = FileUpdater.mapDirectory('', testSourceDir, [testSourceFile], []);
expect(Object.keys(dirMap).sort()).toEqual(['', testSourceFile]);
expect(dirMap[''].subDir).toBe(testSourceDir);
expect(dirMap[''].stats).toBe(testDirStats);
@@ -431,7 +431,7 @@ describe('FileUpdater class', function () {
[testSourceFile, testSourceFile2];
mockFs.statMap[path.join(testSourceDir, testSubDir, testSourceFile)] = testFileStats;
mockFs.statMap[path.join(testSourceDir, testSubDir, testSourceFile2)] = testFileStats;
- var dirMap = FileUpdater.mapDirectory('', testSourceDir, ['**/' + testSourceFile], []);
+ const dirMap = FileUpdater.mapDirectory('', testSourceDir, ['**/' + testSourceFile], []);
expect(Object.keys(dirMap).sort()).toEqual([
'',
path.join(testSubDir, testSourceFile)]);
@@ -446,7 +446,7 @@ describe('FileUpdater class', function () {
mockFs.dirMap[testSourceDir] = [testSourceFile, testSourceFile2];
mockFs.statMap[path.join(testSourceDir, testSourceFile)] = testFileStats;
mockFs.statMap[path.join(testSourceDir, testSourceFile2)] = testFileStats;
- var dirMap = FileUpdater.mapDirectory('', testSourceDir, ['**'], [testSourceFile2]);
+ const dirMap = FileUpdater.mapDirectory('', testSourceDir, ['**'], [testSourceFile2]);
expect(Object.keys(dirMap).sort()).toEqual(['', testSourceFile]);
expect(dirMap[''].subDir).toBe(testSourceDir);
expect(dirMap[''].stats).toBe(testDirStats);
@@ -462,7 +462,7 @@ describe('FileUpdater class', function () {
[testSourceFile, testSourceFile2];
mockFs.statMap[path.join(testSourceDir, testSubDir, testSourceFile)] = testFileStats;
mockFs.statMap[path.join(testSourceDir, testSubDir, testSourceFile2)] = testFileStats;
- var dirMap = FileUpdater.mapDirectory(
+ const dirMap = FileUpdater.mapDirectory(
'', testSourceDir, ['**/' + testSourceFile], [testSubDir]);
expect(Object.keys(dirMap).sort()).toEqual(['']);
expect(dirMap[''].subDir).toBe(testSourceDir);
@@ -471,13 +471,13 @@ describe('FileUpdater class', function () {
});
describe('mergePathMaps method', function () {
- var testTargetFileStats = mockFileStats(oneHourAgo);
- var testSourceFileStats = mockFileStats(now);
- var testSourceFileStats2 = mockFileStats(now);
- var testSourceFileStats3 = mockFileStats(now);
+ const testTargetFileStats = mockFileStats(oneHourAgo);
+ const testSourceFileStats = mockFileStats(now);
+ const testSourceFileStats2 = mockFileStats(now);
+ const testSourceFileStats3 = mockFileStats(now);
it('Test 027 : should prepend the target directory on target paths', function () {
- var mergedPathMap = FileUpdater.mergePathMaps(
+ const mergedPathMap = FileUpdater.mergePathMaps(
[{
'': { subDir: testSourceDir, stats: testDirStats },
testTargetFile: { subDir: testSourceDir, stats: testSourceFileStats }
@@ -501,7 +501,7 @@ describe('FileUpdater class', function () {
});
it('Test 028 : should handle missing source files', function () {
- var mergedPathMap = FileUpdater.mergePathMaps(
+ const mergedPathMap = FileUpdater.mergePathMaps(
[{}],
{
testTargetFile: { subDir: testTargetDir, stats: testTargetFileStats }
@@ -516,7 +516,7 @@ describe('FileUpdater class', function () {
});
it('Tets 029 : should handle missing target files', function () {
- var mergedPathMap = FileUpdater.mergePathMaps(
+ const mergedPathMap = FileUpdater.mergePathMaps(
[{
testTargetFile: { subDir: testSourceDir, stats: testSourceFileStats }
}],
@@ -532,7 +532,7 @@ describe('FileUpdater class', function () {
});
it('Test 030 : should merge three source maps', function () {
- var mergedPathMap = FileUpdater.mergePathMaps(
+ const mergedPathMap = FileUpdater.mergePathMaps(
[
{
'': { subDir: testSourceDir, stats: testDirStats },
@@ -579,7 +579,7 @@ describe('FileUpdater class', function () {
mockFs.statMap[testRootDir] = testDirStats;
mockFs.statMap[path.join(testRootDir, testTargetFile)] = testFileStats;
mockFs.statMap[path.join(testRootDir, testSourceFile)] = testFileStats2;
- var updated = FileUpdater.updatePath(
+ const updated = FileUpdater.updatePath(
testSourceFile, testTargetFile, { rootDir: testRootDir, all: true });
expect(updated).toBe(true);
expect(FileUpdater.updatePathWithStatsCalls.length).toBe(1);
@@ -595,7 +595,7 @@ describe('FileUpdater class', function () {
mockFs.statMap[testTargetFile] = testFileStats;
mockFs.statMap[testSourceFile] = testFileStats2;
FileUpdater.updatePathWithStatsResult = false;
- var updated = FileUpdater.updatePath(testSourceFile, testTargetFile);
+ const updated = FileUpdater.updatePath(testSourceFile, testTargetFile);
expect(updated).toBe(false);
expect(FileUpdater.updatePathWithStatsCalls.length).toBe(1);
expect(FileUpdater.updatePathWithStatsCalls[0][0]).toBe(testSourceFile);
@@ -607,7 +607,7 @@ describe('FileUpdater class', function () {
it('Test 033 : should update a path when the source doesn\'t exist', function () {
mockFs.statMap[testTargetFile] = testFileStats;
- var updated = FileUpdater.updatePath(null, testTargetFile);
+ const updated = FileUpdater.updatePath(null, testTargetFile);
expect(updated).toBe(true);
expect(FileUpdater.updatePathWithStatsCalls.length).toBe(1);
expect(FileUpdater.updatePathWithStatsCalls[0][0]).toBeNull();
@@ -619,7 +619,7 @@ describe('FileUpdater class', function () {
it('Test 034 : should update a path when the target doesn\'t exist', function () {
mockFs.statMap[testSourceFile] = testFileStats2;
- var updated = FileUpdater.updatePath(testSourceFile, testTargetFile);
+ const updated = FileUpdater.updatePath(testSourceFile, testTargetFile);
expect(updated).toBe(true);
expect(FileUpdater.updatePathWithStatsCalls.length).toBe(1);
expect(FileUpdater.updatePathWithStatsCalls[0][0]).toBe(testSourceFile);
@@ -653,14 +653,14 @@ describe('FileUpdater class', function () {
mockFs.statMap[path.join(testSourceDir2, testSubDir, testSourceFile2)] =
testFileStats3;
- var updated = FileUpdater.mergeAndUpdateDir(
+ const updated = FileUpdater.mergeAndUpdateDir(
[testSourceDir, testSourceDir2], testTargetDir);
expect(updated).toBe(true);
expect(FileUpdater.updatePathWithStatsCalls.length).toBe(4);
function validateUpdatePathWithStatsCall (
index, subPath, sourceDir, sourceStats, targetDir, targetStats) {
- var args = FileUpdater.updatePathWithStatsCalls[index];
+ const args = FileUpdater.updatePathWithStatsCalls[index];
expect(args[0]).toBe(path.join(sourceDir, subPath));
expect(args[1]).toEqual(sourceStats);
expect(args[2]).toBe(path.join(targetDir, subPath));
@@ -703,7 +703,7 @@ describe('FileUpdater class', function () {
});
it('Test 037 : should update files from merged source directories - with a rootDir', function () {
- var rootDir = path.join('Users', 'me');
+ const rootDir = path.join('Users', 'me');
mockFs.statMap[rootDir] = testDirStats;
mockFs.dirMap[rootDir] = [testSourceDir, testSourceDir2, testTargetDir];
@@ -728,14 +728,14 @@ describe('FileUpdater class', function () {
mockFs.statMap[path.join(rootDir, testSourceDir2, testSubDir, testSourceFile2)] =
testFileStats3;
- var updated = FileUpdater.mergeAndUpdateDir(
+ const updated = FileUpdater.mergeAndUpdateDir(
[testSourceDir, testSourceDir2], testTargetDir, { rootDir: rootDir });
expect(updated).toBe(true);
expect(FileUpdater.updatePathWithStatsCalls.length).toBe(4);
function validateUpdatePathWithStatsCall (
index, subPath, sourceDir, sourceStats, targetDir, targetStats) {
- var args = FileUpdater.updatePathWithStatsCalls[index];
+ const args = FileUpdater.updatePathWithStatsCalls[index];
expect(args[0]).toBe(path.join(sourceDir, subPath));
expect(args[1]).toEqual(sourceStats);
expect(args[2]).toBe(path.join(targetDir, subPath));
diff --git a/spec/PlatformJson.spec.js b/spec/PlatformJson.spec.js
index e6492f4..3a82565 100644
--- a/spec/PlatformJson.spec.js
+++ b/spec/PlatformJson.spec.js
@@ -17,11 +17,11 @@
under the License.
*/
-var rewire = require('rewire');
-var PlatformJson = rewire('../src/PlatformJson');
-var ModuleMetadata = PlatformJson.__get__('ModuleMetadata');
+const rewire = require('rewire');
+const PlatformJson = rewire('../src/PlatformJson');
+const ModuleMetadata = PlatformJson.__get__('ModuleMetadata');
-var FAKE_MODULE = {
+const FAKE_MODULE = {
name: 'fakeModule',
src: 'www/fakeModule.js',
clobbers: [{ target: 'window.fakeClobber' }],
@@ -35,8 +35,8 @@ describe('PlatformJson class', function () {
});
describe('instance', function () {
- var platformJson;
- var fakePlugin;
+ let platformJson;
+ let fakePlugin;
beforeEach(function () {
platformJson = new PlatformJson('/fake/path', 'android');
@@ -84,7 +84,7 @@ describe('PlatformJson class', function () {
});
it('Test 007 : should remove plugin modules from "root.modules" array based on file path', function () {
- var pluginPaths = [
+ const pluginPaths = [
'plugins/fakeId/www/fakeModule.js',
'plugins/otherPlugin/www/module1.js',
'plugins/otherPlugin/www/module1.js'
@@ -92,7 +92,7 @@ describe('PlatformJson class', function () {
platformJson.root.modules = pluginPaths.map(function (p) { return { file: p }; });
platformJson.removePluginMetadata(fakePlugin);
- var resultantPaths = platformJson.root.modules
+ const resultantPaths = platformJson.root.modules
.map(function (p) { return p.file; })
.filter(function (f) { return /fakeModule\.js$/.test(f); });
@@ -151,7 +151,7 @@ describe('PlatformJson class', function () {
describe('ModuleMetadata class', function () {
it('Test 010 : should be constructable', function () {
- var meta;
+ let meta;
expect(function () {
meta = new ModuleMetadata('fakePlugin', { src: 'www/fakeModule.js' });
}).not.toThrow();
@@ -170,14 +170,14 @@ describe('ModuleMetadata class', function () {
it('Test 013 : should read "clobbers" property from module', function () {
expect(new ModuleMetadata('fakePlugin', { name: 'fakeModule' }).clobbers).not.toBeDefined();
- var metadata = new ModuleMetadata('fakePlugin', FAKE_MODULE);
+ const metadata = new ModuleMetadata('fakePlugin', FAKE_MODULE);
expect(metadata.clobbers).toEqual(jasmine.any(Array));
expect(metadata.clobbers[0]).toBe(FAKE_MODULE.clobbers[0].target);
});
it('Test 014 : should read "merges" property from module', function () {
expect(new ModuleMetadata('fakePlugin', { name: 'fakeModule' }).merges).not.toBeDefined();
- var metadata = new ModuleMetadata('fakePlugin', FAKE_MODULE);
+ const metadata = new ModuleMetadata('fakePlugin', FAKE_MODULE);
expect(metadata.merges).toEqual(jasmine.any(Array));
expect(metadata.merges[0]).toBe(FAKE_MODULE.merges[0].target);
});
diff --git a/spec/PluginInfo/PluginInfo.spec.js b/spec/PluginInfo/PluginInfo.spec.js
index e508f86..458eb56 100644
--- a/spec/PluginInfo/PluginInfo.spec.js
+++ b/spec/PluginInfo/PluginInfo.spec.js
@@ -17,9 +17,9 @@
under the License.
*/
-var PluginInfo = require('../../src/PluginInfo/PluginInfo');
-var path = require('path');
-var pluginsDir = path.join(__dirname, '../fixtures/plugins');
+const PluginInfo = require('../../src/PluginInfo/PluginInfo');
+const path = require('path');
+const pluginsDir = path.join(__dirname, '../fixtures/plugins');
describe('PluginInfo', function () {
it('Test 001 : should read a plugin.xml file', function () {
@@ -48,22 +48,22 @@ describe('PluginInfo', function () {
});
it('Test 003: replace framework src', function () {
- var p = new PluginInfo(path.join(pluginsDir, 'org.test.src'));
- var result = p.getFrameworks('android', { cli_variables: { FCM_VERSION: '9.0.0' } });
+ const p = new PluginInfo(path.join(pluginsDir, 'org.test.src'));
+ const result = p.getFrameworks('android', { cli_variables: { FCM_VERSION: '9.0.0' } });
expect(result[2].src).toBe('com.google.firebase:firebase-messaging:9.0.0');
});
it('Test 004: framework src uses default variable', function () {
- var p = new PluginInfo(path.join(pluginsDir, 'org.test.src'));
- var result = p.getFrameworks('android', {});
+ const p = new PluginInfo(path.join(pluginsDir, 'org.test.src'));
+ const result = p.getFrameworks('android', {});
expect(result[2].src).toBe('com.google.firebase:firebase-messaging:11.0.1');
});
it('Test 005: read podspec', function () {
- var p = new PluginInfo(path.join(pluginsDir, 'org.test.plugins.withcocoapods'));
- var result = p.getPodSpecs('ios');
+ const p = new PluginInfo(path.join(pluginsDir, 'org.test.plugins.withcocoapods'));
+ const result = p.getPodSpecs('ios');
expect(result.length).toBe(1);
- var podSpec = result[0];
+ const podSpec = result[0];
expect(Object.keys(podSpec.declarations).length).toBe(2);
expect(Object.keys(podSpec.sources).length).toBe(1);
expect(Object.keys(podSpec.libraries).length).toBe(4);
diff --git a/spec/PluginInfo/PluginInfoProvider.spec.js b/spec/PluginInfo/PluginInfoProvider.spec.js
index 6331ba8..c81f0e8 100644
--- a/spec/PluginInfo/PluginInfoProvider.spec.js
+++ b/spec/PluginInfo/PluginInfoProvider.spec.js
@@ -17,16 +17,16 @@
under the License.
*/
-var PluginInfoProvider = require('../../src/PluginInfo/PluginInfoProvider');
-var path = require('path');
+const PluginInfoProvider = require('../../src/PluginInfo/PluginInfoProvider');
+const path = require('path');
-var pluginsDir = path.join(__dirname, '../fixtures/plugins');
+const pluginsDir = path.join(__dirname, '../fixtures/plugins');
describe('PluginInfoProvider', function () {
describe('getAllWithinSearchPath', function () {
it('Test 001 : should load all plugins in a dir', function () {
- var pluginInfoProvider = new PluginInfoProvider();
- var plugins = pluginInfoProvider.getAllWithinSearchPath(pluginsDir);
+ const pluginInfoProvider = new PluginInfoProvider();
+ const plugins = pluginInfoProvider.getAllWithinSearchPath(pluginsDir);
expect(plugins.length).not.toBe(0);
expect(plugins).toContain(jasmine.objectContaining({
id: 'org.test.scoped',
diff --git a/spec/PluginManager.spec.js b/spec/PluginManager.spec.js
index 1e6ea36..8062b2e 100644
--- a/spec/PluginManager.spec.js
+++ b/spec/PluginManager.spec.js
@@ -17,18 +17,18 @@
under the License.
*/
-var Q = require('q');
-var fs = require('fs-extra');
-var path = require('path');
-var rewire = require('rewire');
-var PluginInfo = require('../src/PluginInfo/PluginInfo');
-var ConfigChanges = require('../src/ConfigChanges/ConfigChanges');
-
-var PluginManager = rewire('../src/PluginManager');
-
-var DUMMY_PLUGIN = path.join(__dirname, 'fixtures/plugins/org.test.plugins.dummyplugin');
-var FAKE_PLATFORM = 'cordova-atari';
-var FAKE_LOCATIONS = {
+const Q = require('q');
+const fs = require('fs-extra');
+const path = require('path');
+const rewire = require('rewire');
+const PluginInfo = require('../src/PluginInfo/PluginInfo');
+const ConfigChanges = require('../src/ConfigChanges/ConfigChanges');
+
+const PluginManager = rewire('../src/PluginManager');
+
+const DUMMY_PLUGIN = path.join(__dirname, 'fixtures/plugins/org.test.plugins.dummyplugin');
+const FAKE_PLATFORM = 'cordova-atari';
+const FAKE_LOCATIONS = {
root: '/some/fake/path',
platformWww: '/some/fake/path/platform_www',
www: '/some/www/dir'
@@ -53,9 +53,9 @@ describe('PluginManager class', function () {
});
describe('instance', function () {
- var actions, manager;
- var FAKE_PROJECT;
- var ActionStackOrig = PluginManager.__get__('ActionStack');
+ let actions, manager;
+ let FAKE_PROJECT;
+ const ActionStackOrig = PluginManager.__get__('ActionStack');
beforeEach(function () {
FAKE_PROJECT = jasmine.createSpyObj('project', ['getInstaller', 'getUninstaller', 'write']);
@@ -93,8 +93,8 @@ describe('PluginManager class', function () {
});
it('Test 005 : should save plugin metadata to www directory', () => {
- var metadataPath = path.join(manager.locations.www, 'cordova_plugins.js');
- var platformWwwMetadataPath = path.join(manager.locations.platformWww, 'cordova_plugins.js');
+ const metadataPath = path.join(manager.locations.www, 'cordova_plugins.js');
+ const platformWwwMetadataPath = path.join(manager.locations.platformWww, 'cordova_plugins.js');
return manager.addPlugin(new PluginInfo(DUMMY_PLUGIN), {})
.then(function () {
@@ -104,8 +104,8 @@ describe('PluginManager class', function () {
});
it('Test 006 : should save plugin metadata to both www ans platform_www directories when options.usePlatformWww is specified', () => {
- var metadataPath = path.join(manager.locations.www, 'cordova_plugins.js');
- var platformWwwMetadataPath = path.join(manager.locations.platformWww, 'cordova_plugins.js');
+ const metadataPath = path.join(manager.locations.www, 'cordova_plugins.js');
+ const platformWwwMetadataPath = path.join(manager.locations.platformWww, 'cordova_plugins.js');
return manager.addPlugin(new PluginInfo(DUMMY_PLUGIN), { usePlatformWww: true })
.then(function () {
diff --git a/spec/plist-helpers.spec.js b/spec/plist-helpers.spec.js
index eb6c5e0..6a806a0 100644
--- a/spec/plist-helpers.spec.js
+++ b/spec/plist-helpers.spec.js
@@ -17,10 +17,10 @@
under the License.
*/
-var plistHelpers = require('../src/util/plist-helpers');
+const plistHelpers = require('../src/util/plist-helpers');
describe('prunePLIST', function () {
- var doc = {
+ const doc = {
FirstConfigKey: {
FirstPreferenceName: '*',
SecondPreferenceName: 'a + b',
@@ -32,7 +32,7 @@ describe('prunePLIST', function () {
}
};
- var xml = '<dict>' +
+ const xml = '<dict>' +
'<key>FirstPreferenceName</key>' +
'<string>*</string>' +
'<key>SecondPreferenceName</key>' +
@@ -41,10 +41,10 @@ describe('prunePLIST', function () {
'<string>x-msauth-$(CFBundleIdentifier:rfc1034identifier)</string>' +
'</dict>';
- var selector = 'FirstConfigKey';
+ const selector = 'FirstConfigKey';
it('Test 01: should remove property from plist file using provided selector', () => {
- var pruneStatus = plistHelpers.prunePLIST(doc, xml, selector);
+ const pruneStatus = plistHelpers.prunePLIST(doc, xml, selector);
expect(pruneStatus).toBeTruthy();
expect(doc).toEqual(
@@ -73,7 +73,7 @@ describe('plistGraft', function () {
const selector = 'keychain-access-groups';
it('Test 01: should not mangle existing plist entries', () => {
- var graftStatus = plistHelpers.graftPLIST(doc, xml, selector);
+ const graftStatus = plistHelpers.graftPLIST(doc, xml, selector);
expect(graftStatus).toBeTruthy();
expect(doc).toEqual(
diff --git a/spec/superspawn.spec.js b/spec/superspawn.spec.js
index 2c6920c..13e0206 100644
--- a/spec/superspawn.spec.js
+++ b/spec/superspawn.spec.js
@@ -17,13 +17,13 @@
under the License.
*/
-var path = require('path');
-var superspawn = require('../src/superspawn');
+const path = require('path');
+const superspawn = require('../src/superspawn');
-var LS = process.platform === 'win32' ? 'dir' : 'ls';
+const LS = process.platform === 'win32' ? 'dir' : 'ls';
describe('spawn method', function () {
- var progressSpy;
+ let progressSpy;
beforeEach(function () {
progressSpy = jasmine.createSpy('progress');
@@ -56,7 +56,7 @@ describe('spawn method', function () {
});
it('Test 004 : reject handler should pass in Error object with stdout and stderr properties', () => {
- var cp = require('child_process');
+ const cp = require('child_process');
spyOn(cp, 'spawn').and.callFake(() => {
return {
stdout: {
diff --git a/spec/util/xml-helpers.spec.js b/spec/util/xml-helpers.spec.js
index a5de372..fe0ef44 100644
--- a/spec/util/xml-helpers.spec.js
+++ b/spec/util/xml-helpers.spec.js
@@ -17,22 +17,22 @@
under the License.
*/
-var path = require('path');
-var et = require('elementtree');
-var xml_helpers = require('../../src/util/xml-helpers');
+const path = require('path');
+const et = require('elementtree');
+const xml_helpers = require('../../src/util/xml-helpers');
-var title = et.XML('<title>HELLO</title>');
-var usesNetworkOne = et.XML(`<uses-permission
+const title = et.XML('<title>HELLO</title>');
+const usesNetworkOne = et.XML(`<uses-permission
android:name="PACKAGE_NAME.permission.C2D_MESSAGE"/>`);
-var usesNetworkTwo = et.XML(`<uses-permission
+const usesNetworkTwo = et.XML(`<uses-permission
android:name="PACKAGE_NAME.permission.C2D_MESSAGE" />`);
-var usesReceive = et.XML(`<uses-permission
+const usesReceive = et.XML(`<uses-permission
android:name="com.google.android.c2dm.permission.RECEIVE"/>`);
-var helloTagOne = et.XML('<h1>HELLO</h1>');
-var goodbyeTag = et.XML('<h1>GOODBYE</h1>');
-var helloTagTwo = et.XML('<h1> HELLO </h1>');
+const helloTagOne = et.XML('<h1>HELLO</h1>');
+const goodbyeTag = et.XML('<h1>GOODBYE</h1>');
+const helloTagTwo = et.XML('<h1> HELLO </h1>');
-var TEST_XML = '<?xml version="1.0" encoding="UTF-8"?>\n' +
+const TEST_XML = '<?xml version="1.0" encoding="UTF-8"?>\n' +
'<widget xmlns = "http://www.w3.org/ns/widgets"\n' +
' xmlns:cdv = "http://cordova.apache.org/ns/1.0"\n' +
' id = "io.cordova.hellocordova"\n' +
@@ -53,7 +53,7 @@ var TEST_XML = '<?xml version="1.0" encoding="UTF-8"?>\n' +
describe('xml-helpers', function () {
describe('parseElementtreeSync', function () {
it('Test 001 : should parse xml with a byte order mark', function () {
- var xml_path = path.join(__dirname, '../fixtures/projects/windows/bom_test.xml');
+ const xml_path = path.join(__dirname, '../fixtures/projects/windows/bom_test.xml');
expect(function () {
xml_helpers.parseElementtreeSync(xml_path);
}).not.toThrow();
@@ -83,16 +83,16 @@ describe('xml-helpers', function () {
describe('should compare children', function () {
it('Test 007: by child quantity', function () {
- var one = et.XML('<i><b>o</b></i>');
- var two = et.XML('<i><b>o</b><u></u></i>');
+ const one = et.XML('<i><b>o</b></i>');
+ const two = et.XML('<i><b>o</b><u></u></i>');
expect(xml_helpers.equalNodes(one, two)).toBe(false);
});
it('Test 008 : by child equality', function () {
- var one = et.XML('<i><b>o</b></i>');
- var two = et.XML('<i><u></u></i>');
- var uno = et.XML('<i>\n<b>o</b>\n</i>');
+ const one = et.XML('<i><b>o</b></i>');
+ const two = et.XML('<i><u></u></i>');
+ const uno = et.XML('<i>\n<b>o</b>\n</i>');
expect(xml_helpers.equalNodes(one, uno)).toBe(true);
expect(xml_helpers.equalNodes(one, two)).toBe(false);
@@ -101,97 +101,97 @@ describe('xml-helpers', function () {
});
describe('pruneXML', function () {
- var config_xml;
+ let config_xml;
beforeEach(function () {
config_xml = xml_helpers.parseElementtreeSync(path.join(__dirname, '../fixtures/projects/android/res/xml/config.xml'));
});
it('Test 009 : should remove any children that match the specified selector', function () {
- var children = config_xml.findall('plugins/plugin');
+ const children = config_xml.findall('plugins/plugin');
xml_helpers.pruneXML(config_xml, children, 'plugins');
expect(config_xml.find('plugins').getchildren().length).toEqual(0);
});
it('Test 010 : should do nothing if the children cannot be found', function () {
- var children = [title];
+ const children = [title];
xml_helpers.pruneXML(config_xml, children, 'plugins');
expect(config_xml.find('plugins').getchildren().length).toEqual(17);
});
it('Test 011 : should be able to handle absolute selectors', function () {
- var children = config_xml.findall('plugins/plugin');
+ const children = config_xml.findall('plugins/plugin');
xml_helpers.pruneXML(config_xml, children, '/cordova/plugins');
expect(config_xml.find('plugins').getchildren().length).toEqual(0);
});
it('Test 012 : should be able to handle absolute selectors with wildcards', function () {
- var children = config_xml.findall('plugins/plugin');
+ const children = config_xml.findall('plugins/plugin');
xml_helpers.pruneXML(config_xml, children, '/*/plugins');
expect(config_xml.find('plugins').getchildren().length).toEqual(0);
});
});
describe('pruneXMLRestore', function () {
- var android_manifest_xml;
+ let android_manifest_xml;
beforeEach(function () {
android_manifest_xml = xml_helpers.parseElementtreeSync(path.join(__dirname, '../fixtures/projects/android/AndroidManifest.xml'));
});
it('Test 013 : should restore attributes at the specified selector', function () {
- var xml = {
+ const xml = {
oldAttrib: { 'android:icon': '@drawable/icon', 'android:label': '@string/app_name', 'android:debuggable': 'false' }
};
xml_helpers.pruneXMLRestore(android_manifest_xml, 'application', xml);
- var applicationAttr = android_manifest_xml.find('application').attrib;
+ const applicationAttr = android_manifest_xml.find('application').attrib;
expect(Object.keys(applicationAttr).length).toEqual(3);
expect(applicationAttr['android:debuggable']).toEqual('false');
});
it('Test 014 : should do nothing if the old attributes cannot be found', function () {
- var xml = {
+ const xml = {
notOldAttrib: { 'android:icon': '@drawable/icon', 'android:label': '@string/app_name', 'android:debuggable': 'false' }
};
xml_helpers.pruneXMLRestore(android_manifest_xml, 'application', xml);
- var applicationAttr = android_manifest_xml.find('application').attrib;
+ const applicationAttr = android_manifest_xml.find('application').attrib;
expect(Object.keys(applicationAttr).length).toEqual(3);
expect(applicationAttr['android:debuggable']).toEqual('true');
});
it('Test 015 : should be able to handle absolute selectors', function () {
- var xml = {
+ const xml = {
oldAttrib: { 'android:icon': '@drawable/icon', 'android:label': '@string/app_name', 'android:debuggable': 'false' }
};
xml_helpers.pruneXMLRestore(android_manifest_xml, '/manifest/application', xml);
- var applicationAttr = android_manifest_xml.find('application').attrib;
+ const applicationAttr = android_manifest_xml.find('application').attrib;
expect(Object.keys(applicationAttr).length).toEqual(3);
expect(applicationAttr['android:debuggable']).toEqual('false');
});
it('Test 016 : should be able to handle absolute selectors with wildcards', function () {
- var xml = {
+ const xml = {
oldAttrib: { 'android:name': 'ChildApp', 'android:label': '@string/app_name', 'android:configChanges': 'orientation|keyboardHidden', 'android:enabled': 'true' }
};
xml_helpers.pruneXMLRestore(android_manifest_xml, '/*/*/activity', xml);
- var activityAttr = android_manifest_xml.find('application/activity').attrib;
+ const activityAttr = android_manifest_xml.find('application/activity').attrib;
expect(Object.keys(activityAttr).length).toEqual(4);
expect(activityAttr['android:enabled']).toEqual('true');
});
it('Test 017 : should be able to handle xpath selectors', function () {
- var xml = {
+ const xml = {
oldAttrib: { 'android:name': 'com.phonegap.DroidGap', 'android:label': '@string/app_name', 'android:configChanges': 'orientation|keyboardHidden', 'android:enabled': 'true' }
};
xml_helpers.pruneXMLRestore(android_manifest_xml, 'application/activity[@android:name="com.phonegap.DroidGap"]', xml);
- var activityAttr = android_manifest_xml.find('application/activity[@android:name="com.phonegap.DroidGap"]').attrib;
+ const activityAttr = android_manifest_xml.find('application/activity[@android:name="com.phonegap.DroidGap"]').attrib;
expect(Object.keys(activityAttr).length).toEqual(4);
expect(activityAttr['android:enabled']).toEqual('true');
});
});
describe('graftXML', function () {
- var config_xml, plugin_xml;
+ let config_xml, plugin_xml;
beforeEach(function () {
config_xml = xml_helpers.parseElementtreeSync(path.join(__dirname, '../fixtures/projects/android/res/xml/config.xml'));
@@ -199,33 +199,33 @@ describe('xml-helpers', function () {
});
it('Test 018 : should add children to the specified selector', function () {
- var children = plugin_xml.find('config-file').getchildren();
+ const children = plugin_xml.find('config-file').getchildren();
xml_helpers.graftXML(config_xml, children, 'plugins');
expect(config_xml.find('plugins').getchildren().length).toEqual(19);
});
it('Test 019 : should be able to handle absolute selectors', function () {
- var children = plugin_xml.find('config-file').getchildren();
+ const children = plugin_xml.find('config-file').getchildren();
xml_helpers.graftXML(config_xml, children, '/cordova');
expect(config_xml.findall('access').length).toEqual(3);
});
it('Test 020 : should be able to handle absolute selectors with wildcards', function () {
- var children = plugin_xml.find('config-file').getchildren();
+ const children = plugin_xml.find('config-file').getchildren();
xml_helpers.graftXML(config_xml, children, '/*');
expect(config_xml.findall('access').length).toEqual(3);
});
it('Test 020-1 : should create parent', function () {
- var config_xml0 = xml_helpers.parseElementtreeSync(path.join(__dirname, '../fixtures/test-config0.xml'));
- var children = plugin_xml.find('platform[@name="ios"]/config-file').getchildren();
+ const config_xml0 = xml_helpers.parseElementtreeSync(path.join(__dirname, '../fixtures/test-config0.xml'));
+ const children = plugin_xml.find('platform[@name="ios"]/config-file').getchildren();
xml_helpers.graftXML(config_xml0, children, '/widget/plugins');
expect(config_xml0.find('plugins').getchildren().length).toEqual(1);
});
});
describe('graftXMLMerge', function () {
- var plugin_xml, android_manifest_xml;
+ let plugin_xml, android_manifest_xml;
beforeEach(function () {
plugin_xml = xml_helpers.parseElementtreeSync(path.join(__dirname, '../fixtures/plugins/org.test.editconfigtest/plugin.xml'));
@@ -233,36 +233,36 @@ describe('xml-helpers', function () {
});
it('Test 021 : should merge attributes at specified selector', function () {
- var children = plugin_xml.find('platform/edit-config[@mode="merge"]').getchildren();
+ const children = plugin_xml.find('platform/edit-config[@mode="merge"]').getchildren();
xml_helpers.graftXMLMerge(android_manifest_xml, children, 'application/activity[@android:name="com.phonegap.DroidGap"]', {});
- var activityAttr = android_manifest_xml.find('application/activity[@android:name="com.phonegap.DroidGap"]').attrib;
+ const activityAttr = android_manifest_xml.find('application/activity[@android:name="com.phonegap.DroidGap"]').attrib;
expect(Object.keys(activityAttr).length).toEqual(4);
expect(activityAttr['android:enabled']).toEqual('true');
expect(activityAttr['android:configChanges']).toEqual('keyboardHidden');
});
it('Test 022 : should be able to handle absolute selectors', function () {
- var children = plugin_xml.find('platform/edit-config[@mode="merge"]').getchildren();
+ const children = plugin_xml.find('platform/edit-config[@mode="merge"]').getchildren();
xml_helpers.graftXMLMerge(android_manifest_xml, children, '/manifest/application/activity[@android:name="com.phonegap.DroidGap"]', {});
- var activityAttr = android_manifest_xml.find('application/activity[@android:name="com.phonegap.DroidGap"]').attrib;
+ const activityAttr = android_manifest_xml.find('application/activity[@android:name="com.phonegap.DroidGap"]').attrib;
expect(Object.keys(activityAttr).length).toEqual(4);
expect(activityAttr['android:enabled']).toEqual('true');
expect(activityAttr['android:configChanges']).toEqual('keyboardHidden');
});
it('Test 023 : should be able to handle absolute selectors with wildcards', function () {
- var children = plugin_xml.find('platform/edit-config[@mode="merge"]').getchildren();
+ const children = plugin_xml.find('platform/edit-config[@mode="merge"]').getchildren();
xml_helpers.graftXMLMerge(android_manifest_xml, children, '/*/*/activity[@android:name="com.phonegap.DroidGap"]', {});
- var activityAttr = android_manifest_xml.find('application/activity[@android:name="com.phonegap.DroidGap"]').attrib;
+ const activityAttr = android_manifest_xml.find('application/activity[@android:name="com.phonegap.DroidGap"]').attrib;
expect(Object.keys(activityAttr).length).toEqual(4);
expect(activityAttr['android:enabled']).toEqual('true');
expect(activityAttr['android:configChanges']).toEqual('keyboardHidden');
});
it('Test 024 : should be able to handle xpath selectors', function () {
- var children = plugin_xml.find('platform/edit-config[@mode="merge"]').getchildren();
+ const children = plugin_xml.find('platform/edit-config[@mode="merge"]').getchildren();
xml_helpers.graftXMLMerge(android_manifest_xml, children, 'application/activity[@android:name="com.phonegap.DroidGap"]', {});
- var activityAttr = android_manifest_xml.find('application/activity[@android:name="com.phonegap.DroidGap"]').attrib;
+ const activityAttr = android_manifest_xml.find('application/activity[@android:name="com.phonegap.DroidGap"]').attrib;
expect(Object.keys(activityAttr).length).toEqual(4);
expect(activityAttr['android:enabled']).toEqual('true');
expect(activityAttr['android:configChanges']).toEqual('keyboardHidden');
@@ -270,7 +270,7 @@ describe('xml-helpers', function () {
});
describe('graftXMLOverwrite', function () {
- var plugin_xml, android_manifest_xml;
+ let plugin_xml, android_manifest_xml;
beforeEach(function () {
plugin_xml = xml_helpers.parseElementtreeSync(path.join(__dirname, '../fixtures/plugins/org.test.editconfigtest/plugin.xml'));
@@ -278,36 +278,36 @@ describe('xml-helpers', function () {
});
it('Test 025 : should overwrite attributes at specified selector', function () {
- var children = plugin_xml.find('platform/edit-config[@mode="overwrite"]').getchildren();
+ const children = plugin_xml.find('platform/edit-config[@mode="overwrite"]').getchildren();
xml_helpers.graftXMLOverwrite(android_manifest_xml, children, 'application/activity', {});
- var activityAttr = android_manifest_xml.find('application/activity').attrib;
+ const activityAttr = android_manifest_xml.find('application/activity').attrib;
expect(Object.keys(activityAttr).length).toEqual(3);
expect(activityAttr['android:enabled']).toEqual('true');
expect(activityAttr['android:configChanges']).not.toBeDefined();
});
it('Test 026 : should be able to handle absolute selectors', function () {
- var children = plugin_xml.find('platform/edit-config[@mode="overwrite"]').getchildren();
+ const children = plugin_xml.find('platform/edit-config[@mode="overwrite"]').getchildren();
xml_helpers.graftXMLOverwrite(android_manifest_xml, children, '/manifest/application/activity', {});
- var activityAttr = android_manifest_xml.find('application/activity').attrib;
+ const activityAttr = android_manifest_xml.find('application/activity').attrib;
expect(Object.keys(activityAttr).length).toEqual(3);
expect(activityAttr['android:enabled']).toEqual('true');
expect(activityAttr['android:configChanges']).not.toBeDefined();
});
it('Test 027 : should be able to handle absolute selectors with wildcards', function () {
- var children = plugin_xml.find('platform/edit-config[@mode="overwrite"]').getchildren();
+ const children = plugin_xml.find('platform/edit-config[@mode="overwrite"]').getchildren();
xml_helpers.graftXMLOverwrite(android_manifest_xml, children, '/*/*/activity', {});
- var activityAttr = android_manifest_xml.find('application/activity').attrib;
+ const activityAttr = android_manifest_xml.find('application/activity').attrib;
expect(Object.keys(activityAttr).length).toEqual(3);
expect(activityAttr['android:enabled']).toEqual('true');
expect(activityAttr['android:configChanges']).not.toBeDefined();
});
it('Test 028 : should be able to handle xpath selectors', function () {
- var children = plugin_xml.find('platform/edit-config[@mode="overwrite"]').getchildren();
+ const children = plugin_xml.find('platform/edit-config[@mode="overwrite"]').getchildren();
xml_helpers.graftXMLOverwrite(android_manifest_xml, children, 'application/activity[@android:name="ChildApp"]', {});
- var activityAttr = android_manifest_xml.find('application/activity').attrib;
+ const activityAttr = android_manifest_xml.find('application/activity').attrib;
expect(Object.keys(activityAttr).length).toEqual(3);
expect(activityAttr['android:enabled']).toEqual('true');
expect(activityAttr['android:configChanges']).not.toBeDefined();
@@ -315,14 +315,14 @@ describe('xml-helpers', function () {
});
describe('mergeXml', function () {
- var dstXml;
+ let dstXml;
beforeEach(function () {
dstXml = et.XML(TEST_XML);
});
it('Test 029 : should merge attributes and text of the root element without clobbering', function () {
- var testXml = et.XML('<widget foo="bar" id="NOTANID">TEXT</widget>');
+ const testXml = et.XML('<widget foo="bar" id="NOTANID">TEXT</widget>');
xml_helpers.mergeXml(testXml, dstXml);
expect(dstXml.attrib.foo).toEqual('bar');
expect(dstXml.attrib.id).not.toEqual('NOTANID');
@@ -330,7 +330,7 @@ describe('xml-helpers', function () {
});
it('Test 030 : should merge attributes and text of the root element with clobbering', function () {
- var testXml = et.XML('<widget foo="bar" id="NOTANID">TEXT</widget>');
+ const testXml = et.XML('<widget foo="bar" id="NOTANID">TEXT</widget>');
xml_helpers.mergeXml(testXml, dstXml, 'foo', true);
expect(dstXml.attrib.foo).toEqual('bar');
expect(dstXml.attrib.id).toEqual('NOTANID');
@@ -338,7 +338,7 @@ describe('xml-helpers', function () {
});
it('Test 031 : should handle attributes values with quotes correctly', function () {
- var testXml = et.XML('<widget><quote foo="some \'quoted\' string" bar="another "quoted" string" baz=""mixed" \'quotes\'" /></widget>');
+ const testXml = et.XML('<widget><quote foo="some \'quoted\' string" bar="another "quoted" string" baz=""mixed" \'quotes\'" /></widget>');
xml_helpers.mergeXml(testXml, dstXml);
expect(dstXml.find('quote')).toBeDefined();
expect(dstXml.find('quote').attrib.foo).toEqual('some \'quoted\' string');
@@ -347,30 +347,30 @@ describe('xml-helpers', function () {
});
it('Test 032 : should not merge platform tags with the wrong platform', function () {
- var testXml = et.XML('<widget><platform name="bar"><testElement testAttrib="value">testTEXT</testElement></platform></widget>');
- var origCfg = et.tostring(dstXml);
+ const testXml = et.XML('<widget><platform name="bar"><testElement testAttrib="value">testTEXT</testElement></platform></widget>');
+ const origCfg = et.tostring(dstXml);
xml_helpers.mergeXml(testXml, dstXml, 'foo', true);
expect(et.tostring(dstXml)).toEqual(origCfg);
});
it('Test 033 : should merge platform tags with the correct platform', function () {
- var testXml = et.XML('<widget><platform name="bar"><testElement testAttrib="value">testTEXT</testElement></platform></widget>');
- var origCfg = et.tostring(dstXml);
+ const testXml = et.XML('<widget><platform name="bar"><testElement testAttrib="value">testTEXT</testElement></platform></widget>');
+ const origCfg = et.tostring(dstXml);
xml_helpers.mergeXml(testXml, dstXml, 'bar', true);
expect(et.tostring(dstXml)).not.toEqual(origCfg);
- var testElement = dstXml.find('testElement');
+ const testElement = dstXml.find('testElement');
expect(testElement).toBeDefined();
expect(testElement.attrib.testAttrib).toEqual('value');
expect(testElement.text).toEqual('testTEXT');
});
it('Test 034 : should merge singleton children without clobber', function () {
- var testXml = et.XML('<widget><author testAttrib="value" href="http://www.nowhere.com">SUPER_AUTHOR</author></widget>');
+ const testXml = et.XML('<widget><author testAttrib="value" href="http://www.nowhere.com">SUPER_AUTHOR</author></widget>');
xml_helpers.mergeXml(testXml, dstXml);
- var testElements = dstXml.findall('author');
+ const testElements = dstXml.findall('author');
expect(testElements).toBeDefined();
expect(testElements.length).toEqual(1);
expect(testElements[0].attrib.testAttrib).toEqual('value');
@@ -380,20 +380,20 @@ describe('xml-helpers', function () {
});
it('Test 035 : should merge singleton name without clobber', function () {
- var testXml = et.XML('<widget><name>SUPER_NAME</name></widget>');
+ const testXml = et.XML('<widget><name>SUPER_NAME</name></widget>');
xml_helpers.mergeXml(testXml, dstXml);
- var testElements = dstXml.findall('name');
+ const testElements = dstXml.findall('name');
expect(testElements).toBeDefined();
expect(testElements.length).toEqual(1);
expect(testElements[0].text).toContain('Hello Cordova');
});
it('Test 036 : should clobber singleton children with clobber', function () {
- var testXml = et.XML('<widget><author testAttrib="value" href="http://www.nowhere.com">SUPER_AUTHOR</author></widget>');
+ const testXml = et.XML('<widget><author testAttrib="value" href="http://www.nowhere.com">SUPER_AUTHOR</author></widget>');
xml_helpers.mergeXml(testXml, dstXml, '', true);
- var testElements = dstXml.findall('author');
+ const testElements = dstXml.findall('author');
expect(testElements).toBeDefined();
expect(testElements.length).toEqual(1);
expect(testElements[0].attrib.testAttrib).toEqual('value');
@@ -403,51 +403,51 @@ describe('xml-helpers', function () {
});
it('Test 037 : should merge singleton name with clobber', function () {
- var testXml = et.XML('<widget><name>SUPER_NAME</name></widget>');
+ const testXml = et.XML('<widget><name>SUPER_NAME</name></widget>');
xml_helpers.mergeXml(testXml, dstXml, '', true);
- var testElements = dstXml.findall('name');
+ const testElements = dstXml.findall('name');
expect(testElements).toBeDefined();
expect(testElements.length).toEqual(1);
expect(testElements[0].text).toContain('SUPER_NAME');
});
it('Test 038 : should append non singelton children', function () {
- var testXml = et.XML('<widget><preference num="1"/> <preference num="2"/></widget>');
+ const testXml = et.XML('<widget><preference num="1"/> <preference num="2"/></widget>');
xml_helpers.mergeXml(testXml, dstXml, '', true);
- var testElements = dstXml.findall('preference');
+ const testElements = dstXml.findall('preference');
expect(testElements.length).toEqual(4);
});
it('Test 039 : should handle namespaced elements', function () {
- var testXml = et.XML('<widget><foo:bar testAttrib="value">testText</foo:bar></widget>');
+ const testXml = et.XML('<widget><foo:bar testAttrib="value">testText</foo:bar></widget>');
xml_helpers.mergeXml(testXml, dstXml, 'foo', true);
- var testElement = dstXml.find('foo:bar');
+ const testElement = dstXml.find('foo:bar');
expect(testElement).toBeDefined();
expect(testElement.attrib.testAttrib).toEqual('value');
expect(testElement.text).toEqual('testText');
});
it('Test 040 : should not append duplicate non singelton children', function () {
- var testXml = et.XML('<widget><preference name="fullscreen" value="true"/></widget>');
+ const testXml = et.XML('<widget><preference name="fullscreen" value="true"/></widget>');
xml_helpers.mergeXml(testXml, dstXml, '', true);
- var testElements = dstXml.findall('preference');
+ const testElements = dstXml.findall('preference');
expect(testElements.length).toEqual(2);
});
it('Test 041 : should not skip partial duplicate non singelton children', function () {
// remove access tags from dstXML
- var testElements = dstXml.findall('access');
- for (var i = 0; i < testElements.length; i++) {
+ let testElements = dstXml.findall('access');
+ for (let i = 0; i < testElements.length; i++) {
dstXml.remove(testElements[i]);
}
testElements = dstXml.findall('access');
expect(testElements.length).toEqual(0);
// add an external whitelist access tag
- var testXml = et.XML('<widget><access origin="*" launch-external="yes"/></widget>');
+ let testXml = et.XML('<widget><access origin="*" launch-external="yes"/></widget>');
xml_helpers.mergeXml(testXml, dstXml, '', true);
testElements = dstXml.findall('access');
expect(testElements.length).toEqual(1);
@@ -459,7 +459,7 @@ describe('xml-helpers', function () {
});
it('Test 042 : should remove duplicate preferences (by name attribute value)', function () {
- var testXml = et.XML(
+ const testXml = et.XML(
'<?xml version="1.0" encoding="UTF-8"?>\n' +
'<widget xmlns = "http://www.w3.org/ns/widgets"\n' +
' xmlns:cdv = "http://cordova.apache.org/ns/1.0"\n' +
@@ -475,12 +475,12 @@ describe('xml-helpers', function () {
'</widget>\n'
);
xml_helpers.mergeXml(testXml, dstXml, 'ios');
- var testElements = dstXml.findall('preference[@name="Orientation"]');
+ const testElements = dstXml.findall('preference[@name="Orientation"]');
expect(testElements.length).toEqual(1);
});
it('Test 043 : should merge preferences, with platform preferences written last', function () {
- var testXml = et.XML(
+ const testXml = et.XML(
'<?xml version="1.0" encoding="UTF-8"?>\n' +
'<widget xmlns = "http://www.w3.org/ns/widgets"\n' +
' xmlns:cdv = "http://cordova.apache.org/ns/1.0"\n' +
@@ -493,7 +493,7 @@ describe('xml-helpers', function () {
'</widget>\n'
);
xml_helpers.mergeXml(testXml, dstXml, 'ios');
- var testElements = dstXml.findall('preference[@name="Orientation"]');
+ const testElements = dstXml.findall('preference[@name="Orientation"]');
expect(testElements.length).toEqual(1);
expect(testElements[0].attrib.value).toEqual('all');
});
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org