You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by au...@apache.org on 2017/07/28 18:26:40 UTC
[09/18] cordova-lib git commit: CB-12895 : ran eslint --fix on
cordova-lib
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/cordova/platform/index.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova/platform/index.spec.js b/spec/cordova/platform/index.spec.js
index 546694d..5146902 100644
--- a/spec/cordova/platform/index.spec.js
+++ b/spec/cordova/platform/index.spec.js
@@ -14,8 +14,6 @@
specific language governing permissions and limitations
under the License.
*/
-// TODO: remove these once eslint lands
-/* eslint-env jasmine */
/* globals fail */
var rewire = require('rewire');
@@ -49,11 +47,11 @@ describe('cordova/platform', function () {
// targets = null
return platform('remove', null);
})
- .then(function () {
- fail('should not succeed without targets');
- }, function (err) {
- expect(err).toMatch(/You need to qualify.* with one or more platforms/gi);
- }).done(done);
+ .then(function () {
+ fail('should not succeed without targets');
+ }, function (err) {
+ expect(err).toMatch(/You need to qualify.* with one or more platforms/gi);
+ }).done(done);
});
});
describe('handling of targets parameter', function () {
@@ -64,119 +62,119 @@ describe('cordova/platform', function () {
it('should be able to handle an array of platform targets', function (done) {
var targets = ['nokia brick', 'HAM radio', 'nintendo wii'];
platform(cmd, targets)
- .then(function () {
- expect(platform[cmd]).toHaveBeenCalledWith(jasmine.any(Object), projectRoot, targets, jasmine.any(Object));
- }).fail(function (e) {
- expect(e).toBeUndefined();
- fail('did not expect fail handler to be invoked');
- }).done(done);
+ .then(function () {
+ expect(platform[cmd]).toHaveBeenCalledWith(jasmine.any(Object), projectRoot, targets, jasmine.any(Object));
+ }).fail(function (e) {
+ expect(e).toBeUndefined();
+ fail('did not expect fail handler to be invoked');
+ }).done(done);
});
it('should be able to handle a single platform target string', function (done) {
var target = 'motorola razr';
platform(cmd, target)
- .then(function () {
- expect(platform[cmd]).toHaveBeenCalledWith(jasmine.any(Object), projectRoot, [target], jasmine.any(Object));
- }).fail(function (e) {
- expect(e).toBeUndefined();
- fail('did not expect fail handler to be invoked');
- }).done(done);
+ .then(function () {
+ expect(platform[cmd]).toHaveBeenCalledWith(jasmine.any(Object), projectRoot, [target], jasmine.any(Object));
+ }).fail(function (e) {
+ expect(e).toBeUndefined();
+ fail('did not expect fail handler to be invoked');
+ }).done(done);
});
});
describe('happy path (success conditions)', function () {
it('should direct `add` commands to the `add` method/module', function (done) {
spyOn(platform, 'add').and.returnValue(true);
platform('add', ['android'])
- .then(function () {
- expect(platform.add).toHaveBeenCalled();
- }).fail(function (e) {
- expect(e).toBeUndefined();
- fail('did not expect fail handler to be invoked');
- }).done(done);
+ .then(function () {
+ expect(platform.add).toHaveBeenCalled();
+ }).fail(function (e) {
+ expect(e).toBeUndefined();
+ fail('did not expect fail handler to be invoked');
+ }).done(done);
});
it('should direct `remove` + `rm` commands to the `remove` method/module', function (done) {
spyOn(platform, 'remove').and.returnValue(true);
platform('remove', ['android'])
- .then(function () {
- expect(platform.remove).toHaveBeenCalled();
- }).fail(function (e) {
- expect(e).toBeUndefined();
- fail('did not expect fail handler to be invoked');
- }).then(function () {
- platform.remove.calls.reset(); // reset spy counter
- return platform('rm', ['android']);
- }).then(function () {
- expect(platform.remove).toHaveBeenCalled();
- }).fail(function (e) {
- expect(e).toBeUndefined();
- fail('did not expect fail handler to be invoked');
- }).done(done);
+ .then(function () {
+ expect(platform.remove).toHaveBeenCalled();
+ }).fail(function (e) {
+ expect(e).toBeUndefined();
+ fail('did not expect fail handler to be invoked');
+ }).then(function () {
+ platform.remove.calls.reset(); // reset spy counter
+ return platform('rm', ['android']);
+ }).then(function () {
+ expect(platform.remove).toHaveBeenCalled();
+ }).fail(function (e) {
+ expect(e).toBeUndefined();
+ fail('did not expect fail handler to be invoked');
+ }).done(done);
});
it('should direct `update` + `up` commands to the `update` method/module', function (done) {
spyOn(platform, 'update').and.returnValue(true);
platform('update', ['android'])
- .then(function () {
- expect(platform.update).toHaveBeenCalled();
- }).fail(function (e) {
- expect(e).toBeUndefined();
- fail('did not expect fail handler to be invoked');
- }).then(function () {
- platform.update.calls.reset(); // reset spy counter
- return platform('up', ['android']);
- }).then(function () {
- expect(platform.update).toHaveBeenCalled();
- }).fail(function (e) {
- expect(e).toBeUndefined();
- fail('did not expect fail handler to be invoked');
- }).done(done);
+ .then(function () {
+ expect(platform.update).toHaveBeenCalled();
+ }).fail(function (e) {
+ expect(e).toBeUndefined();
+ fail('did not expect fail handler to be invoked');
+ }).then(function () {
+ platform.update.calls.reset(); // reset spy counter
+ return platform('up', ['android']);
+ }).then(function () {
+ expect(platform.update).toHaveBeenCalled();
+ }).fail(function (e) {
+ expect(e).toBeUndefined();
+ fail('did not expect fail handler to be invoked');
+ }).done(done);
});
it('should direct `check` commands to the `check` method/module', function (done) {
spyOn(platform, 'check').and.returnValue(true);
platform('check', ['android'])
- .then(function () {
- expect(platform.check).toHaveBeenCalled();
- }).fail(function (e) {
- expect(e).toBeUndefined();
- fail('did not expect fail handler to be invoked');
- }).done(done);
+ .then(function () {
+ expect(platform.check).toHaveBeenCalled();
+ }).fail(function (e) {
+ expect(e).toBeUndefined();
+ fail('did not expect fail handler to be invoked');
+ }).done(done);
});
it('should direct `save` commands to the `save` method/module', function (done) {
spyOn(platform, 'save').and.returnValue(true);
platform('save', ['android'])
- .then(function () {
- expect(platform.save).toHaveBeenCalled();
- }).fail(function (e) {
- expect(e).toBeUndefined();
- fail('did not expect fail handler to be invoked');
- }).done(done);
+ .then(function () {
+ expect(platform.save).toHaveBeenCalled();
+ }).fail(function (e) {
+ expect(e).toBeUndefined();
+ fail('did not expect fail handler to be invoked');
+ }).done(done);
});
it('should direct `list`, all other commands and no command at all to the `list` method/module', function (done) {
spyOn(platform, 'list').and.returnValue(true);
// test the `list` command directly
platform('list')
- .then(function () {
- expect(platform.list).toHaveBeenCalled();
- }).fail(function (e) {
- expect(e).toBeUndefined();
- fail('did not expect fail handler to be invoked');
- }).then(function () {
- platform.list.calls.reset(); // reset spy counter
- // test the list catch-all
- return platform('please give me the list command');
- }).then(function () {
- expect(platform.list).toHaveBeenCalled();
- }).fail(function (e) {
- expect(e).toBeUndefined();
- fail('did not expect fail handler to be invoked');
- }).then(function () {
- platform.list.calls.reset(); // reset spy counter
- // test the lack of providing an argument.
- return platform();
- }).then(function () {
- expect(platform.list).toHaveBeenCalled();
- }).fail(function (e) {
- expect(e).toBeUndefined();
- fail('did not expect fail handler to be invoked');
- }).done(done);
+ .then(function () {
+ expect(platform.list).toHaveBeenCalled();
+ }).fail(function (e) {
+ expect(e).toBeUndefined();
+ fail('did not expect fail handler to be invoked');
+ }).then(function () {
+ platform.list.calls.reset(); // reset spy counter
+ // test the list catch-all
+ return platform('please give me the list command');
+ }).then(function () {
+ expect(platform.list).toHaveBeenCalled();
+ }).fail(function (e) {
+ expect(e).toBeUndefined();
+ fail('did not expect fail handler to be invoked');
+ }).then(function () {
+ platform.list.calls.reset(); // reset spy counter
+ // test the lack of providing an argument.
+ return platform();
+ }).then(function () {
+ expect(platform.list).toHaveBeenCalled();
+ }).fail(function (e) {
+ expect(e).toBeUndefined();
+ fail('did not expect fail handler to be invoked');
+ }).done(done);
});
});
});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/cordova/platforms/PlatformApiPoly.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova/platforms/PlatformApiPoly.spec.js b/spec/cordova/platforms/PlatformApiPoly.spec.js
index 23369b7..c15c17c 100644
--- a/spec/cordova/platforms/PlatformApiPoly.spec.js
+++ b/spec/cordova/platforms/PlatformApiPoly.spec.js
@@ -81,21 +81,21 @@ describe('PlatformApi polyfill', function () {
it('should be constructable', function () {
var api;
- expect(function(){api = new PlatformApiPoly(PLATFORM, PLATFORM_ROOT);}).not.toThrow();
+ expect(function () { api = new PlatformApiPoly(PLATFORM, PLATFORM_ROOT); }).not.toThrow();
expect(api).toEqual(jasmine.any(PlatformApiPoly));
});
-
+ /* eslint-disable no-unused-vars */
it('should fail when unknown platform is specified', function () {
var api;
- expect(function(){api = new PlatformApiPoly('fakePlatform', PLATFORM_ROOT);}).toThrow();
+ expect(function () { api = new PlatformApiPoly('fakePlatform', PLATFORM_ROOT); }).toThrow();
});
it('should fail when mandatory argument is not specified', function () {
var api;
- expect(function(){api = new PlatformApiPoly(PLATFORM);}).toThrow();
- expect(function(){api = new PlatformApiPoly(null, PLATFORM_ROOT);}).toThrow();
+ expect(function () { api = new PlatformApiPoly(PLATFORM); }).toThrow();
+ expect(function () { api = new PlatformApiPoly(null, PLATFORM_ROOT); }).toThrow();
});
-
+ /* eslint-enable no-unused-vars */
it('should have fields defined', function () {
expect(platformApi.platform).toBe(PLATFORM);
expect(platformApi.root).toBe(PLATFORM_ROOT);
@@ -114,7 +114,12 @@ describe('PlatformApi polyfill', function () {
describe('methods:', function () {
- var FAKE_PROJECT, FAKE_CONFIG, OPTIONS, getPlatformApi, fail, success;
+ var FAKE_PROJECT;
+ var FAKE_CONFIG;
+ var OPTIONS;
+ var getPlatformApi; // eslint-disable-line no-unused-vars
+ var fail;
+ var success;
beforeEach(function () {
getPlatformApi = spyOn(knownPlatforms, 'getPlatformApi').and.returnValue(platformApi);
@@ -141,54 +146,54 @@ describe('PlatformApi polyfill', function () {
it('should create/update platform through running platforms\' scripts', function (done) {
Q.all([PlatformApiPoly.createPlatform(PLATFORM_ROOT, FAKE_CONFIG, OPTIONS),
- PlatformApiPoly.updatePlatform(PLATFORM_ROOT, OPTIONS)])
- .then(function () {
- expect(spawn).toHaveBeenCalled();
- expect(spawn.calls.count()).toBe(2);
- }).fail(function (err) {
- expect(err).not.toBeDefined();
- }).fin(done);
+ PlatformApiPoly.updatePlatform(PLATFORM_ROOT, OPTIONS)])
+ .then(function () {
+ expect(spawn).toHaveBeenCalled();
+ expect(spawn.calls.count()).toBe(2);
+ }).fail(function (err) {
+ expect(err).not.toBeDefined();
+ }).fin(done);
});
it('should pass down arguments to platforms\' scripts', function (done) {
Q.all([PlatformApiPoly.createPlatform(PLATFORM_ROOT, FAKE_CONFIG, OPTIONS),
- PlatformApiPoly.updatePlatform(PLATFORM_ROOT, OPTIONS)])
- .then(function () {
- expect(spawn).toHaveBeenCalled();
- expect(spawn.calls.count()).toBe(2);
- expect(spawn.calls.argsFor(0)[0]).toBe(path.join(PLATFORM_LIB, 'bin/create'));
- expect(spawn.calls.argsFor(0)[1]).toContain(PLATFORM_ROOT);
- expect(spawn.calls.argsFor(1)[0]).toBe(path.join(PLATFORM_LIB, 'bin/update'));
- expect(spawn.calls.argsFor(1)[1]).toContain(PLATFORM_ROOT);
- }).fail(function (err) {
- expect(err).not.toBeDefined();
- }).fin(done);
+ PlatformApiPoly.updatePlatform(PLATFORM_ROOT, OPTIONS)])
+ .then(function () {
+ expect(spawn).toHaveBeenCalled();
+ expect(spawn.calls.count()).toBe(2);
+ expect(spawn.calls.argsFor(0)[0]).toBe(path.join(PLATFORM_LIB, 'bin/create'));
+ expect(spawn.calls.argsFor(0)[1]).toContain(PLATFORM_ROOT);
+ expect(spawn.calls.argsFor(1)[0]).toBe(path.join(PLATFORM_LIB, 'bin/update'));
+ expect(spawn.calls.argsFor(1)[1]).toContain(PLATFORM_ROOT);
+ }).fail(function (err) {
+ expect(err).not.toBeDefined();
+ }).fin(done);
});
it('should copy cordova JS sources into created platform', function (done) {
Q.all([PlatformApiPoly.createPlatform(PLATFORM_ROOT, FAKE_CONFIG, OPTIONS),
- PlatformApiPoly.updatePlatform(PLATFORM_ROOT, OPTIONS)])
- .then(function () {
- expect(shell.cp).toHaveBeenCalled();
- expect(shell.cp.calls.count()).toBe(2);
- }).fail(fail)
- .fin(function () {
- expect(fail).not.toHaveBeenCalled();
- done();
- });
+ PlatformApiPoly.updatePlatform(PLATFORM_ROOT, OPTIONS)])
+ .then(function () {
+ expect(shell.cp).toHaveBeenCalled();
+ expect(shell.cp.calls.count()).toBe(2);
+ }).fail(fail)
+ .fin(function () {
+ expect(fail).not.toHaveBeenCalled();
+ done();
+ });
});
it('should fail immediately if options.platformInfo is not specified', function (done) {
Q.all([PlatformApiPoly.createPlatform(PLATFORM_ROOT, FAKE_CONFIG),
- PlatformApiPoly.updatePlatform(PLATFORM_ROOT, FAKE_CONFIG)])
- .then(success)
- .fail(fail)
- .fin(function function_name (argument) {
- expect(success).not.toHaveBeenCalled();
- expect(fail).toHaveBeenCalled();
- expect(spawn).not.toHaveBeenCalled();
- done();
- });
+ PlatformApiPoly.updatePlatform(PLATFORM_ROOT, FAKE_CONFIG)])
+ .then(success)
+ .fail(fail)
+ .fin(function function_name (argument) {
+ expect(success).not.toHaveBeenCalled();
+ expect(fail).toHaveBeenCalled();
+ expect(spawn).not.toHaveBeenCalled();
+ done();
+ });
});
});
@@ -206,17 +211,17 @@ describe('PlatformApi polyfill', function () {
it('should call parser\'s corresponding methods', function (done) {
platformApi.prepare(FAKE_PROJECT, OPTIONS)
- .then(function () {
- [platformApi._parser.update_www, platformApi._parser.update_project]
- .forEach(function (method) {
- expect(method).toHaveBeenCalled();
+ .then(function () {
+ [platformApi._parser.update_www, platformApi._parser.update_project]
+ .forEach(function (method) {
+ expect(method).toHaveBeenCalled();
+ });
+ })
+ .fail(fail)
+ .fin(function () {
+ expect(fail).not.toHaveBeenCalled();
+ done();
});
- })
- .fail(fail)
- .fin(function () {
- expect(fail).not.toHaveBeenCalled();
- done();
- });
});
});
@@ -236,25 +241,25 @@ describe('PlatformApi polyfill', function () {
it('should fail if plugin parameter is not specified', function (done) {
platformApi.addPlugin()
- .then(success)
- .fail(fail)
- .fin(function () {
- expect(success).not.toHaveBeenCalled();
- expect(fail).toHaveBeenCalled();
- done();
- });
+ .then(success)
+ .fail(fail)
+ .fin(function () {
+ expect(success).not.toHaveBeenCalled();
+ expect(fail).toHaveBeenCalled();
+ done();
+ });
});
it('should process all plugin files through action stack', function (done) {
platformApi.addPlugin(plugin)
- .then(success)
- .fail(fail)
- .fin(function () {
- expect(actionsProcess).toHaveBeenCalled();
- expect(success).toHaveBeenCalled();
- expect(fail).not.toHaveBeenCalled();
- done();
- });
+ .then(success)
+ .fail(fail)
+ .fin(function () {
+ expect(actionsProcess).toHaveBeenCalled();
+ expect(success).toHaveBeenCalled();
+ expect(fail).not.toHaveBeenCalled();
+ done();
+ });
});
});
@@ -267,9 +272,9 @@ describe('PlatformApi polyfill', function () {
it('should return promise', function (done) {
var ops = [
- platformApi.build(/*opts*/),
- platformApi.run(/*opts*/),
- platformApi.clean(/*opts*/),
+ platformApi.build(/* opts */),
+ platformApi.run(/* opts */),
+ platformApi.clean(/* opts */),
platformApi.requirements()
];
@@ -281,16 +286,16 @@ describe('PlatformApi polyfill', function () {
it('should do their job through running platforms\' scripts', function (done) {
var ops = [
- platformApi.build(/*opts*/),
- platformApi.run(/*opts*/),
- platformApi.clean(/*opts*/)
+ platformApi.build(/* opts */),
+ platformApi.run(/* opts */),
+ platformApi.clean(/* opts */)
];
Q.all(ops)
- .then(function () {
- expect(spawnSpy).toHaveBeenCalled();
- expect(spawnSpy.calls.count()).toEqual(3);
- }).fin(done);
+ .then(function () {
+ expect(spawnSpy).toHaveBeenCalled();
+ expect(spawnSpy.calls.count()).toEqual(3);
+ }).fin(done);
});
it('should convert and pass down options to platforms\' scripts', function (done) {
@@ -304,12 +309,12 @@ describe('PlatformApi polyfill', function () {
};
spawnSpy.and.returnValue(Q());
platformApi.build(options)
- .then(function () {
- ['--release', '--nobuild', '--device', '--target=' + options.target, '--archs=arm,x86', '--buildConfig=' +options.buildConfig]
- .forEach(function (arg) {
- expect(spawnSpy.calls[0].args[1]).toContain(arg);
- });
- }).fin(done);
+ .then(function () {
+ ['--release', '--nobuild', '--device', '--target=' + options.target, '--archs=arm,x86', '--buildConfig=' + options.buildConfig]
+ .forEach(function (arg) {
+ expect(spawnSpy.calls[0].args[1]).toContain(arg);
+ });
+ }).fin(done);
});
});
});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/cordova/platforms/platforms.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova/platforms/platforms.spec.js b/spec/cordova/platforms/platforms.spec.js
index 1918446..b57ff2d 100644
--- a/spec/cordova/platforms/platforms.spec.js
+++ b/spec/cordova/platforms/platforms.spec.js
@@ -62,8 +62,8 @@ describe('getPlatformApi method', function () {
it('should return PlatformApi polyfill if PlatformApi is not defined by platform', function () {
spyOn(browserParser, 'dirExists').and.returnValue(true);
- spyOn(fs, 'existsSync').and.callFake(function(somePath) {
- if(somePath === 'PLATFORM_WOUT_API') {
+ spyOn(fs, 'existsSync').and.callFake(function (somePath) {
+ if (somePath === 'PLATFORM_WOUT_API') {
return true;
}
return false;
@@ -83,7 +83,7 @@ describe('getPlatformApi method', function () {
it('should throw error if using deprecated platform', function () {
try {
platforms.getPlatformApi('android', path.join(CORDOVA_ROOT, 'platforms/android'));
- } catch(error) {
+ } catch (error) {
expect(error.toString()).toContain('platform does not have Api.js');
}
});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/cordova/plugin/search.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova/plugin/search.spec.js b/spec/cordova/plugin/search.spec.js
index 32c9eeb..33e4d48 100644
--- a/spec/cordova/plugin/search.spec.js
+++ b/spec/cordova/plugin/search.spec.js
@@ -16,8 +16,6 @@
specific language governing permissions and limitations
under the License.
*/
-// TODO: remove once eslint lands
-/* eslint-env jasmine */
/* globals fail */
var Q = require('q');
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/cordova/prepare.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova/prepare.spec.js b/spec/cordova/prepare.spec.js
index 1afe882..1467587 100644
--- a/spec/cordova/prepare.spec.js
+++ b/spec/cordova/prepare.spec.js
@@ -67,14 +67,14 @@ describe('cordova/prepare', function () {
spyOn(util, 'cdProjectRoot').and.returnValue(project_dir);
spyOn(util, 'preProcessOptions').and.callFake(function (options) {
var platforms = options.platforms || [];
- return {'platforms':platforms};
+ return {'platforms': platforms};
});
spyOn(prepare, 'preparePlatforms').and.returnValue(Q);
});
describe('failure', function () {
it('should invoke util.preProcessOptions as preflight task checker, which, if fails, should trigger promise rejection and only fire the before_prepare hook', function (done) {
util.preProcessOptions.and.callFake(function () {
- throw new Error('preProcessOption error');
+ throw new Error('preProcessOption error');
});
prepare({}).then(function () {
fail('unexpected failure handler invoked');
@@ -87,7 +87,7 @@ describe('cordova/prepare', function () {
util.cdProjectRoot.and.callFake(function () {
throw new Error('cdProjectRoot error');
});
- prepare({}).then(function () {
+ prepare({}).then(function () {
fail('unexpected failure handler invoked');
}).fail(function (e) {
expect(e.message).toBe('cdProjectRoot error');
@@ -114,11 +114,11 @@ describe('cordova/prepare', function () {
}).done(done);
});
it('should retrieve PlatformApi instances for each platform provided', function (done) {
- prepare({'platforms':['android', 'ios']}).then(function () {
+ prepare({'platforms': ['android', 'ios']}).then(function () {
expect(platforms.getPlatformApi).toHaveBeenCalledTimes(4);
- //expect(platforms.getPlatformApi).toHaveBeenCalledWith(['android', path.join('some','path','platforms','android')], ['ios', path.join('some','path','platforms','ios')], ['android'], ['ios']);
- expect(platforms.getPlatformApi).toHaveBeenCalledWith('android', path.join('/','some','path','platforms','android'));
- expect(platforms.getPlatformApi).toHaveBeenCalledWith('ios', path.join('/','some','path','platforms','ios'));
+ // expect(platforms.getPlatformApi).toHaveBeenCalledWith(['android', path.join('some','path','platforms','android')], ['ios', path.join('some','path','platforms','ios')], ['android'], ['ios']);
+ expect(platforms.getPlatformApi).toHaveBeenCalledWith('android', path.join('/', 'some', 'path', 'platforms', 'android'));
+ expect(platforms.getPlatformApi).toHaveBeenCalledWith('ios', path.join('/', 'some', 'path', 'platforms', 'ios'));
expect(platforms.getPlatformApi).toHaveBeenCalledWith('android');
expect(platforms.getPlatformApi).toHaveBeenCalledWith('ios');
}).fail(function (e) {
@@ -127,7 +127,7 @@ describe('cordova/prepare', function () {
}).done(done);
});
it('should invoke restore module\'s installPluginsFromConfigXML method', function (done) {
- prepare({platforms:[]}).then(function () {
+ prepare({platforms: []}).then(function () {
expect(restore.installPluginsFromConfigXML).toHaveBeenCalled();
}).fail(function (e) {
fail('unexpected failure handler invoked');
@@ -135,8 +135,8 @@ describe('cordova/prepare', function () {
}).done(done);
});
it('should invoke preparePlatforms method, providing the appropriate platforms', function (done) {
- prepare({platforms:['android']}).then(function () {
- expect(prepare.preparePlatforms).toHaveBeenCalledWith(['android'],'/some/path', jasmine.any(Object));
+ prepare({platforms: ['android']}).then(function () {
+ expect(prepare.preparePlatforms).toHaveBeenCalledWith(['android'], '/some/path', jasmine.any(Object));
}).fail(function (e) {
fail('unexpected failure handler invoked');
console.error(e);
@@ -144,7 +144,7 @@ describe('cordova/prepare', function () {
});
it('should fire the after_prepare hook and provide platform and path information as arguments', function (done) {
- prepare({platforms:['android']}).then(function () {
+ prepare({platforms: ['android']}).then(function () {
expect(HooksRunner.prototype.fire).toHaveBeenCalledWith('after_prepare', jasmine.any(Object));
}).fail(function (e) {
fail('unexpected failure handler invoked');
@@ -171,48 +171,48 @@ describe('cordova/prepare', function () {
platform_munger_revert_mock = prepare.__set__('PlatformMunger', platform_munger_mock);
spyOn(util, 'projectConfig').and.returnValue(project_dir);
spyOn(util, 'projectWww').and.returnValue(path.join(project_dir, 'www'));
-
+
});
afterEach(function () {
cfg_parser_revert_mock();
platform_munger_revert_mock();
});
it('should call restoreMissingPluginsForPlatform', function (done) {
- prepare.preparePlatforms(['android'],project_dir, {}).then(function () {
+ prepare.preparePlatforms(['android'], project_dir, {}).then(function () {
expect(prepare.restoreMissingPluginsForPlatform).toHaveBeenCalled();
}).fail(function (e) {
fail('unexpected failure handler invoked');
console.error(e);
- }).done(done);
+ }).done(done);
});
it('should retrieve the platform API via getPlatformApi per platform provided, and invoke the prepare method from that API', function (done) {
- prepare.preparePlatforms(['android'],project_dir, {}).then(function () {
+ prepare.preparePlatforms(['android'], project_dir, {}).then(function () {
expect(platforms.getPlatformApi).toHaveBeenCalledWith('android');
expect(platform_api_prepare_mock).toHaveBeenCalled();
}).fail(function (e) {
fail('unexpected failure handler invoked');
console.error(e);
- }).done(done);
+ }).done(done);
});
it('should fire a pre_package hook for the windows', function (done) {
- prepare.preparePlatforms(['windows'],project_dir, {}).then(function () {
+ prepare.preparePlatforms(['windows'], project_dir, {}).then(function () {
expect(HooksRunner.prototype.fire).toHaveBeenCalledWith('pre_package', jasmine.any(Object));
}).fail(function (e) {
fail('unexpected failure handler invoked');
console.error(e);
- }).done(done);
+ }).done(done);
});
// TODO: xit'ed the one below as dynamic requires make it difficult to spy on
// Can we refactor the relevant code to make it testable?
xit('should invoke browserify if the browserify option is provided');
it('should handle config changes by invoking add_config_changes and save_all', function (done) {
- prepare.preparePlatforms(['android'],project_dir, {}).then(function () {
+ prepare.preparePlatforms(['android'], project_dir, {}).then(function () {
expect(platform_munger_mock.prototype.add_config_changes).toHaveBeenCalled();
expect(platform_munger_save_mock).toHaveBeenCalled();
}).fail(function (e) {
fail('unexpected failure handler invoked');
console.error(e);
- }).done(done);
+ }).done(done);
});
});
@@ -237,14 +237,14 @@ describe('cordova/prepare', function () {
}).fail(function (e) {
fail('unexpected failure handler invoked');
console.error(e);
- }).done(done);
+ }).done(done);
});
it('should leverage platform API to remove and add any missing plugins identified', function (done) {
is_plugin_installed_mock = jasmine.createSpy('is plugin installed mock');
is_plugin_provider_get_mock = jasmine.createSpy('is plugin provider get mock');
// mock platform json value below
PlatformJson.load.and.callFake(function (platformJsonPath, plat) {
- //set different installed plugins to simulate missing plugins
+ // set different installed plugins to simulate missing plugins
var missingPlugins;
if (platformJsonPath === '/some/path/platforms/android') {
missingPlugins = {'cordova-plugin-device': {}};
@@ -270,7 +270,7 @@ describe('cordova/prepare', function () {
}).fail(function (e) {
fail('unexpected failure handler invoked');
console.error(e);
- }).done(done);
+ }).done(done);
});
});
});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/cordova/project-metadata-apis.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova/project-metadata-apis.spec.js b/spec/cordova/project-metadata-apis.spec.js
index 80314b1..45b7d75 100644
--- a/spec/cordova/project-metadata-apis.spec.js
+++ b/spec/cordova/project-metadata-apis.spec.js
@@ -17,8 +17,8 @@
under the License.
*/
-var cordova = require('../../src/cordova/cordova'),
- path = require('path');
+var cordova = require('../../src/cordova/cordova');
+var path = require('path');
describe('retrieval of project metadata', function () {
var projectRoot = path.resolve(__dirname, 'Projects/ProjectMetadata');
@@ -98,7 +98,7 @@ describe('retrieval of project metadata', function () {
});
});
-function findPlatform(platforms, platformName) {
+function findPlatform (platforms, platformName) {
for (var i = 0; i < platforms.length; i++) {
if (platforms[i].name === platformName) {
return platforms[i];
@@ -107,7 +107,7 @@ function findPlatform(platforms, platformName) {
return null;
}
-function findPlugin(plugins, pluginId) {
+function findPlugin (plugins, pluginId) {
for (var i = 0; i < plugins.length; i++) {
if (plugins[i].name === pluginId) {
return plugins[i];
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/cordova/run.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova/run.spec.js b/spec/cordova/run.spec.js
index 01c3536..a19540e 100644
--- a/spec/cordova/run.spec.js
+++ b/spec/cordova/run.spec.js
@@ -16,20 +16,20 @@
specific language governing permissions and limitations
under the License.
*/
-var cordova = require('../../src/cordova/cordova'),
- platforms = require('../../src/platforms/platforms'),
- HooksRunner = require('../../src/hooks/HooksRunner'),
- Q = require('q'),
- util = require('../../src/cordova/util');
+var cordova = require('../../src/cordova/cordova');
+var platforms = require('../../src/platforms/platforms');
+var HooksRunner = require('../../src/hooks/HooksRunner');
+var Q = require('q');
+var util = require('../../src/cordova/util');
-var supported_platforms = Object.keys(platforms).filter(function(p) { return p != 'www'; });
+var supported_platforms = Object.keys(platforms).filter(function (p) { return p !== 'www'; });
-describe('run command', function() {
+describe('run command', function () {
var is_cordova, cd_project_root, list_platforms, fire, platformApi, getPlatformApi;
var project_dir = '/some/path';
var prepare_spy;
- beforeEach(function() {
+ beforeEach(function () {
is_cordova = spyOn(util, 'isCordova').and.returnValue(project_dir);
cd_project_root = spyOn(util, 'cdProjectRoot').and.returnValue(project_dir);
list_platforms = spyOn(util, 'listPlatforms').and.returnValue(supported_platforms);
@@ -41,145 +41,146 @@ describe('run command', function() {
};
getPlatformApi = spyOn(platforms, 'getPlatformApi').and.returnValue(platformApi);
});
- describe('failure', function() {
- it('Test 001 : should not run inside a Cordova-based project with no added platforms by calling util.listPlatforms', function(done) {
+ describe('failure', function () {
+ it('Test 001 : should not run inside a Cordova-based project with no added platforms by calling util.listPlatforms', function (done) {
list_platforms.and.returnValue([]);
- Q().then(cordova.run).then(function() {
+ Q().then(cordova.run).then(function () {
expect('this call').toBe('fail');
- }, function(err) {
+ }, function (err) {
expect(err.message).toEqual('No platforms added to this project. Please use `cordova platform add <platform>`.');
}).fin(done);
});
- it('Test 002 : should not run outside of a Cordova-based project', function(done) {
+ it('Test 002 : should not run outside of a Cordova-based project', function (done) {
var msg = 'Dummy message about not being in a cordova dir.';
cd_project_root.and.throwError(new Error(msg));
is_cordova.and.returnValue(false);
- Q().then(cordova.run).then(function() {
+ Q().then(cordova.run).then(function () {
expect('this call').toBe('fail');
- }, function(err) {
+ }, function (err) {
expect(err.message).toEqual(msg);
}).fin(done);
});
});
- describe('success', function() {
- it('Test 003 : should call prepare before actually run platform ', function(done) {
- cordova.run(['android','ios']).then(function() {
+ describe('success', function () {
+ it('Test 003 : should call prepare before actually run platform ', function (done) {
+ cordova.run(['android', 'ios']).then(function () {
expect(prepare_spy.calls.argsFor(0)).toEqual([ { platforms: [ 'android', 'ios' ], verbose: false, options: {} } ]);
- }, function(err) {
+ }, function (err) {
expect(err).toBeUndefined();
}).fin(done);
});
- it('Test 004 : should get PlatformApi instance for each platform and call its\' run method', function(done) {
- cordova.run(['android','ios']).then(function() {
+ it('Test 004 : should get PlatformApi instance for each platform and call its\' run method', function (done) {
+ cordova.run(['android', 'ios']).then(function () {
expect(getPlatformApi).toHaveBeenCalledWith('android');
expect(getPlatformApi).toHaveBeenCalledWith('ios');
expect(platformApi.build).toHaveBeenCalled();
expect(platformApi.run).toHaveBeenCalled();
- }, function(err) {
+ }, function (err) {
expect(err).toBeUndefined();
}).fin(done);
});
- it('Test 005 : should pass down parameters', function(done) {
- cordova.run({platforms: ['blackberry10'], options:{password: '1q1q'}}).then(function() {
+ it('Test 005 : should pass down parameters', function (done) {
+ cordova.run({platforms: ['blackberry10'], options: {password: '1q1q'}}).then(function () {
expect(prepare_spy).toHaveBeenCalledWith({ platforms: [ 'blackberry10' ], options: { password: '1q1q' }, verbose: false });
expect(platformApi.build).toHaveBeenCalledWith({password: '1q1q'});
expect(platformApi.run).toHaveBeenCalledWith({password: '1q1q', nobuild: true});
- }, function(err) {
+ }, function (err) {
expect(err).toBeUndefined();
}).fin(done);
});
it('Test 006 : should convert parameters from old format and warn user about this', function (done) {
- function warnSpy(message) {
+ function warnSpy (message) {
expect(message).toMatch('The format of cordova.* methods "options" argument was changed');
}
cordova.on('warn', warnSpy);
- cordova.run({platforms: ['blackberry10'], options:['--password=1q1q']}).then(function() {
+ cordova.run({platforms: ['blackberry10'], options: ['--password=1q1q']}).then(function () {
expect(prepare_spy).toHaveBeenCalledWith({ platforms: [ 'blackberry10' ],
- options: jasmine.objectContaining({argv:['--password=1q1q']}), verbose: false });
- expect(platformApi.run).toHaveBeenCalledWith(jasmine.objectContaining({argv:['--password=1q1q']}));
- }, function(err) {
+ options: jasmine.objectContaining({argv: ['--password=1q1q']}),
+ verbose: false });
+ expect(platformApi.run).toHaveBeenCalledWith(jasmine.objectContaining({argv: ['--password=1q1q']}));
+ }, function (err) {
expect(err).toBeUndefined();
})
- .fin(function () {
- cordova.off('warn', warnSpy);
- done();
- });
+ .fin(function () {
+ cordova.off('warn', warnSpy);
+ done();
+ });
});
it('Test 007 : should call platform\'s build method', function (done) {
cordova.run({platforms: ['blackberry10']})
- .then(function() {
- expect(prepare_spy).toHaveBeenCalled();
- expect(platformApi.build).toHaveBeenCalledWith({});
- expect(platformApi.run).toHaveBeenCalledWith(jasmine.objectContaining({nobuild: true}));
- }, function(err) {
- expect(err).toBeUndefined();
- })
- .fin(done);
+ .then(function () {
+ expect(prepare_spy).toHaveBeenCalled();
+ expect(platformApi.build).toHaveBeenCalledWith({});
+ expect(platformApi.run).toHaveBeenCalledWith(jasmine.objectContaining({nobuild: true}));
+ }, function (err) {
+ expect(err).toBeUndefined();
+ })
+ .fin(done);
});
it('Test 008 : should not call build if --nobuild option is passed', function (done) {
cordova.run({platforms: ['blackberry10'], options: { nobuild: true }})
- .then(function() {
- expect(prepare_spy).toHaveBeenCalled();
- expect(platformApi.build).not.toHaveBeenCalled();
- expect(platformApi.run).toHaveBeenCalledWith(jasmine.objectContaining({nobuild: true}));
- }, function(err) {
- expect(err).toBeUndefined();
- })
- .fin(done);
+ .then(function () {
+ expect(prepare_spy).toHaveBeenCalled();
+ expect(platformApi.build).not.toHaveBeenCalled();
+ expect(platformApi.run).toHaveBeenCalledWith(jasmine.objectContaining({nobuild: true}));
+ }, function (err) {
+ expect(err).toBeUndefined();
+ })
+ .fin(done);
});
- describe('run parameters should not be altered by intermediate build command', function() {
+ describe('run parameters should not be altered by intermediate build command', function () {
var originalBuildSpy;
- beforeEach(function() {
+ beforeEach(function () {
originalBuildSpy = platformApi.build;
- platformApi.build = jasmine.createSpy('build').and.callFake(function(opts) {
+ platformApi.build = jasmine.createSpy('build').and.callFake(function (opts) {
opts.couldBeModified = 'insideBuild';
return Q();
});
});
- afterEach(function() {
+ afterEach(function () {
platformApi.build = originalBuildSpy;
});
- it('Test 009 : should leave parameters unchanged', function(done) {
- cordova.run({platforms: ['blackberry10'], options:{password: '1q1q'}}).then(function() {
+ it('Test 009 : should leave parameters unchanged', function (done) {
+ cordova.run({platforms: ['blackberry10'], options: {password: '1q1q'}}).then(function () {
expect(prepare_spy).toHaveBeenCalledWith({ platforms: [ 'blackberry10' ], options: { password: '1q1q', 'couldBeModified': 'insideBuild' }, verbose: false });
expect(platformApi.build).toHaveBeenCalledWith({password: '1q1q', 'couldBeModified': 'insideBuild'});
expect(platformApi.run).toHaveBeenCalledWith({password: '1q1q', nobuild: true});
- }, function(err) {
+ }, function (err) {
expect(err).toBeUndefined();
}).fin(done);
});
});
});
- describe('hooks', function() {
- describe('when platforms are added', function() {
- it('Test 010 : should fire before hooks through the hooker module', function(done) {
- cordova.run(['android', 'ios']).then(function() {
+ describe('hooks', function () {
+ describe('when platforms are added', function () {
+ it('Test 010 : should fire before hooks through the hooker module', function (done) {
+ cordova.run(['android', 'ios']).then(function () {
expect(fire.calls.argsFor(0)).toEqual([ 'before_run', { platforms: [ 'android', 'ios' ], verbose: false, options: {} } ]);
- }, function(err) {
+ }, function (err) {
expect(err).toBeUndefined();
}).fin(done);
});
- it('Test 011 : should fire after hooks through the hooker module', function(done) {
- cordova.run('android').then(function() {
+ it('Test 011 : should fire after hooks through the hooker module', function (done) {
+ cordova.run('android').then(function () {
expect(fire.calls.argsFor(2)).toEqual([ 'after_run', { platforms: [ 'android' ], verbose: false, options: {} } ]);
- }, function(err) {
+ }, function (err) {
expect(err).toBeUndefined();
}).fin(done);
});
});
- describe('with no platforms added', function() {
- it('Test 012 : should not fire the hooker', function(done) {
+ describe('with no platforms added', function () {
+ it('Test 012 : should not fire the hooker', function (done) {
list_platforms.and.returnValue([]);
- Q().then(cordova.run).then(function() {
+ Q().then(cordova.run).then(function () {
expect('this call').toBe('fail');
- }, function(err) {
+ }, function (err) {
expect(fire).not.toHaveBeenCalled();
expect(err.message).toEqual('No platforms added to this project. Please use `cordova platform add <platform>`.');
}).fin(done);
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/cordova/serve.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova/serve.spec.js b/spec/cordova/serve.spec.js
index 45165b0..45d6dd6 100644
--- a/spec/cordova/serve.spec.js
+++ b/spec/cordova/serve.spec.js
@@ -17,81 +17,81 @@
under the License.
*/
-/* jshint expr: true */
/* global xdescribe */
-var cordova = require('../../src/cordova/cordova'),
- console = require('console'),
- path = require('path'),
- shell = require('shelljs'),
- fs = require('fs'),
- Q = require('q'),
- tempDir,
- http = require('http');
+var cordova = require('../../src/cordova/cordova');
+var console = require('console');
+var path = require('path');
+var shell = require('shelljs');
+var fs = require('fs');
+var Q = require('q');
+var tempDir;
+var http = require('http');
var cwd = process.cwd();
-//skipped because of CB-7078
-xdescribe('serve command', function() {
- var payloads = {},
- consoleSpy;
- beforeEach(function() {
+// skipped because of CB-7078
+xdescribe('serve command', function () {
+ var payloads = {};
+ var consoleSpy; // eslint-disable-line no-unused-vars
+ beforeEach(function () {
// Make a temp directory
tempDir = path.join(__dirname, '..', 'temp-' + Date.now());
shell.rm('-rf', tempDir);
shell.mkdir('-p', tempDir);
consoleSpy = spyOn(console, 'log');
});
- afterEach(function() {
+ afterEach(function () {
process.chdir(cwd);
process.env.PWD = cwd;
shell.rm('-rf', tempDir);
});
- it('Test 001 : should not run outside of a Cordova-based project', function() {
+ it('Test 001 : should not run outside of a Cordova-based project', function () {
process.chdir(tempDir);
- expect(function() {
- cordova.serve().then(function(server) {
+ expect(function () {
+ cordova.serve().then(function (server) {
expect(server).toBe(null);
server.close();
});
}).toThrow('Current working directory is not a Cordova-based project.');
});
- describe('`serve`', function() {
- var done = false, failed = false;
- beforeEach(function() {
+ describe('`serve`', function () {
+ var done = false; // eslint-disable-line no-unused-vars
+ var failed = false;
+ beforeEach(function () {
done = false;
failed = false;
});
- afterEach(function() {
+ afterEach(function () {
payloads = {};
});
- function cit(cond) {
+ function cit (cond) {
if (cond) {
return it;
}
return xit;
}
- function itifapps(apps) {
- return cit(apps.every(function (bin) {return shell.which(bin);}));
+ function itifapps (apps) {
+ return cit(apps.every(function (bin) { return shell.which(bin); }));
}
- function test_serve(platform, ref, expectedContents, opts) {
- var timeout = opts && 'timeout' in opts && opts.timeout || 1000;
- return function() {
+ function test_serve (platform, ref, expectedContents, opts) {
+ var timeout = (opts && 'timeout' in opts && opts.timeout) || (1000);
+ return function () {
var server;
- runs(function() {
+ runs(function () {
cordova.create(tempDir).then(function () {
process.chdir(tempDir);
process.env.PWD = tempDir;
var plats = [];
- Object.getOwnPropertyNames(payloads).forEach(function(plat) {
+ Object.getOwnPropertyNames(payloads).forEach(function (plat) {
var d = Q.defer();
plats.push(d.promise);
- cordova.platform('add', plat, {spawnoutput:'ignore'}).then(function () {
+ cordova.platform('add', plat, {spawnoutput: 'ignore'}).then(function () {
var dir = path.join(tempDir, 'merges', plat);
shell.mkdir('-p', dir);
// Write testing HTML files into the directory.
@@ -117,12 +117,12 @@ xdescribe('serve command', function() {
});
});
- waitsFor(function() {
+ waitsFor(function () {
return server || failed;
}, 'the server should start', timeout);
var done, errorCB;
- runs(function() {
+ runs(function () {
if (failed) {
return;
}
@@ -133,12 +133,12 @@ xdescribe('serve command', function() {
port: opts && 'port' in opts ? opts.port : 8000,
path: '/' + platform + '/www' + ref,
connection: 'Close'
- }).on('response', function(res) {
+ }).on('response', function (res) {
var response = '';
- res.on('data', function(data) {
+ res.on('data', function (data) {
response += data;
});
- res.on('end', function() {
+ res.on('end', function () {
expect(response).toEqual(expectedContents);
if (response === expectedContents) {
expect(res.statusCode).toEqual(200);
@@ -148,11 +148,11 @@ xdescribe('serve command', function() {
}).on('error', errorCB);
});
- waitsFor(function() {
+ waitsFor(function () {
return done || failed;
}, 'the HTTP request should complete', timeout);
- runs(function() {
+ runs(function () {
if (!failed) {
expect(done).toBeTruthy();
expect(errorCB).not.toHaveBeenCalled();
@@ -165,8 +165,8 @@ xdescribe('serve command', function() {
itifapps([
'android',
- 'ant',
- ])('should fall back to assets/www on Android', function() {
+ 'ant'
+ ])('should fall back to assets/www on Android', function () {
payloads.android = 'This is the Android test file.';
test_serve('android', '/test.html', payloads.android, {timeout: 20000})();
});
@@ -175,18 +175,17 @@ xdescribe('serve command', function() {
'blackberry-nativepackager',
'blackberry-deploy',
'blackberry-signer',
- 'blackberry-debugtokenrequest',
- ])('should fall back to www on BlackBerry10', function() {
+ 'blackberry-debugtokenrequest'
+ ])('should fall back to www on BlackBerry10', function () {
payloads.blackberry10 = 'This is the BlackBerry10 test file.';
test_serve('blackberry10', '/test.html', payloads.blackberry10, {timeout: 10000})();
});
itifapps([
- 'xcodebuild',
- ])('should fall back to www on iOS', function() {
+ 'xcodebuild'
+ ])('should fall back to www on iOS', function () {
payloads.ios = 'This is the iOS test file.';
test_serve('ios', '/test.html', payloads.ios, {timeout: 10000})();
});
});
});
-
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/cordova/util.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova/util.spec.js b/spec/cordova/util.spec.js
index a66f04a..6c63421 100644
--- a/spec/cordova/util.spec.js
+++ b/spec/cordova/util.spec.js
@@ -17,50 +17,48 @@
under the License.
*/
-/* jshint sub: true */
-
-var shell = require('shelljs'),
- path = require('path'),
- fs = require('fs'),
- util = require('../../src/cordova/util'),
- events = require('../../cordova-lib').events,
- helpers = require('../helpers'),
- temp = path.join(__dirname, '..', 'temp');
+var shell = require('shelljs');
+var path = require('path');
+var fs = require('fs');
+var util = require('../../src/cordova/util');
+var events = require('../../cordova-lib').events;
+var helpers = require('../helpers');
+var temp = path.join(__dirname, '..', 'temp');
var cwd = process.cwd();
-var home = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
+var home = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
var origPWD = process.env['PWD'];
-describe('util module', function() {
- describe('isCordova method', function() {
- afterEach(function() {
+describe('util module', function () {
+ describe('isCordova method', function () {
+ afterEach(function () {
process.env['PWD'] = origPWD;
process.chdir(cwd);
});
- function removeDir(directory) {
+ function removeDir (directory) {
shell.rm('-rf', directory);
}
- it('Test 001 : should return false if it hits the home directory', function() {
+ it('Test 001 : should return false if it hits the home directory', function () {
var somedir = path.join(home, 'somedir');
removeDir(somedir);
shell.mkdir(somedir);
expect(util.isCordova(somedir)).toEqual(false);
});
- it('Test 002 : should return false if it cannot find a .cordova directory up the directory tree', function() {
+ it('Test 002 : should return false if it cannot find a .cordova directory up the directory tree', function () {
var somedir = path.join(home, '..');
expect(util.isCordova(somedir)).toEqual(false);
});
- it('Test 003 : should return the first directory it finds with a .cordova folder in it', function() {
- var somedir = path.join(home,'somedir');
+ it('Test 003 : should return the first directory it finds with a .cordova folder in it', function () {
+ var somedir = path.join(home, 'somedir');
var anotherdir = path.join(somedir, 'anotherdir');
removeDir(somedir);
shell.mkdir('-p', anotherdir);
shell.mkdir('-p', path.join(somedir, 'www', 'config.xml'));
expect(util.isCordova(somedir)).toEqual(somedir);
});
- it('Test 004 : should ignore PWD when its undefined', function() {
+ it('Test 004 : should ignore PWD when its undefined', function () {
delete process.env['PWD'];
- var somedir = path.join(home,'somedir');
+ var somedir = path.join(home, 'somedir');
var anotherdir = path.join(somedir, 'anotherdir');
removeDir(somedir);
shell.mkdir('-p', anotherdir);
@@ -69,8 +67,8 @@ describe('util module', function() {
process.chdir(anotherdir);
expect(util.isCordova()).toEqual(somedir);
});
- it('Test 005 : should use PWD when available', function() {
- var somedir = path.join(home,'somedir');
+ it('Test 005 : should use PWD when available', function () {
+ var somedir = path.join(home, 'somedir');
var anotherdir = path.join(somedir, 'anotherdir');
removeDir(somedir);
shell.mkdir('-p', anotherdir);
@@ -79,8 +77,8 @@ describe('util module', function() {
process.chdir(path.sep);
expect(util.isCordova()).toEqual(somedir);
});
- it('Test 006 : should use cwd as a fallback when PWD is not a cordova dir', function() {
- var somedir = path.join(home,'somedir');
+ it('Test 006 : should use cwd as a fallback when PWD is not a cordova dir', function () {
+ var somedir = path.join(home, 'somedir');
var anotherdir = path.join(somedir, 'anotherdir');
removeDir(somedir);
shell.mkdir('-p', anotherdir);
@@ -89,8 +87,8 @@ describe('util module', function() {
process.chdir(anotherdir);
expect(util.isCordova()).toEqual(somedir);
});
- it('Test 007 : should ignore platform www/config.xml', function() {
- var somedir = path.join(home,'somedir');
+ it('Test 007 : should ignore platform www/config.xml', function () {
+ var somedir = path.join(home, 'somedir');
var anotherdir = path.join(somedir, 'anotherdir');
removeDir(somedir);
shell.mkdir('-p', anotherdir);
@@ -100,11 +98,11 @@ describe('util module', function() {
expect(util.isCordova(anotherdir)).toEqual(somedir);
});
});
- describe('deleteSvnFolders method', function() {
- afterEach(function() {
+ describe('deleteSvnFolders method', function () {
+ afterEach(function () {
shell.rm('-rf', temp);
});
- it('Test 008 : should delete .svn folders in any subdirectory of specified dir', function() {
+ it('Test 008 : should delete .svn folders in any subdirectory of specified dir', function () {
var one = path.join(temp, 'one');
var two = path.join(temp, 'two');
var one_svn = path.join(one, '.svn');
@@ -116,11 +114,11 @@ describe('util module', function() {
expect(fs.existsSync(two_svn)).toEqual(false);
});
});
- describe('listPlatforms method', function() {
- afterEach(function() {
+ describe('listPlatforms method', function () {
+ afterEach(function () {
shell.rm('-rf', temp);
});
- it('Test 009 : should only return supported platform directories present in a cordova project dir', function() {
+ it('Test 009 : should only return supported platform directories present in a cordova project dir', function () {
var platforms = path.join(temp, 'platforms');
shell.mkdir('-p', path.join(platforms, 'android'));
@@ -129,17 +127,17 @@ describe('util module', function() {
shell.mkdir('-p', path.join(platforms, 'atari'));
// create a typical platforms.json file, it should not be returned as a platform
- shell.exec('touch ' + path.join(platforms,'platforms.json'));
+ shell.exec('touch ' + path.join(platforms, 'platforms.json'));
var res = util.listPlatforms(temp);
expect(res.length).toEqual(4);
});
});
- describe('getInstalledPlatformsWithVersions method', function() {
- afterEach(function() {
+ describe('getInstalledPlatformsWithVersions method', function () {
+ afterEach(function () {
shell.rm('-rf', temp);
});
- it('Test 010 : should get the supported platforms in the cordova project dir along with their reported versions', function(done) {
+ it('Test 010 : should get the supported platforms in the cordova project dir along with their reported versions', function (done) {
var platforms = path.join(temp, 'platforms');
var android = path.join(platforms, 'android');
@@ -148,16 +146,16 @@ describe('util module', function() {
shell.cp('-R',
path.join(__dirname, 'fixtures', 'platforms', helpers.testPlatform), platforms);
util.getInstalledPlatformsWithVersions(temp)
- .then(function(platformMap) {
- expect(platformMap['android']).toBe('3.1.0');
- }).fin(done);
+ .then(function (platformMap) {
+ expect(platformMap['android']).toBe('3.1.0');
+ }).fin(done);
});
});
- describe('findPlugins method', function() {
- afterEach(function() {
+ describe('findPlugins method', function () {
+ afterEach(function () {
shell.rm('-rf', temp);
});
- it('Test 011 : should only return plugin directories present in a cordova project dir', function() {
+ it('Test 011 : should only return plugin directories present in a cordova project dir', function () {
var plugins = path.join(temp, 'plugins');
var android = path.join(plugins, 'android');
var ios = path.join(plugins, 'ios');
@@ -170,7 +168,7 @@ describe('util module', function() {
var res = util.findPlugins(plugins);
expect(res.length).toEqual(4);
});
- it('Test 012 : should not return ".svn" directories', function() {
+ it('Test 012 : should not return ".svn" directories', function () {
var plugins = path.join(temp, 'plugins');
var android = path.join(plugins, 'android');
var ios = path.join(plugins, 'ios');
@@ -182,7 +180,7 @@ describe('util module', function() {
expect(res.length).toEqual(2);
expect(res.indexOf('.svn')).toEqual(-1);
});
- it('Test 013 : should not return "CVS" directories', function() {
+ it('Test 013 : should not return "CVS" directories', function () {
var plugins = path.join(temp, 'plugins');
var android = path.join(plugins, 'android');
var ios = path.join(plugins, 'ios');
@@ -196,7 +194,7 @@ describe('util module', function() {
});
});
- describe('preprocessOptions method', function() {
+ describe('preprocessOptions method', function () {
var isCordova, listPlatforms;
var DEFAULT_OPTIONS = {
@@ -206,59 +204,59 @@ describe('util module', function() {
verbose: false
};
- beforeEach(function() {
+ beforeEach(function () {
isCordova = spyOn(util, 'isCordova').and.returnValue('/fake/path');
listPlatforms = spyOn(util, 'listPlatforms').and.returnValue(['android']);
});
- it('Test 014 : should throw if called outside of cordova project', function() {
+ it('Test 014 : should throw if called outside of cordova project', function () {
isCordova.and.returnValue(false);
- expect(function() { util.preProcessOptions(); }).toThrow();
+ expect(function () { util.preProcessOptions(); }).toThrow();
});
- it('Test 015 : should throw when no platforms added to project', function() {
+ it('Test 015 : should throw when no platforms added to project', function () {
listPlatforms.and.returnValue([]);
expect(function () { util.preProcessOptions(); }).toThrow();
});
- it('Test 016 : should return default options when no arguments passed', function() {
+ it('Test 016 : should return default options when no arguments passed', function () {
expect(util.preProcessOptions()).toEqual(jasmine.objectContaining(DEFAULT_OPTIONS));
});
- it('Test 017 : should accept single string argument as platform name', function() {
+ it('Test 017 : should accept single string argument as platform name', function () {
expect(util.preProcessOptions('ios')).toEqual(jasmine.objectContaining({platforms: ['ios']}));
});
- it('Test 018 : should accept array of strings as platform names', function() {
+ it('Test 018 : should accept array of strings as platform names', function () {
expect(util.preProcessOptions(['ios', 'windows'])).toEqual(jasmine.objectContaining({platforms: ['ios', 'windows']}));
});
- it('Test 019 : should fall back to installed platform if input doesn\'t contain platforms list', function() {
+ it('Test 019 : should fall back to installed platform if input doesn\'t contain platforms list', function () {
expect(util.preProcessOptions({verbose: true}))
.toEqual(jasmine.objectContaining({platforms: ['android'], verbose: true}));
});
- it('Test 020 : should pick buildConfig if no option is provided, but buildConfig.json exists', function() {
+ it('Test 020 : should pick buildConfig if no option is provided, but buildConfig.json exists', function () {
spyOn(fs, 'existsSync').and.returnValue(true);
// Using path.join below to normalize path separators
expect(util.preProcessOptions())
.toEqual(jasmine.objectContaining({options: {buildConfig: path.join('/fake/path/build.json')}}));
});
- describe('ensurePlatformOptionsCompatible', function() {
+ describe('ensurePlatformOptionsCompatible', function () {
var unknownOptions = ['--foo', '--appx=uap', '--gradleArg=--no-daemon'];
var validOptions = ['--debug', '--release', '--device', '--emulator', '--nobuild', '--list',
- '--buildConfig=/fake/path/build.json', '--target=foo', '--archs="x86 x64"'];
+ '--buildConfig=/fake/path/build.json', '--target=foo', '--archs="x86 x64"'];
- it('Test 021 : should return \'options\' unchanged if they are not an array', function() {
+ it('Test 021 : should return \'options\' unchanged if they are not an array', function () {
['foo', true, {bar: true}].forEach(function (optionValue) {
expect(util.preProcessOptions({options: optionValue}))
.toEqual(jasmine.objectContaining({options: optionValue}));
});
});
- it('Test 022 : should emit \'warn\' event if \'options\' is an Array', function() {
+ it('Test 022 : should emit \'warn\' event if \'options\' is an Array', function () {
var warnSpy = jasmine.createSpy('warnSpy');
events.on('warn', warnSpy);
util.preProcessOptions({options: ['foo']});
@@ -267,20 +265,25 @@ describe('util module', function() {
events.removeListener('warn', warnSpy);
});
- it('Test 023 : should convert options Array into object with \'argv\' field', function() {
+ it('Test 023 : should convert options Array into object with \'argv\' field', function () {
expect(util.preProcessOptions({options: []}))
.toEqual(jasmine.objectContaining({options: {argv: []}}));
});
it('Test 024 : should convert known options (platform-agnostic) into resultant object\'s fields', function () {
+ /* eslint-disable no-useless-escape */
var expectedResult = {
- 'debug': true, 'release': true,
- 'device': true, 'emulator': true,
- 'nobuild': true, 'list': true,
+ 'debug': true,
+ 'release': true,
+ 'device': true,
+ 'emulator': true,
+ 'nobuild': true,
+ 'list': true,
'buildConfig': '/fake/path/build.json',
'target': 'foo',
'archs': '\"x86 x64\"'
};
+ /* eslint-disable no-useless-escape */
expect(util.preProcessOptions({options: validOptions}).options)
.toEqual(jasmine.objectContaining(expectedResult));
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/helpers.js
----------------------------------------------------------------------
diff --git a/spec/helpers.js b/spec/helpers.js
index 76686df..f9fd7cd 100644
--- a/spec/helpers.js
+++ b/spec/helpers.js
@@ -17,18 +17,18 @@
under the License.
*/
-var path = require('path'),
- fs = require('fs'),
- shell = require('shelljs'),
- os = require('os'),
- ConfigParser = require('cordova-common').ConfigParser;
+var path = require('path');
+var fs = require('fs');
+var shell = require('shelljs');
+var os = require('os');
+var ConfigParser = require('cordova-common').ConfigParser;
// Just use Android everywhere; we're mocking out any calls to the `android` binary.
module.exports.testPlatform = 'android';
-function getConfigPath(dir) {
+function getConfigPath (dir) {
// if path ends with 'config.xml', return it
- if (dir.indexOf('config.xml') == dir.length - 10) {
+ if (dir.indexOf('config.xml') === dir.length - 10) {
return dir;
}
// otherwise, add 'config.xml' to the end of it
@@ -40,7 +40,7 @@ module.exports.tmpDir = function (subdir) {
if (subdir) {
dir = path.join(dir, subdir);
}
- if(fs.existsSync(dir)) {
+ if (fs.existsSync(dir)) {
shell.rm('-rf', dir);
}
shell.mkdir('-p', dir);
@@ -70,8 +70,8 @@ module.exports.setEngineSpec = function (appPath, engine, spec) {
module.exports.getEngineSpec = function (appPath, engine) {
appPath = getConfigPath(appPath);
- var parser = new ConfigParser(appPath),
- engines = parser.getEngines();
+ var parser = new ConfigParser(appPath);
+ var engines = parser.getEngines();
for (var i = 0; i < engines.length; i++) {
if (engines[i].name === module.exports.testPlatform) {
@@ -91,9 +91,9 @@ module.exports.removeEngine = function (appPath, engine) {
module.exports.setPluginSpec = function (appPath, plugin, spec) {
appPath = getConfigPath(appPath);
- var parser = new ConfigParser(appPath),
- p = parser.getPlugin(plugin),
- variables = [];
+ var parser = new ConfigParser(appPath);
+ var p = parser.getPlugin(plugin);
+ var variables = [];
if (p) {
parser.removePlugin(p.name);
@@ -108,8 +108,8 @@ module.exports.setPluginSpec = function (appPath, plugin, spec) {
module.exports.getPluginSpec = function (appPath, plugin) {
appPath = getConfigPath(appPath);
- var parser = new ConfigParser(appPath),
- p = parser.getPlugin(plugin);
+ var parser = new ConfigParser(appPath);
+ var p = parser.getPlugin(plugin);
if (p) {
return p.spec;
@@ -119,8 +119,8 @@ module.exports.getPluginSpec = function (appPath, plugin) {
module.exports.getPluginVariable = function (appPath, plugin, variable) {
appPath = getConfigPath(appPath);
- var parser = new ConfigParser(appPath),
- p = parser.getPlugin(plugin);
+ var parser = new ConfigParser(appPath);
+ var p = parser.getPlugin(plugin);
if (p && p.variables) {
return p.variables[variable];
@@ -151,12 +151,12 @@ beforeEach(function () {
jasmine.addMatchers({
'toExist': function () {
return {
- compare: function(actual, expected) {
+ compare: function (actual, expected) {
var result = {};
result.pass = fs.existsSync(actual);
- if(result.pass) {
+ if (result.pass) {
result.message = 'expected ' + actual + ' to not exist';
} else {
result.message = 'expected ' + actual + ' to exist';
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/plugman/add_platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/plugman/add_platform.spec.js b/spec/plugman/add_platform.spec.js
index ccef788..9631d2c 100644
--- a/spec/plugman/add_platform.spec.js
+++ b/spec/plugman/add_platform.spec.js
@@ -16,14 +16,14 @@
specific language governing permissions and limitations
under the License.
*/
-var platform = require('../../src/plugman/platform'),
- Q = require('q'),
- fs = require('fs');
+var platform = require('../../src/plugman/platform');
+var Q = require('q');
+var fs = require('fs');
-describe( 'platform add/remove', function() {
- it( 'Test 001 : should call platform add', function() {
- var sPlatformA = spyOn( platform, 'add' ).and.returnValue(Q()),
- sPlatformR = spyOn( platform, 'remove' ).and.returnValue(Q());
+describe('platform add/remove', function () {
+ it('Test 001 : should call platform add', function () {
+ var sPlatformA = spyOn(platform, 'add').and.returnValue(Q());
+ var sPlatformR = spyOn(platform, 'remove').and.returnValue(Q());
platform.add();
expect(sPlatformA).toHaveBeenCalled();
platform.remove();
@@ -31,43 +31,45 @@ describe( 'platform add/remove', function() {
});
});
+describe('platform add', function () {
+ /* eslint-disable no-unused-vars */
+ var done = false;
+ var existsSync;
+ /* eslint-enable no-unused-vars */
-describe( 'platform add', function() {
- var done = false,
- existsSync;
-
- beforeEach( function() {
- existsSync = spyOn( fs, 'existsSync' ).and.returnValue( false );
+ beforeEach(function () {
+ existsSync = spyOn(fs, 'existsSync').and.returnValue(false);
done = false;
});
- it( 'Test 002 : should error on non existing plugin.xml', function(done) {
- platform.add().then(function(result){
+ it('Test 002 : should error on non existing plugin.xml', function (done) {
+ platform.add().then(function (result) {
expect(false).toBe(true);
done();
},
- function err(errMsg) {
+ function err (errMsg) {
expect(errMsg.toString()).toContain('can\'t find a plugin.xml. Are you in the plugin?');
done();
});
}, 6000);
});
+describe('platform remove', function () {
+ /* eslint-disable no-unused-vars */
+ var done = false;
+ var existsSync;
+ /* eslint-enable no-unused-vars */
-describe( 'platform remove', function() {
- var done = false,
- existsSync;
-
- beforeEach( function() {
- existsSync = spyOn( fs, 'existsSync' ).and.returnValue( false );
+ beforeEach(function () {
+ existsSync = spyOn(fs, 'existsSync').and.returnValue(false);
done = false;
});
- it( 'Test 003 : should error on non existing plugin.xml', function(done) {
- platform.remove().then(function(result) {
+ it('Test 003 : should error on non existing plugin.xml', function (done) {
+ platform.remove().then(function (result) {
expect(false).toBe(true);
done();
},
- function err(errMsg) {
- expect(errMsg.toString()).toContain( 'can\'t find a plugin.xml. Are you in the plugin?' );
+ function err (errMsg) {
+ expect(errMsg.toString()).toContain('can\'t find a plugin.xml. Are you in the plugin?');
done();
});
}, 6000);
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/plugman/config.spec.js
----------------------------------------------------------------------
diff --git a/spec/plugman/config.spec.js b/spec/plugman/config.spec.js
index f8b087c..46c4a03 100644
--- a/spec/plugman/config.spec.js
+++ b/spec/plugman/config.spec.js
@@ -16,12 +16,12 @@
specific language governing permissions and limitations
under the License.
*/
-var config = require('../../src/plugman/config'),
- Q = require('q'),
- registry = require('../../src/plugman/registry/registry');
+var config = require('../../src/plugman/config');
+var Q = require('q');
+var registry = require('../../src/plugman/registry/registry');
-describe('config', function() {
- it('Test 001 : should run config', function() {
+describe('config', function () {
+ it('Test 001 : should run config', function () {
var sConfig = spyOn(registry, 'config').and.returnValue(Q());
var params = ['set', 'registry', 'http://registry.cordova.io'];
config(params);
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/plugman/create.spec.js
----------------------------------------------------------------------
diff --git a/spec/plugman/create.spec.js b/spec/plugman/create.spec.js
index 0aac688..e538851 100644
--- a/spec/plugman/create.spec.js
+++ b/spec/plugman/create.spec.js
@@ -16,62 +16,66 @@
specific language governing permissions and limitations
under the License.
*/
-var create = require('../../src/plugman/create'),
- Q = require('q'),
- fs = require('fs'),
- shell = require('shelljs'),
- plugman = require('../../src/plugman/plugman');
+var create = require('../../src/plugman/create');
+var Q = require('q');
+var fs = require('fs');
+var shell = require('shelljs');
+var plugman = require('../../src/plugman/plugman');
-describe( 'create', function() {
- it( 'Test 001 : should call create', function() {
- var sCreate = spyOn( plugman, 'create' ).and.returnValue(Q());
+describe('create', function () {
+ it('Test 001 : should call create', function () {
+ var sCreate = spyOn(plugman, 'create').and.returnValue(Q());
plugman.create();
expect(sCreate).toHaveBeenCalled();
});
});
-describe( 'create plugin', function() {
- var done = false,
- existsSync,
- mkdir,
- writeFileSync;
+describe('create plugin', function () {
+ /* eslint-disable no-unused-vars */
+ var done = false;
+ var existsSync;
+ var mkdir;
+ var writeFileSync;
+ /* eslint-enable no-unused-vars */
- beforeEach( function() {
- existsSync = spyOn( fs, 'existsSync' ).and.returnValue( false );
- mkdir = spyOn( shell, 'mkdir' ).and.returnValue( true );
- writeFileSync = spyOn( fs, 'writeFileSync' );
+ beforeEach(function () {
+ existsSync = spyOn(fs, 'existsSync').and.returnValue(false);
+ mkdir = spyOn(shell, 'mkdir').and.returnValue(true);
+ writeFileSync = spyOn(fs, 'writeFileSync');
done = false;
});
- it( 'Test 002 : should be successful', function(done) {
+ it('Test 002 : should be successful', function (done) {
create('name', 'org.plugin.id', '0.0.0', '.', [])
- .then(function(result) {
- expect( writeFileSync.calls.count() ).toEqual( 2 );
- done();
- }).fail(function err(errMsg) {
- expect(errMsg).toBeUndefined();
- done();
- });
+ .then(function (result) {
+ expect(writeFileSync.calls.count()).toEqual(2);
+ done();
+ }).fail(function err (errMsg) {
+ expect(errMsg).toBeUndefined();
+ done();
+ });
}, 6000);
});
-describe( 'create plugin in existing plugin', function() {
- var done = false,
- existsSync;
+describe('create plugin in existing plugin', function () {
+ /* eslint-disable no-unused-vars */
+ var done = false;
+ var existsSync;
+ /* eslint-enable no-unused-vars */
- beforeEach( function() {
- existsSync = spyOn( fs, 'existsSync' ).and.returnValue( true );
- done = false;
+ beforeEach(function () {
+ existsSync = spyOn(fs, 'existsSync').and.returnValue(true); // eslint-disable-line no-unused-vars
+ done = false; // eslint-disable-line no-unused-vars
});
- it( 'Test 003 : should fail due to an existing plugin.xml', function(done) {
+ it('Test 003 : should fail due to an existing plugin.xml', function (done) {
create()
- .then(function(result) {
- expect(false).toBe(true);
- done();
- }).fail(function err(errMsg) {
- expect(errMsg.toString()).toContain( 'plugin.xml already exists. Are you already in a plugin?' );
- done();
- });
+ .then(function (result) {
+ expect(false).toBe(true);
+ done();
+ }).fail(function err (errMsg) {
+ expect(errMsg.toString()).toContain('plugin.xml already exists. Are you already in a plugin?');
+ done();
+ });
}, 6000);
});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/plugman/info.spec.js
----------------------------------------------------------------------
diff --git a/spec/plugman/info.spec.js b/spec/plugman/info.spec.js
index b8505db..8f45b28 100644
--- a/spec/plugman/info.spec.js
+++ b/spec/plugman/info.spec.js
@@ -16,12 +16,12 @@
specific language governing permissions and limitations
under the License.
*/
-var search = require('../../src/plugman/info'),
- Q = require('q'),
- registry = require('../../src/plugman/registry/registry');
+var search = require('../../src/plugman/info');
+var Q = require('q');
+var registry = require('../../src/plugman/registry/registry');
-describe('info', function() {
- it('Test 001 : should show plugin info', function() {
+describe('info', function () {
+ it('Test 001 : should show plugin info', function () {
var sSearch = spyOn(registry, 'info').and.returnValue(Q({
name: 'fakePlugin',
version: '1.0.0',
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org