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:42 UTC
[11/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/integration-tests/plugin_fetch.spec.js
----------------------------------------------------------------------
diff --git a/integration-tests/plugin_fetch.spec.js b/integration-tests/plugin_fetch.spec.js
index 55b1a0e..ec0f14e 100644
--- a/integration-tests/plugin_fetch.spec.js
+++ b/integration-tests/plugin_fetch.spec.js
@@ -19,11 +19,11 @@
// TODO: all of these tests should go as unit tests to src/cordova/plugin/add
-var plugin = require('../src/cordova/plugin/add'),
+var plugin = require('../src/cordova/plugin/add'),
helpers = require('../spec/helpers'),
- path = require('path'),
+ path = require('path'),
events = require('cordova-common').events,
- shell = require('shelljs');
+ shell = require('shelljs');
var testPluginVersions = [
'0.0.2',
@@ -54,13 +54,13 @@ var UNMET_REQ_REGEX = /\s+([^\s]+)[^\d]+(\d+\.\d+\.\d+) in project, (.+) require
// We generate warnings when we don't fetch latest. Collect them to make sure we
// are making the correct warnings
-events.on('warn', function(warning) {
+events.on('warn', function (warning) {
warnings.push(warning);
});
// Tests a sample engine against the installed platforms/plugins in our test
// project
-function testEngineWithProject(done, testEngine, testResult) {
+function testEngineWithProject (done, testEngine, testResult) {
plugin.getFetchVersion(project,
{
'version': '2.3.0',
@@ -68,7 +68,7 @@ function testEngineWithProject(done, testEngine, testResult) {
'engines': { 'cordovaDependencies': testEngine },
'versions': testPluginVersions
}, cordovaVersion)
- .then(function(toFetch) {
+ .then(function (toFetch) {
expect(toFetch).toBe(testResult);
})
.fail(getVersionErrorCallback)
@@ -78,10 +78,10 @@ function testEngineWithProject(done, testEngine, testResult) {
// Checks the warnings that were printed by the CLI to ensure that the code is
// listing the correct reasons for failure. Checks against the global warnings
// object which is reset before each test
-function checkUnmetRequirements(requirements) {
+function checkUnmetRequirements (requirements) {
var reqWarnings = [];
- warnings.forEach(function(warning) {
+ warnings.forEach(function (warning) {
var extracted = UNMET_REQ_REGEX.exec(warning);
if (extracted) {
reqWarnings.push({
@@ -93,19 +93,18 @@ function checkUnmetRequirements(requirements) {
});
expect(reqWarnings.length).toEqual(requirements.length);
-
- requirements.forEach(function(requirement) {
- expect(reqWarnings).toContainArray(function(extractedWarning) {
- return extractedWarning.dependency === requirement.dependency.trim() &&
- extractedWarning.installed === requirement.installed.trim() &&
- extractedWarning.required === requirement.required.trim();
+ requirements.forEach(function (requirement) {
+ expect(reqWarnings).toContainArray(function (extractedWarning) {
+ return extractedWarning.dependency === requirement.dependency.trim() &&
+ extractedWarning.installed === requirement.installed.trim() &&
+ extractedWarning.required === requirement.required.trim();
}, requirement);
});
}
// Helper functions for creating the requirements objects taken by
// checkUnmetRequirements()
-function getPlatformRequirement(requirement) {
+function getPlatformRequirement (requirement) {
return {
dependency: 'cordova-android',
installed: '3.1.0',
@@ -113,7 +112,7 @@ function getPlatformRequirement(requirement) {
};
}
-function getCordovaRequirement(requirement) {
+function getCordovaRequirement (requirement) {
return {
dependency: 'cordova',
installed: cordovaVersion,
@@ -121,7 +120,7 @@ function getCordovaRequirement(requirement) {
};
}
-function getPluginRequirement(requirement) {
+function getPluginRequirement (requirement) {
return {
dependency: 'ca.filmaj.AndroidPlugin',
installed: '4.2.0',
@@ -130,8 +129,8 @@ function getPluginRequirement(requirement) {
}
// Generates a callback that checks warning messages after the test is complete
-function getWarningCheckCallback(done, requirements) {
- return function() {
+function getWarningCheckCallback (done, requirements) {
+ return function () {
checkUnmetRequirements(requirements);
expect(getVersionErrorCallback).not.toHaveBeenCalled();
done();
@@ -139,7 +138,7 @@ function getWarningCheckCallback(done, requirements) {
}
var fixtures = path.join(__dirname, '..', 'spec', 'cordova', 'fixtures');
-function createTestProject() {
+function createTestProject () {
// Get the base project
shell.cp('-R', path.join(fixtures, 'base'), tempDir);
shell.mv(path.join(tempDir, 'base'), project);
@@ -153,20 +152,20 @@ function createTestProject() {
path.join(project, 'plugins'));
}
-function removeTestProject() {
+function removeTestProject () {
shell.rm('-rf', tempDir);
}
-describe('plugin fetching version selection', function() {
+describe('plugin fetching version selection', function () {
createTestProject();
- beforeEach(function() {
+ beforeEach(function () {
jasmine.addMatchers({
- 'toContainArray': function() {
+ 'toContainArray': function () {
return {
- compare: function(actual, expected) {
+ compare: function (actual, expected) {
var result = {};
result.pass = false;
- for(var i = 0; i < actual.length; i++) {
+ for (var i = 0; i < actual.length; i++) {
if (expected(actual[i])) {
result.pass = true;
break;
@@ -182,15 +181,15 @@ describe('plugin fetching version selection', function() {
getVersionErrorCallback = jasmine.createSpy('unexpectedPluginFetchErrorCallback');
});
- it('Test 001 : should handle a mix of upper bounds and single versions', function(done) {
+ it('Test 001 : should handle a mix of upper bounds and single versions', function (done) {
var testEngine = {
- '0.0.0' : { 'cordova-android': '1.0.0' },
- '0.0.2' : { 'cordova-android': '>1.0.0' },
+ '0.0.0': { 'cordova-android': '1.0.0' },
+ '0.0.2': { 'cordova-android': '>1.0.0' },
'<1.0.0': { 'cordova-android': '<2.0.0' },
- '1.0.0' : { 'cordova-android': '>2.0.0' },
- '1.7.0' : { 'cordova-android': '>4.0.0' },
+ '1.0.0': { 'cordova-android': '>2.0.0' },
+ '1.7.0': { 'cordova-android': '>4.0.0' },
'<2.3.0': { 'cordova-android': '<6.1.1' },
- '2.3.0' : { 'cordova-android': '6.1.1' }
+ '2.3.0': { 'cordova-android': '6.1.1' }
};
var after = getWarningCheckCallback(done, [
@@ -199,15 +198,15 @@ describe('plugin fetching version selection', function() {
testEngineWithProject(after, testEngine, '1.3.0');
}, 6000);
- it('Test 002 : should apply upper bound engine constraints when there are no unspecified constraints above the upper bound', function(done) {
+ it('Test 002 : should apply upper bound engine constraints when there are no unspecified constraints above the upper bound', function (done) {
var testEngine = {
- '1.0.0' : { 'cordova-android': '>2.0.0' },
- '1.7.0' : { 'cordova-android': '>4.0.0' },
+ '1.0.0': { 'cordova-android': '>2.0.0' },
+ '1.7.0': { 'cordova-android': '>4.0.0' },
'<2.3.0': {
'cordova-android': '<6.1.1',
'ca.filmaj.AndroidPlugin': '<1.0.0'
},
- '2.3.0' : { 'cordova-android': '6.1.1' }
+ '2.3.0': { 'cordova-android': '6.1.1' }
};
var after = getWarningCheckCallback(done, [
@@ -216,10 +215,10 @@ describe('plugin fetching version selection', function() {
testEngineWithProject(after, testEngine, null);
});
- it('Test 003 : should apply upper bound engine constraints when there are unspecified constraints above the upper bound', function(done) {
+ it('Test 003 : should apply upper bound engine constraints when there are unspecified constraints above the upper bound', function (done) {
var testEngine = {
- '0.0.0' : {},
- '2.0.0' : { 'cordova-android': '~5.0.0' },
+ '0.0.0': {},
+ '2.0.0': { 'cordova-android': '~5.0.0' },
'<1.0.0': { 'cordova-android': '>5.0.0' }
};
@@ -230,9 +229,9 @@ describe('plugin fetching version selection', function() {
});
- it('Test 004 : should handle the case where there are no constraints for earliest releases', function(done) {
+ it('Test 004 : should handle the case where there are no constraints for earliest releases', function (done) {
var testEngine = {
- '1.0.0' : { 'cordova-android': '~5.0.0' }
+ '1.0.0': { 'cordova-android': '~5.0.0' }
};
var after = getWarningCheckCallback(done, [
@@ -242,9 +241,9 @@ describe('plugin fetching version selection', function() {
});
- it('Test 005 : should handle the case where the lowest version is unsatisfied', function(done) {
+ it('Test 005 : should handle the case where the lowest version is unsatisfied', function (done) {
var testEngine = {
- '0.0.2' : { 'cordova-android': '~5.0.0' }
+ '0.0.2': { 'cordova-android': '~5.0.0' }
};
var after = getWarningCheckCallback(done, [
@@ -254,7 +253,7 @@ describe('plugin fetching version selection', function() {
});
- it('Test 006 : should handle upperbounds if no single version constraints are given', function(done) {
+ it('Test 006 : should handle upperbounds if no single version constraints are given', function (done) {
var testEngine = {
'<1.0.0': { 'cordova-android': '<2.0.0' }
};
@@ -265,9 +264,9 @@ describe('plugin fetching version selection', function() {
});
- it('Test 007 : should apply upper bounds greater than highest version', function(done) {
+ it('Test 007 : should apply upper bounds greater than highest version', function (done) {
var testEngine = {
- '0.0.0' : {},
+ '0.0.0': {},
'<5.0.0': { 'cordova-android': '<2.0.0' }
};
@@ -279,10 +278,10 @@ describe('plugin fetching version selection', function() {
});
- it('Test 008 : should treat empty constraints as satisfied', function(done) {
+ it('Test 008 : should treat empty constraints as satisfied', function (done) {
var testEngine = {
- '1.0.0' : {},
- '1.1.0' : { 'cordova-android': '>5.0.0' }
+ '1.0.0': {},
+ '1.1.0': { 'cordova-android': '>5.0.0' }
};
var after = getWarningCheckCallback(done, [
@@ -293,7 +292,7 @@ describe('plugin fetching version selection', function() {
});
- it('Test 009 : should ignore an empty cordovaDependencies entry', function(done) {
+ it('Test 009 : should ignore an empty cordovaDependencies entry', function (done) {
var testEngine = {};
var after = getWarningCheckCallback(done, []);
@@ -302,9 +301,9 @@ describe('plugin fetching version selection', function() {
});
- it('Test 010 : should ignore a badly formatted semver range', function(done) {
+ it('Test 010 : should ignore a badly formatted semver range', function (done) {
var testEngine = {
- '1.1.3' : { 'cordova-android': 'badSemverRange' }
+ '1.1.3': { 'cordova-android': 'badSemverRange' }
};
var after = getWarningCheckCallback(done, []);
@@ -313,11 +312,11 @@ describe('plugin fetching version selection', function() {
});
- it('Test 011 : should respect unreleased versions in constraints', function(done) {
+ it('Test 011 : should respect unreleased versions in constraints', function (done) {
var testEngine = {
- '1.0.0' : { 'cordova-android': '3.1.0' },
- '1.1.2' : { 'cordova-android': '6.1.1' },
- '1.3.0' : { 'cordova-android': '6.1.1' }
+ '1.0.0': { 'cordova-android': '3.1.0' },
+ '1.1.2': { 'cordova-android': '6.1.1' },
+ '1.3.0': { 'cordova-android': '6.1.1' }
};
var after = getWarningCheckCallback(done, [
@@ -328,11 +327,11 @@ describe('plugin fetching version selection', function() {
});
- it('Test 012 : should respect plugin constraints', function(done) {
+ it('Test 012 : should respect plugin constraints', function (done) {
var testEngine = {
- '0.0.0' : { 'ca.filmaj.AndroidPlugin': '1.2.0' },
- '1.1.3' : { 'ca.filmaj.AndroidPlugin': '<5.0.0 || >2.3.0' },
- '2.3.0' : { 'ca.filmaj.AndroidPlugin': '6.1.1' }
+ '0.0.0': { 'ca.filmaj.AndroidPlugin': '1.2.0' },
+ '1.1.3': { 'ca.filmaj.AndroidPlugin': '<5.0.0 || >2.3.0' },
+ '2.3.0': { 'ca.filmaj.AndroidPlugin': '6.1.1' }
};
var after = getWarningCheckCallback(done, [
@@ -343,11 +342,11 @@ describe('plugin fetching version selection', function() {
});
- it('Test 013 : should respect cordova constraints', function(done) {
+ it('Test 013 : should respect cordova constraints', function (done) {
var testEngine = {
- '0.0.0' : { 'cordova': '>1.0.0' },
- '1.1.3' : { 'cordova': '<3.0.0 || >4.0.0' },
- '2.3.0' : { 'cordova': '6.1.1' }
+ '0.0.0': { 'cordova': '>1.0.0' },
+ '1.1.3': { 'cordova': '<3.0.0 || >4.0.0' },
+ '2.3.0': { 'cordova': '6.1.1' }
};
var after = getWarningCheckCallback(done, [
@@ -358,10 +357,10 @@ describe('plugin fetching version selection', function() {
});
- it('Test 014 : should not include pre-release versions', function(done) {
+ it('Test 014 : should not include pre-release versions', function (done) {
var testEngine = {
- '0.0.0' : {},
- '2.0.0' : { 'cordova-android': '>5.0.0' }
+ '0.0.0': {},
+ '2.0.0': { 'cordova-android': '>5.0.0' }
};
var after = getWarningCheckCallback(done, [
@@ -373,42 +372,42 @@ describe('plugin fetching version selection', function() {
});
- it('Test 015 : should not fail if there is no engine in the npm info', function(done) {
+ it('Test 015 : should not fail if there is no engine in the npm info', function (done) {
plugin.getFetchVersion(project, {
- version: '2.3.0',
- name: 'test-plugin',
- versions: testPluginVersions
- }, cordovaVersion)
- .then(function(toFetch) {
+ version: '2.3.0',
+ name: 'test-plugin',
+ versions: testPluginVersions
+ }, cordovaVersion)
+ .then(function (toFetch) {
expect(toFetch).toBe(null);
})
.fail(getVersionErrorCallback).fin(done);
});
- it('Test 016 : should not fail if there is no cordovaDependencies in the engines', function(done) {
+ it('Test 016 : should not fail if there is no cordovaDependencies in the engines', function (done) {
var after = getWarningCheckCallback(done, []);
plugin.getFetchVersion(project, {
- version: '2.3.0',
- name: 'test-plugin',
- versions: testPluginVersions,
- engines: {
- 'node': '>7.0.0',
- 'npm': '~2.0.0'
- }
- }, cordovaVersion)
- .then(function(toFetch) {
+ version: '2.3.0',
+ name: 'test-plugin',
+ versions: testPluginVersions,
+ engines: {
+ 'node': '>7.0.0',
+ 'npm': '~2.0.0'
+ }
+ }, cordovaVersion)
+ .then(function (toFetch) {
expect(toFetch).toBe(null);
})
.fail(getVersionErrorCallback).fin(after);
});
- it('Test 017 : should handle extra whitespace', function(done) {
+ it('Test 017 : should handle extra whitespace', function (done) {
var testEngine = {
- ' 1.0.0 ' : {},
- '2.0.0 ' : { ' cordova-android': '~5.0.0 ' },
- ' < 1.0.0\t' : { ' cordova-android ': ' > 5.0.0' }
+ ' 1.0.0 ': {},
+ '2.0.0 ': { ' cordova-android': '~5.0.0 ' },
+ ' < 1.0.0\t': { ' cordova-android ': ' > 5.0.0' }
};
var after = getWarningCheckCallback(done, [
@@ -419,11 +418,11 @@ describe('plugin fetching version selection', function() {
});
- it('Test 018 : should ignore badly typed version requirement entries', function(done) {
+ it('Test 018 : should ignore badly typed version requirement entries', function (done) {
var testEngine = {
- '1.1.0' : ['cordova', '5.0.0'],
- '1.3.0' : undefined,
- '1.7.0' : null
+ '1.1.0': ['cordova', '5.0.0'],
+ '1.3.0': undefined,
+ '1.7.0': null
};
var after = getWarningCheckCallback(done, []);
@@ -432,14 +431,14 @@ describe('plugin fetching version selection', function() {
});
- it('Test 019 : should ignore badly typed constraint entries', function(done) {
+ it('Test 019 : should ignore badly typed constraint entries', function (done) {
var testEngine = {
- '0.0.2' : { 'cordova': 1 },
- '0.7.0' : { 'cordova': {}},
- '1.0.0' : { 'cordova': undefined},
- '1.1.3' : { 8 : '5.0.0'},
- '1.3.0' : { 'cordova': [] },
- '1.7.1' : { 'cordova': null }
+ '0.0.2': { 'cordova': 1 },
+ '0.7.0': { 'cordova': {}},
+ '1.0.0': { 'cordova': undefined},
+ '1.1.3': { 8: '5.0.0'},
+ '1.3.0': { 'cordova': [] },
+ '1.7.1': { 'cordova': null }
};
var after = getWarningCheckCallback(done, []);
@@ -448,14 +447,14 @@ describe('plugin fetching version selection', function() {
});
- it('Test 020 : should ignore bad semver versions', function(done) {
+ it('Test 020 : should ignore bad semver versions', function (done) {
var testEngine = {
- '0.0.0' : { 'cordova-android': '5.0.0' },
- 'notAVersion' : { 'cordova-android': '3.1.0' },
- '^1.1.2' : { 'cordova-android': '3.1.0' },
- '<=1.3.0' : { 'cordova-android': '3.1.0' },
- '1.0' : { 'cordova-android': '3.1.0' },
- '2' : { 'cordova-android': '3.1.0' }
+ '0.0.0': { 'cordova-android': '5.0.0' },
+ 'notAVersion': { 'cordova-android': '3.1.0' },
+ '^1.1.2': { 'cordova-android': '3.1.0' },
+ '<=1.3.0': { 'cordova-android': '3.1.0' },
+ '1.0': { 'cordova-android': '3.1.0' },
+ '2': { 'cordova-android': '3.1.0' }
};
var after = getWarningCheckCallback(done, [
@@ -465,15 +464,15 @@ describe('plugin fetching version selection', function() {
testEngineWithProject(after, testEngine, null);
});
- it('Test 021 : should not fail if there are bad semver versions', function(done) {
+ it('Test 021 : should not fail if there are bad semver versions', function (done) {
var testEngine = {
- 'notAVersion' : { 'cordova-android': '3.1.0' },
- '^1.1.2' : { 'cordova-android': '3.1.0' },
- '<=1.3.0' : { 'cordova-android': '3.1.0' },
- '1.0.0' : { 'cordova-android': '~3' }, // Good semver
- '2.0.0' : { 'cordova-android': '5.1.0' }, // Good semver
- '1.0' : { 'cordova-android': '3.1.0' },
- '2' : { 'cordova-android': '3.1.0' }
+ 'notAVersion': { 'cordova-android': '3.1.0' },
+ '^1.1.2': { 'cordova-android': '3.1.0' },
+ '<=1.3.0': { 'cordova-android': '3.1.0' },
+ '1.0.0': { 'cordova-android': '~3' }, // Good semver
+ '2.0.0': { 'cordova-android': '5.1.0' }, // Good semver
+ '1.0': { 'cordova-android': '3.1.0' },
+ '2': { 'cordova-android': '3.1.0' }
};
var after = getWarningCheckCallback(done, [
@@ -483,12 +482,12 @@ describe('plugin fetching version selection', function() {
testEngineWithProject(after, testEngine, '1.7.1');
});
- it('Test 022 : should properly warn about multiple unmet requirements', function(done) {
+ it('Test 022 : should properly warn about multiple unmet requirements', function (done) {
var testEngine = {
- '1.7.0' : {
- 'cordova-android' : '>5.1.0',
- 'ca.filmaj.AndroidPlugin' : '3.1.0',
- 'cordova' : '3.4.2'
+ '1.7.0': {
+ 'cordova-android': '>5.1.0',
+ 'ca.filmaj.AndroidPlugin': '3.1.0',
+ 'cordova': '3.4.2'
}
};
@@ -500,12 +499,12 @@ describe('plugin fetching version selection', function() {
testEngineWithProject(after, testEngine, '1.3.0');
});
- it('Test 023 : should properly warn about both unmet latest and upper bound requirements', function(done) {
+ it('Test 023 : should properly warn about both unmet latest and upper bound requirements', function (done) {
var testEngine = {
- '1.7.0' : { 'cordova-android': '>5.1.0' },
+ '1.7.0': { 'cordova-android': '>5.1.0' },
'<5.0.0': {
- 'cordova-android' : '>7.1.0',
- 'ca.filmaj.AndroidPlugin' : '3.1.0'
+ 'cordova-android': '>7.1.0',
+ 'ca.filmaj.AndroidPlugin': '3.1.0'
}
};
@@ -517,12 +516,12 @@ describe('plugin fetching version selection', function() {
testEngineWithProject(after, testEngine, null);
});
- it('Test 024 : should not warn about versions past latest', function(done) {
+ it('Test 024 : should not warn about versions past latest', function (done) {
var testEngine = {
- '1.7.0' : { 'cordova-android': '>5.1.0' },
+ '1.7.0': { 'cordova-android': '>5.1.0' },
'7.0.0': {
- 'cordova-android' : '>7.1.0',
- 'ca.filmaj.AndroidPlugin' : '3.1.0'
+ 'cordova-android': '>7.1.0',
+ 'ca.filmaj.AndroidPlugin': '3.1.0'
}
};
@@ -533,7 +532,7 @@ describe('plugin fetching version selection', function() {
testEngineWithProject(after, testEngine, '1.3.0');
});
- it('Test 025 : clean up after plugin fetch spec', function() {
+ it('Test 025 : clean up after plugin fetch spec', function () {
removeTestProject();
});
});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/integration-tests/plugman_fetch.spec.js
----------------------------------------------------------------------
diff --git a/integration-tests/plugman_fetch.spec.js b/integration-tests/plugman_fetch.spec.js
index 3896db1..a12a072 100644
--- a/integration-tests/plugman_fetch.spec.js
+++ b/integration-tests/plugman_fetch.spec.js
@@ -16,33 +16,33 @@
specific language governing permissions and limitations
under the License.
*/
-var rewire = require('rewire'),
- fetch = rewire('../src/plugman/fetch'),
- fs = require('fs'),
- os = require('os'),
- path = require('path'),
- shell = require('shelljs'),
- realrm = shell.rm,
+var rewire = require('rewire'),
+ fetch = rewire('../src/plugman/fetch'),
+ fs = require('fs'),
+ os = require('os'),
+ path = require('path'),
+ shell = require('shelljs'),
+ realrm = shell.rm,
TIMEOUT = 60 * 1000,
- //xml_helpers = require('../src/util/xml-helpers'),
+ // xml_helpers = require('../src/util/xml-helpers'),
metadata = require('../src/plugman/util/metadata'),
- temp = path.join(os.tmpdir(), 'plugman', 'fetch');
+ temp = path.join(os.tmpdir(), 'plugman', 'fetch');
var plugins_dir = path.join(__dirname, '..', 'spec', 'plugman', 'plugins'),
test_plugin = path.join(plugins_dir, 'org.test.plugins.childbrowser'),
test_pkgjson_plugin = path.join(plugins_dir, 'pkgjson-test-plugin'),
test_plugin_searchpath = path.join(test_plugin, '..'),
- //test_plugin_with_space = path.join(__dirname, 'folder with space', 'plugins', 'org.test.plugins.childbrowser'),
- //test_plugin_xml = xml_helpers.parseElementtreeSync(path.join(test_plugin, 'plugin.xml')),
+ // test_plugin_with_space = path.join(__dirname, 'folder with space', 'plugins', 'org.test.plugins.childbrowser'),
+ // test_plugin_xml = xml_helpers.parseElementtreeSync(path.join(test_plugin, 'plugin.xml')),
test_plugin_id = 'org.test.plugins.childbrowser',
- test_plugin_version ='0.6.0',
+ test_plugin_version = '0.6.0',
plugins = require('../src/plugman/util/plugins'),
Q = require('q'),
registry = require('../src/plugman/registry/registry');
-describe('fetch', function() {
+describe('fetch', function () {
- function wrapper(p, done, post) {
- p.then(post, function(err) {
+ function wrapper (p, done, post) {
+ p.then(post, function (err) {
expect(err).toBeUndefined('Unexpected exception' + err.stack);
}).fin(done);
}
@@ -62,230 +62,229 @@ describe('fetch', function() {
});
});
*/
- describe('local plugins', function() {
+ describe('local plugins', function () {
var rm, sym, cp, save_metadata, revertLocal, revertFetch, fetchCalls = 0;
- beforeEach(function() {
+ beforeEach(function () {
rm = spyOn(shell, 'rm');
sym = spyOn(fs, 'symlinkSync');
cp = spyOn(shell, 'cp').and.callThrough();
save_metadata = spyOn(metadata, 'save_fetch_metadata');
realrm('-rf', temp);
revertLocal = fetch.__set__('localPlugins', null);
- revertFetch = fetch.__set__('fetch', function(pluginDir) {
- fetchCalls ++;
+ revertFetch = fetch.__set__('fetch', function (pluginDir) {
+ fetchCalls++;
return Q(pluginDir);
});
});
- afterEach(function(){
+ afterEach(function () {
revertLocal();
revertFetch();
fetchCalls = 0;
});
- it('Test 001 : should copy locally-available plugin to plugins directory', function(done) {
- wrapper(fetch(test_plugin, temp), done, function() {
+ it('Test 001 : should copy locally-available plugin to plugins directory', function (done) {
+ wrapper(fetch(test_plugin, temp), done, function () {
expect(cp).toHaveBeenCalledWith('-R', path.join(test_plugin, '*'), path.join(temp, test_plugin_id));
});
});
- it('Test 002 : should copy locally-available plugin to plugins directory when adding a plugin with searchpath argument', function(done) {
- wrapper(fetch(test_plugin_id, temp, { searchpath: test_plugin_searchpath }), done, function() {
+ it('Test 002 : should copy locally-available plugin to plugins directory when adding a plugin with searchpath argument', function (done) {
+ wrapper(fetch(test_plugin_id, temp, { searchpath: test_plugin_searchpath }), done, function () {
expect(cp).toHaveBeenCalledWith('-R', path.join(test_plugin, '*'), path.join(temp, test_plugin_id));
});
});
- it('Test 003 : should create a symlink if used with `link` param', function(done) {
- wrapper(fetch(test_plugin, temp, { link: true }), done, function() {
+ it('Test 003 : should create a symlink if used with `link` param', function (done) {
+ wrapper(fetch(test_plugin, temp, { link: true }), done, function () {
expect(sym).toHaveBeenCalledWith(test_plugin, path.join(temp, test_plugin_id), 'dir');
});
});
- it('Test 004 : should fail when the expected ID doesn\'t match', function(done) {
+ it('Test 004 : should fail when the expected ID doesn\'t match', function (done) {
fetch(test_plugin, temp, { expected_id: 'wrongID' })
- .then(function() {
+ .then(function () {
expect('this call').toBe('fail');
- }, function(err) {
- expect(''+err).toContain('Expected plugin to have ID "wrongID" but got');
+ }, function (err) {
+ expect('' + err).toContain('Expected plugin to have ID "wrongID" but got');
}).fin(done);
});
- it('Test 005 : should succeed when the expected ID is correct', function(done) {
- wrapper(fetch(test_plugin, temp, { expected_id: test_plugin_id }), done, function() {
+ it('Test 005 : should succeed when the expected ID is correct', function (done) {
+ wrapper(fetch(test_plugin, temp, { expected_id: test_plugin_id }), done, function () {
expect(1).toBe(1);
});
});
- it('Test 006 : should fail when the expected ID with version specified doesn\'t match', function(done) {
+ it('Test 006 : should fail when the expected ID with version specified doesn\'t match', function (done) {
fetch(test_plugin, temp, { expected_id: test_plugin_id + '@wrongVersion' })
- .then(function() {
+ .then(function () {
expect('this call').toBe('fail');
- }, function(err) {
- expect(''+err).toContain('to satisfy version "wrongVersion" but got');
+ }, function (err) {
+ expect('' + err).toContain('to satisfy version "wrongVersion" but got');
}).fin(done);
});
- it('Test 007 : should succeed when the plugin version specified is correct', function(done) {
+ it('Test 007 : should succeed when the plugin version specified is correct', function (done) {
var exp_id = test_plugin_id + '@' + test_plugin_version;
- wrapper(fetch(test_plugin, temp, { expected_id: exp_id}), done, function() {
+ wrapper(fetch(test_plugin, temp, { expected_id: exp_id}), done, function () {
expect(1).toBe(1);
});
});
- it('Test 027 : should copy locally-available plugin to plugins directory', function(done) {
- wrapper(fetch(test_pkgjson_plugin, temp, {fetch:true}), done, function() {
+ it('Test 027 : should copy locally-available plugin to plugins directory', function (done) {
+ wrapper(fetch(test_pkgjson_plugin, temp, {fetch: true}), done, function () {
expect(cp).toHaveBeenCalledWith('-R', path.join(test_pkgjson_plugin, '*'), path.join(temp, 'pkgjson-test-plugin'));
expect(fetchCalls).toBe(1);
});
});
- it('Test 028 : should fail when locally-available plugin is missing pacakge.json', function(done) {
- fetch(test_plugin, temp, {fetch:true})
- .then(function() {
+ it('Test 028 : should fail when locally-available plugin is missing pacakge.json', function (done) {
+ fetch(test_plugin, temp, {fetch: true})
+ .then(function () {
expect(false).toBe(true);
- }).fail(function(err) {
+ }).fail(function (err) {
expect(err).toBeDefined();
expect(err.message).toContain('needs a valid package.json');
done();
});
});
});
- describe('git plugins', function() {
+ describe('git plugins', function () {
var clone, save_metadata, done;
- beforeEach(function() {
+ beforeEach(function () {
clone = spyOn(plugins, 'clonePluginGitRepo').and.returnValue(Q(test_plugin));
save_metadata = spyOn(metadata, 'save_fetch_metadata');
done = false;
});
- it('Test 008 : should call clonePluginGitRepo for https:// and git:// based urls', function(done) {
+ it('Test 008 : should call clonePluginGitRepo for https:// and git:// based urls', function (done) {
var url = 'https://github.com/bobeast/GAPlugin.git';
- fetch(url, temp).then(function(){
- expect(save_metadata).toHaveBeenCalled();
- expect(clone).toHaveBeenCalledWith(url, temp, '.', undefined, undefined);
- done();
+ fetch(url, temp).then(function () {
+ expect(save_metadata).toHaveBeenCalled();
+ expect(clone).toHaveBeenCalledWith(url, temp, '.', undefined, undefined);
+ done();
});
}, 6000);
-
- it('Test 009 : should call clonePluginGitRepo with subdir if applicable', function(done) {
+
+ it('Test 009 : should call clonePluginGitRepo with subdir if applicable', function (done) {
var url = 'https://github.com/bobeast/GAPlugin.git';
var dir = 'fakeSubDir';
- fetch(url, temp, { subdir: dir }).then(function(){
+ fetch(url, temp, { subdir: dir }).then(function () {
expect(clone).toHaveBeenCalledWith(url, temp, dir, undefined, undefined);
expect(save_metadata).toHaveBeenCalled();
done();
});
}, 6000);
- it('Test 010 : should call clonePluginGitRepo with subdir and git ref if applicable', function(done) {
+ it('Test 010 : should call clonePluginGitRepo with subdir and git ref if applicable', function (done) {
var url = 'https://github.com/bobeast/GAPlugin.git';
var dir = 'fakeSubDir';
var ref = 'fakeGitRef';
- fetch(url, temp, { subdir: dir, git_ref: ref }).then(function(){
+ fetch(url, temp, { subdir: dir, git_ref: ref }).then(function () {
expect(clone).toHaveBeenCalledWith(url, temp, dir, ref, undefined);
expect(save_metadata).toHaveBeenCalled();
done();
});
}, 6000);
- it('Test 011 : should extract the git ref from the URL hash, if provided', function(done) {
+ it('Test 011 : should extract the git ref from the URL hash, if provided', function (done) {
var url = 'https://github.com/bobeast/GAPlugin.git#fakeGitRef';
var baseURL = 'https://github.com/bobeast/GAPlugin.git';
- fetch(url, temp, {}).then(function(){
+ fetch(url, temp, {}).then(function () {
expect(clone).toHaveBeenCalledWith(baseURL, temp, '.', 'fakeGitRef', undefined);
expect(save_metadata).toHaveBeenCalled();
done();
});
}, 6000);
- it('Test 012 : should extract the subdir from the URL hash, if provided', function(done) {
+ it('Test 012 : should extract the subdir from the URL hash, if provided', function (done) {
var url = 'https://github.com/bobeast/GAPlugin.git#:fakeSubDir';
var baseURL = 'https://github.com/bobeast/GAPlugin.git';
- fetch(url, temp, {}).then(function(result){
+ fetch(url, temp, {}).then(function (result) {
expect(clone).toHaveBeenCalledWith(baseURL, temp, 'fakeSubDir', undefined, undefined);
expect(save_metadata).toHaveBeenCalled();
done();
});
}, 6000);
- it('Test 013 : should extract the git ref and subdir from the URL hash, if provided', function(done) {
+ it('Test 013 : should extract the git ref and subdir from the URL hash, if provided', function (done) {
var url = 'https://github.com/bobeast/GAPlugin.git#fakeGitRef:/fake/Sub/Dir/';
var baseURL = 'https://github.com/bobeast/GAPlugin.git';
- fetch(url, temp, {}).then(function(result){
+ fetch(url, temp, {}).then(function (result) {
expect(clone).toHaveBeenCalledWith(baseURL, temp, 'fake/Sub/Dir', 'fakeGitRef', undefined);
expect(save_metadata).toHaveBeenCalled();
done();
});
}, 6000);
- it('Test 014 : should fail when the expected ID doesn\'t match', function(done) {
+ it('Test 014 : should fail when the expected ID doesn\'t match', function (done) {
fetch('https://github.com/bobeast/GAPlugin.git', temp, { expected_id: 'wrongID' })
- .then(function() {
+ .then(function () {
expect('this call').toBe('fail');
- }, function(err) {
- expect(''+err).toContain('Expected plugin to have ID "wrongID" but got');
+ }, function (err) {
+ expect('' + err).toContain('Expected plugin to have ID "wrongID" but got');
}).fin(done);
});
- it('Test 015 : should fail when the expected ID with version specified doesn\'t match', function(done) {
+ it('Test 015 : should fail when the expected ID with version specified doesn\'t match', function (done) {
fetch('https://github.com/bobeast/GAPlugin.git', temp, { expected_id: 'id@wrongVersion' })
- .then(function() {
+ .then(function () {
expect('this call').toBe('fail');
- }, function(err) {
- expect(''+err).toContain('Expected plugin to have ID "id" but got');
+ }, function (err) {
+ expect('' + err).toContain('Expected plugin to have ID "id" but got');
}).fin(done);
});
- it('Test 016 : should succeed when the expected ID is correct', function(done) {
- wrapper(fetch('https://github.com/bobeast/GAPlugin.git', temp, { expected_id: test_plugin_id }), done, function() {
+ it('Test 016 : should succeed when the expected ID is correct', function (done) {
+ wrapper(fetch('https://github.com/bobeast/GAPlugin.git', temp, { expected_id: test_plugin_id }), done, function () {
expect(1).toBe(1);
});
});
});
- describe('github plugins', function() {
+ describe('github plugins', function () {
// these tests actually pull a plugin from github
- beforeEach(function(){
- realrm('-rf',temp);
+ beforeEach(function () {
+ realrm('-rf', temp);
});
// this commit uses the new id
- it('Test 017 : should fetch from a commit-sha', function(done) {
- wrapper(fetch('http://github.com/apache/cordova-plugin-device.git#ad5f1e7bfd05ef98c01df549a0fa98036a5625db', temp, { expected_id: 'cordova-plugin-device' }), done, function() {
+ it('Test 017 : should fetch from a commit-sha', function (done) {
+ wrapper(fetch('http://github.com/apache/cordova-plugin-device.git#ad5f1e7bfd05ef98c01df549a0fa98036a5625db', temp, { expected_id: 'cordova-plugin-device' }), done, function () {
expect(1).toBe(1);
done();
});
}, TIMEOUT);
// this branch uses the old id
- it('Test 018 : should fetch from a branch', function(done) {
- wrapper(fetch('http://github.com/apache/cordova-plugin-device.git#cdvtest', temp, { expected_id: 'org.apache.cordova.device' }), done, function() {
+ it('Test 018 : should fetch from a branch', function (done) {
+ wrapper(fetch('http://github.com/apache/cordova-plugin-device.git#cdvtest', temp, { expected_id: 'org.apache.cordova.device' }), done, function () {
expect(1).toBe(1);
done();
});
}, TIMEOUT);
// this tag uses the new id
- it('Test 019 : should fetch from a tag', function(done) {
- wrapper(fetch('http://github.com/apache/cordova-plugin-device.git#r1.0.0', temp, { expected_id: 'cordova-plugin-device' }), done, function() {
+ it('Test 019 : should fetch from a tag', function (done) {
+ wrapper(fetch('http://github.com/apache/cordova-plugin-device.git#r1.0.0', temp, { expected_id: 'cordova-plugin-device' }), done, function () {
expect(1).toBe(1);
done();
});
}, TIMEOUT);
});
- describe('fetch recursive error CB-8809', function(){
+ describe('fetch recursive error CB-8809', function () {
var srcDir = path.join(plugins_dir, 'recursivePlug');
var appDir = path.join(plugins_dir, 'recursivePlug', 'demo');
- if(/^win/.test(process.platform)) {
- it('Test 020 : should copy all but the /demo/ folder',function(done) {
+ if (/^win/.test(process.platform)) {
+ it('Test 020 : should copy all but the /demo/ folder', function (done) {
var cp = spyOn(shell, 'cp');
- wrapper(fetch(srcDir, appDir),done, function() {
- expect(cp).toHaveBeenCalledWith('-R',path.join(srcDir,'asset.txt'),path.join(appDir,'test-recursive'));
- expect(cp).not.toHaveBeenCalledWith('-R',srcDir,path.join(appDir,'test-recursive'));
+ wrapper(fetch(srcDir, appDir), done, function () {
+ expect(cp).toHaveBeenCalledWith('-R', path.join(srcDir, 'asset.txt'), path.join(appDir, 'test-recursive'));
+ expect(cp).not.toHaveBeenCalledWith('-R', srcDir, path.join(appDir, 'test-recursive'));
});
});
- }
- else {
- it('Test 021 : should skip copy to avoid recursive error', function(done) {
+ } else {
+ it('Test 021 : should skip copy to avoid recursive error', function (done) {
- var cp = spyOn(shell, 'cp').and.callFake(function(){});
+ var cp = spyOn(shell, 'cp').and.callFake(function () {});
- wrapper(fetch(srcDir, appDir),done, function() {
+ wrapper(fetch(srcDir, appDir), done, function () {
expect(cp).not.toHaveBeenCalled();
});
});
@@ -293,10 +292,10 @@ describe('fetch', function() {
});
- describe('registry plugins', function() {
+ describe('registry plugins', function () {
var pluginId = 'dummyplugin', sFetch;
var rm, sym, save_metadata;
- beforeEach(function() {
+ beforeEach(function () {
rm = spyOn(shell, 'rm');
sym = spyOn(fs, 'symlinkSync');
save_metadata = spyOn(metadata, 'save_fetch_metadata');
@@ -304,35 +303,35 @@ describe('fetch', function() {
realrm('-rf', temp);
});
- it('Test 022 : should fail when the expected ID with version specified doesn\'t match', function(done) {
- //fetch(pluginId, temp, { expected_id: test_plugin_id + '@wrongVersion' })
+ it('Test 022 : should fail when the expected ID with version specified doesn\'t match', function (done) {
+ // fetch(pluginId, temp, { expected_id: test_plugin_id + '@wrongVersion' })
fetch(pluginId, temp, { expected_id: 'wrongID' })
- .then(function() {
+ .then(function () {
expect('this call').toBe('fail');
- }, function(err) {
- expect(''+err).toContain('Expected plugin to have ID "wrongID" but got');
+ }, function (err) {
+ expect('' + err).toContain('Expected plugin to have ID "wrongID" but got');
}).fin(done);
});
-
- it('Test 023 : should succeed when the expected ID is correct', function(done) {
- wrapper(fetch(pluginId, temp, { expected_id: test_plugin_id }), done, function() {
+
+ it('Test 023 : should succeed when the expected ID is correct', function (done) {
+ wrapper(fetch(pluginId, temp, { expected_id: test_plugin_id }), done, function () {
expect(1).toBe(1);
});
});
- it('Test 024 : should succeed when the plugin version specified is correct', function(done) {
- wrapper(fetch(pluginId, temp, { expected_id: test_plugin_id + '@' + test_plugin_version }), done, function() {
+ it('Test 024 : should succeed when the plugin version specified is correct', function (done) {
+ wrapper(fetch(pluginId, temp, { expected_id: test_plugin_id + '@' + test_plugin_version }), done, function () {
expect(1).toBe(1);
});
});
- it('Test 025 : should fetch plugins that are scoped packages', function(done) {
+ it('Test 025 : should fetch plugins that are scoped packages', function (done) {
var scopedPackage = '@testcope/dummy-plugin';
- wrapper(fetch(scopedPackage, temp, { expected_id: test_plugin_id }), done, function() {
+ wrapper(fetch(scopedPackage, temp, { expected_id: test_plugin_id }), done, function () {
expect(sFetch).toHaveBeenCalledWith([scopedPackage]);
});
});
- it('Test 026 : should fetch plugins that are scoped packages and have versions specified', function(done) {
+ it('Test 026 : should fetch plugins that are scoped packages and have versions specified', function (done) {
var scopedPackage = '@testcope/dummy-plugin@latest';
- wrapper(fetch(scopedPackage, temp, { expected_id: test_plugin_id }), done, function() {
+ wrapper(fetch(scopedPackage, temp, { expected_id: test_plugin_id }), done, function () {
expect(sFetch).toHaveBeenCalledWith([scopedPackage]);
});
});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/integration-tests/plugman_uninstall.spec.js
----------------------------------------------------------------------
diff --git a/integration-tests/plugman_uninstall.spec.js b/integration-tests/plugman_uninstall.spec.js
index 4755929..7d1b73a 100644
--- a/integration-tests/plugman_uninstall.spec.js
+++ b/integration-tests/plugman_uninstall.spec.js
@@ -24,16 +24,16 @@ var uninstall = require('../src/plugman/uninstall'),
actions = require('cordova-common').ActionStack,
PluginInfo = require('cordova-common').PluginInfo,
events = require('cordova-common').events,
- common = require('../spec/common'),
+ common = require('../spec/common'),
platforms = require('../src/platforms/platforms'),
xmlHelpers = require('cordova-common').xmlHelpers,
- et = require('elementtree'),
- fs = require('fs'),
- path = require('path'),
- shell = require('shelljs'),
- Q = require('q'),
- spec = path.join(__dirname, '..', 'spec', 'plugman'),
- done = false,
+ et = require('elementtree'),
+ fs = require('fs'),
+ path = require('path'),
+ shell = require('shelljs'),
+ Q = require('q'),
+ spec = path.join(__dirname, '..', 'spec', 'plugman'),
+ done = false,
srcProject = path.join(spec, 'projects', 'android'),
project = path.join(spec, 'projects', 'android_uninstall.test'),
project2 = path.join(spec, 'projects', 'android_uninstall.test2'),
@@ -45,9 +45,9 @@ var uninstall = require('../src/plugman/uninstall'),
plugins_install_dir3 = path.join(project3, 'cordova', 'plugins'),
plugins = {
- 'org.test.plugins.dummyplugin' : path.join(plugins_dir, 'org.test.plugins.dummyplugin'),
- 'A' : path.join(plugins_dir, 'dependencies', 'A'),
- 'C' : path.join(plugins_dir, 'dependencies', 'C')
+ 'org.test.plugins.dummyplugin': path.join(plugins_dir, 'org.test.plugins.dummyplugin'),
+ 'A': path.join(plugins_dir, 'dependencies', 'A'),
+ 'C': path.join(plugins_dir, 'dependencies', 'C')
},
dummy_id = 'org.test.plugins.dummyplugin';
@@ -69,60 +69,60 @@ var TEST_XML = '<?xml version="1.0" encoding="UTF-8"?>\n' +
' <access origin="*" />\n' +
'</widget>\n';
-describe('plugman uninstall start', function() {
+describe('plugman uninstall start', function () {
beforeEach(function () {
var origParseElementtreeSync = xmlHelpers.parseElementtreeSync.bind(xmlHelpers);
- spyOn(xmlHelpers, 'parseElementtreeSync').and.callFake(function(path) {
+ spyOn(xmlHelpers, 'parseElementtreeSync').and.callFake(function (path) {
if (/config.xml$/.test(path)) return new et.ElementTree(et.XML(TEST_XML));
return origParseElementtreeSync(path);
});
});
- it('Test 001 : plugman uninstall start', function(done) {
+ it('Test 001 : plugman uninstall start', function (done) {
shell.rm('-rf', project, project2, project3);
shell.cp('-R', path.join(srcProject, '*'), project);
shell.cp('-R', path.join(srcProject, '*'), project2);
shell.cp('-R', path.join(srcProject, '*'), project3);
return install('android', project, plugins['org.test.plugins.dummyplugin'])
- .then(function(result){
+ .then(function (result) {
return install('android', project, plugins['A']);
- }).then( function(){
+ }).then(function () {
return install('android', project2, plugins['C']);
- }).then(function(){
+ }).then(function () {
return install('android', project2, plugins['A']);
- }).then(function(){
+ }).then(function () {
return install('android', project3, plugins['A']);
- }).then(function(){
+ }).then(function () {
return install('android', project3, plugins['C']);
- }).then(function(result){
+ }).then(function (result) {
expect(result).toEqual(true);
done();
- }).fail(function(err){
+ }).fail(function (err) {
expect(err).toBeUndefined();
});
}, 60000);
});
-describe('uninstallPlatform', function() {
+describe('uninstallPlatform', function () {
var proc, rm;
var fsWrite;
- beforeEach(function() {
+ beforeEach(function () {
proc = spyOn(actions.prototype, 'process').and.returnValue(Q());
fsWrite = spyOn(fs, 'writeFileSync').and.returnValue(true);
rm = spyOn(shell, 'rm').and.returnValue(true);
spyOn(shell, 'cp').and.returnValue(true);
done = false;
});
- describe('success', function() {
+ describe('success', function () {
- it('Test 002 : should get PlatformApi instance for platform and invoke its\' removePlugin method', function(done) {
+ it('Test 002 : should get PlatformApi instance for platform and invoke its\' removePlugin method', function (done) {
var platformApi = { removePlugin: jasmine.createSpy('removePlugin').and.returnValue(Q()) };
var getPlatformApi = spyOn(platforms, 'getPlatformApi').and.returnValue(platformApi);
uninstall.uninstallPlatform('android', project, dummy_id)
- .then(function() {
+ .then(function () {
expect(getPlatformApi).toHaveBeenCalledWith('android', project);
expect(platformApi.removePlugin).toHaveBeenCalled();
done();
@@ -132,7 +132,7 @@ describe('uninstallPlatform', function() {
});
}, 6000);
- it('Test 003 : should return propagate value returned by PlatformApi removePlugin method', function(done) {
+ it('Test 003 : should return propagate value returned by PlatformApi removePlugin method', function (done) {
var platformApi = { removePlugin: jasmine.createSpy('removePlugin') };
spyOn(platforms, 'getPlatformApi').and.returnValue(platformApi);
@@ -145,7 +145,7 @@ describe('uninstallPlatform', function() {
var fakeProvider = jasmine.createSpyObj('fakeProvider', ['get']);
fakeProvider.get.and.returnValue(dummyPluginInfo);
- function validateReturnedResultFor(values, expectedResult) {
+ function validateReturnedResultFor (values, expectedResult) {
return values.reduce(function (promise, value) {
return promise
.then(function () {
@@ -153,38 +153,38 @@ describe('uninstallPlatform', function() {
return uninstall.uninstallPlatform('android', project, dummy_id, null,
{ pluginInfoProvider: fakeProvider, platformVersion: '9.9.9' });
})
- .then(function(result) {
+ .then(function (result) {
expect(!!result).toEqual(expectedResult);
- }, function(err) {
+ }, function (err) {
expect(err).toBeUndefined();
});
}, Q());
}
- validateReturnedResultFor([ true, {}, [], 'foo', function(){} ], true)
+ validateReturnedResultFor([ true, {}, [], 'foo', function () {} ], true)
.then(function () {
return validateReturnedResultFor([ false, null, undefined, '' ], false);
})
.fin(done);
});
- describe('with dependencies', function() {
+ describe('with dependencies', function () {
var emit;
- beforeEach(function() {
+ beforeEach(function () {
emit = spyOn(events, 'emit');
});
uninstall.uninstallPlatform('android', project, 'A')
- .then(function(result) {
+ .then(function (result) {
expect(emit).toHaveBeenCalledWith('log', 'Uninstalling 2 dependent plugins.');
done();
});
});
});
- describe('failure ', function() {
- it('Test 004 : should throw if platform is unrecognized', function(done) {
+ describe('failure ', function () {
+ it('Test 004 : should throw if platform is unrecognized', function (done) {
uninstall.uninstallPlatform('atari', project, 'SomePlugin')
- .then(function(result){
+ .then(function (result) {
expect(false).toBe(true);
done();
}).fail(function err (errMsg) {
@@ -193,9 +193,9 @@ describe('uninstallPlatform', function() {
});
}, 6000);
- it('Test 005 : should throw if plugin is missing', function(done) {
+ it('Test 005 : should throw if plugin is missing', function (done) {
uninstall.uninstallPlatform('android', project, 'SomePluginThatDoesntExist')
- .then(function(result){
+ .then(function (result) {
expect(false).toBe(true);
done();
}).fail(function err (errMsg) {
@@ -206,21 +206,21 @@ describe('uninstallPlatform', function() {
});
});
-describe('uninstallPlugin', function() {
+describe('uninstallPlugin', function () {
var rm, fsWrite, rmstack = [], emit;
- beforeEach(function() {
+ beforeEach(function () {
fsWrite = spyOn(fs, 'writeFileSync').and.returnValue(true);
- rm = spyOn(shell, 'rm').and.callFake(function(f,p) { rmstack.push(p); return true; });
+ rm = spyOn(shell, 'rm').and.callFake(function (f, p) { rmstack.push(p); return true; });
rmstack = [];
emit = spyOn(events, 'emit');
done = false;
});
- describe('with dependencies', function() {
+ describe('with dependencies', function () {
- it('Test 006 : should delete all dependent plugins', function(done) {
+ it('Test 006 : should delete all dependent plugins', function (done) {
uninstall.uninstallPlugin('A', plugins_install_dir)
- .then(function(result) {
+ .then(function (result) {
var del = common.spy.getDeleted(emit);
expect(del).toEqual([
'Deleted "C"',
@@ -231,9 +231,9 @@ describe('uninstallPlugin', function() {
});
});
- it('Test 007 : should fail if plugin is a required dependency', function(done) {
+ it('Test 007 : should fail if plugin is a required dependency', function (done) {
uninstall.uninstallPlugin('C', plugins_install_dir)
- .then(function(result){
+ .then(function (result) {
expect(false).toBe(true);
done();
}).fail(function err (errMsg) {
@@ -242,18 +242,18 @@ describe('uninstallPlugin', function() {
});
}, 6000);
- it('Test 008 : allow forcefully removing a plugin', function(done) {
- uninstall.uninstallPlugin('C', plugins_install_dir, {force: true})
- .then(function() {
+ it('Test 008 : allow forcefully removing a plugin', function (done) {
+ uninstall.uninstallPlugin('C', plugins_install_dir, {force: true})
+ .then(function () {
var del = common.spy.getDeleted(emit);
expect(del).toEqual(['Deleted "C"']);
done();
});
});
- it('Test 009 : never remove top level plugins if they are a dependency', function(done) {
+ it('Test 009 : never remove top level plugins if they are a dependency', function (done) {
uninstall.uninstallPlugin('A', plugins_install_dir2)
- .then(function() {
+ .then(function () {
var del = common.spy.getDeleted(emit);
expect(del).toEqual([
'Deleted "D"',
@@ -263,9 +263,9 @@ describe('uninstallPlugin', function() {
});
});
- it('Test 010 : should not remove dependent plugin if it was installed after as top-level', function(done) {
+ it('Test 010 : should not remove dependent plugin if it was installed after as top-level', function (done) {
uninstall.uninstallPlugin('A', plugins_install_dir3)
- .then(function() {
+ .then(function () {
var del = common.spy.getDeleted(emit);
expect(del).toEqual([
'Deleted "D"',
@@ -277,19 +277,19 @@ describe('uninstallPlugin', function() {
});
});
-describe('uninstall', function() {
+describe('uninstall', function () {
var fsWrite, rm;
- beforeEach(function() {
+ beforeEach(function () {
fsWrite = spyOn(fs, 'writeFileSync').and.returnValue(true);
rm = spyOn(shell, 'rm').and.returnValue(true);
done = false;
});
-
- describe('failure', function() {
- it('Test 011 : should throw if platform is unrecognized', function(done) {
+
+ describe('failure', function () {
+ it('Test 011 : should throw if platform is unrecognized', function (done) {
return uninstall('atari', project, 'SomePlugin')
- .then(function(result){
+ .then(function (result) {
expect(false).toBe(true);
done();
}).fail(function err (errMsg) {
@@ -298,9 +298,9 @@ describe('uninstall', function() {
});
}, 6000);
- it('Test 012 : should throw if plugin is missing', function(done) {
+ it('Test 012 : should throw if plugin is missing', function (done) {
uninstall('android', project, 'SomePluginThatDoesntExist')
- .then(function(result){
+ .then(function (result) {
expect(false).toBe(true);
done();
}).fail(function err (errMsg) {
@@ -311,20 +311,19 @@ describe('uninstall', function() {
});
});
-describe('end', function() {
- it('Test 013 : end', function(done) {
+describe('end', function () {
+ it('Test 013 : end', function (done) {
return uninstall('android', project, plugins['org.test.plugins.dummyplugin'])
- .then(function(){
+ .then(function () {
// Fails... A depends on
return uninstall('android', project, plugins['C']);
- }).fail(function(err) {
+ }).fail(function (err) {
expect(err.stack).toMatch(/The plugin 'C' is required by \(A\), skipping uninstallation./);
- }).then(function(){
+ }).then(function () {
// dependencies on C,D ... should this only work with --recursive? prompt user..?
return uninstall('android', project, plugins['A']);
- }).fin(function(err){
- if(err)
- events.emit('error', err);
+ }).fin(function (err) {
+ if (err) { events.emit('error', err); }
shell.rm('-rf', project, project2, project3);
done();
});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/common.js
----------------------------------------------------------------------
diff --git a/spec/common.js b/spec/common.js
index dd29539..3c1c45b 100644
--- a/spec/common.js
+++ b/spec/common.js
@@ -49,30 +49,26 @@ var common = {};
module.exports = common = {
spy: {
- getInstall: function(emitSpy){
+ getInstall: function (emitSpy) {
return common.spy.startsWith(emitSpy, 'Install start');
},
- getDeleted: function(emitSpy){
+ getDeleted: function (emitSpy) {
return common.spy.startsWith(emitSpy, 'Deleted');
},
- startsWith: function(emitSpy, string)
- {
+ startsWith: function (emitSpy, string) {
var match = [];
- emitSpy.calls.all().forEach(function(val, i) {
- if(emitSpy.calls.argsFor(i)[1].substr(0, string.length) === string)
- match.push(emitSpy.calls.argsFor(i)[1]);
+ emitSpy.calls.all().forEach(function (val, i) {
+ if (emitSpy.calls.argsFor(i)[1].substr(0, string.length) === string) { match.push(emitSpy.calls.argsFor(i)[1]); }
});
return match;
},
- contains: function(emitSpy, string)
- {
+ contains: function (emitSpy, string) {
var match = [];
- emitSpy.calls.all().forEach(function(val, i) {
- if(emitSpy.calls.argsFor(i)[1].indexOf(string) >= 0)
- match.push(emitSpy.calls.argsFor(i)[1]);
+ emitSpy.calls.all().forEach(function (val, i) {
+ if (emitSpy.calls.argsFor(i)[1].indexOf(string) >= 0) { match.push(emitSpy.calls.argsFor(i)[1]); }
});
return match;
}
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/cordova/build.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova/build.spec.js b/spec/cordova/build.spec.js
index 7c9e737..c7919b2 100644
--- a/spec/cordova/build.spec.js
+++ b/spec/cordova/build.spec.js
@@ -16,20 +16,23 @@
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('build command', function() {
- var is_cordova, cd_project_root, list_platforms, fire;
+describe('build command', function () {
+ var is_cordova;
+ var cd_project_root; // eslint-disable-line no-unused-vars
+ var list_platforms;
+ var fire;
var project_dir = '/some/path';
var prepare_spy, compile_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);
@@ -37,44 +40,44 @@ describe('build command', function() {
prepare_spy = spyOn(cordova, 'prepare').and.returnValue(Q());
compile_spy = spyOn(cordova, 'compile').and.returnValue(Q());
});
- describe('failure', function() {
- it('Test 001 : should not run inside a project with no platforms', function(done) {
+ describe('failure', function () {
+ it('Test 001 : should not run inside a project with no platforms', function (done) {
list_platforms.and.returnValue([]);
cordova.build()
- .then(function() {
- expect('this call').toBe('fail');
- }, function(err) {
- expect(err.message).toEqual(
- 'No platforms added to this project. Please use `cordova platform add <platform>`.'
- );
- }).fin(done);
+ .then(function () {
+ expect('this call').toBe('fail');
+ }, 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) {
is_cordova.and.returnValue(false);
cordova.build()
- .then(function() {
- expect('this call').toBe('fail');
- }, function(err) {
- expect(err.message).toEqual(
- 'Current working directory is not a Cordova-based project.'
- );
- }).fin(done);
+ .then(function () {
+ expect('this call').toBe('fail');
+ }, function (err) {
+ expect(err.message).toEqual(
+ 'Current working directory is not a Cordova-based project.'
+ );
+ }).fin(done);
});
});
- describe('success', function() {
- it('Test 003 : should run inside a Cordova-based project with at least one added platform and call both prepare and compile', function(done) {
- cordova.build(['android','ios']).then(function() {
- var opts = Object({ platforms: [ 'android', 'ios' ], verbose: false, options: Object({ }) });
+ describe('success', function () {
+ it('Test 003 : should run inside a Cordova-based project with at least one added platform and call both prepare and compile', function (done) {
+ cordova.build(['android', 'ios']).then(function () {
+ var opts = Object({ platforms: [ 'android', 'ios' ], verbose: false, options: Object({ }) });
expect(prepare_spy).toHaveBeenCalledWith(opts);
expect(compile_spy).toHaveBeenCalledWith(opts);
done();
});
});
- it('Test 004 : should pass down options', function(done) {
- cordova.build({platforms: ['android'], options: {release: true}}).then(function() {
+ it('Test 004 : should pass down options', function (done) {
+ cordova.build({platforms: ['android'], options: {release: true}}).then(function () {
var opts = {platforms: ['android'], options: {release: true}, verbose: false};
expect(prepare_spy).toHaveBeenCalledWith(opts);
expect(compile_spy).toHaveBeenCalledWith(opts);
@@ -83,12 +86,12 @@ describe('build command', function() {
});
it('Test 005 : should convert options 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.build({platforms:['android'], options:['--release', '--cdvBuildOpt=opt']}).then(function () {
+ cordova.build({platforms: ['android'], options: ['--release', '--cdvBuildOpt=opt']}).then(function () {
var opts = {platforms: ['android'], options: jasmine.objectContaining({release: true, argv: ['--cdvBuildOpt=opt']}), verbose: false};
expect(prepare_spy).toHaveBeenCalledWith(opts);
expect(compile_spy).toHaveBeenCalledWith(opts);
@@ -98,28 +101,28 @@ describe('build command', function() {
});
});
- describe('hooks', function() {
- describe('when platforms are added', function() {
- it('Test 006 : should fire before hooks through the hooker module', function(done) {
- cordova.build(['android', 'ios']).then(function() {
- expect(fire.calls.argsFor(0)).toEqual(['before_build', {verbose: false, platforms:['android', 'ios'] , options: {}}]);
+ describe('hooks', function () {
+ describe('when platforms are added', function () {
+ it('Test 006 : should fire before hooks through the hooker module', function (done) {
+ cordova.build(['android', 'ios']).then(function () {
+ expect(fire.calls.argsFor(0)).toEqual(['before_build', {verbose: false, platforms: ['android', 'ios'], options: {}}]);
done();
});
});
- it('Test 007 : should fire after hooks through the hooker module', function(done) {
- cordova.build('android').then(function() {
- expect(fire.calls.argsFor(1)).toEqual([ 'after_build', { platforms: [ 'android' ], verbose: false, options: {} } ]);
- done();
+ it('Test 007 : should fire after hooks through the hooker module', function (done) {
+ cordova.build('android').then(function () {
+ expect(fire.calls.argsFor(1)).toEqual([ 'after_build', { platforms: [ 'android' ], verbose: false, options: {} } ]);
+ done();
});
});
});
- describe('with no platforms added', function() {
- it('Test 008 : should not fire the hooker', function(done) {
+ describe('with no platforms added', function () {
+ it('Test 008 : should not fire the hooker', function (done) {
list_platforms.and.returnValue([]);
- Q().then(cordova.build).then(function() {
+ Q().then(cordova.build).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>`.'
);
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/cordova/compile.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova/compile.spec.js b/spec/cordova/compile.spec.js
index 425e4f0..e090fb6 100644
--- a/spec/cordova/compile.spec.js
+++ b/spec/cordova/compile.spec.js
@@ -16,120 +16,130 @@
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'),
- util = require('../../src/cordova/util'),
- Q = require('q');
+var cordova = require('../../src/cordova/cordova');
+var platforms = require('../../src/platforms/platforms');
+var HooksRunner = require('../../src/hooks/HooksRunner');
+var util = require('../../src/cordova/util');
+var Q = require('q');
-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('compile command', function() {
- var is_cordova, list_platforms, fire, cd_project_root, fail, platformApi, getPlatformApi;
+describe('compile command', function () {
+ var is_cordova;
+ var list_platforms;
+ var fire;
+ var cd_project_root; // eslint-disable-line no-unused-vars
+ var fail;
+ var platformApi;
+ var getPlatformApi;
var project_dir = '/some/path';
- 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);
+ list_platforms = spyOn(util, 'listPlatforms').and.returnValue(supported_platforms);
fire = spyOn(HooksRunner.prototype, 'fire').and.returnValue(Q());
- platformApi = { build: jasmine.createSpy('build').and.returnValue(Q())};
+ platformApi = { build: jasmine.createSpy('build').and.returnValue(Q()) };
getPlatformApi = spyOn(platforms, 'getPlatformApi').and.returnValue(platformApi);
fail = function (err) { expect(err.stack).not.toBeDefined(); };
});
- 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([]);
var success = jasmine.createSpy('success');
cordova.compile()
- .then(success, function(result) {
- expect(result instanceof Error).toBe(true);
- expect('' + result).toContain('No platforms added to this project. Please use `cordova platform add <platform>`.');
- })
- .fin(function() {
- expect(success).not.toHaveBeenCalled();
- done();
- });
+ .then(success, function (result) {
+ expect(result instanceof Error).toBe(true);
+ expect('' + result).toContain('No platforms added to this project. Please use `cordova platform add <platform>`.');
+ })
+ .fin(function () {
+ expect(success).not.toHaveBeenCalled();
+ 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) {
is_cordova.and.returnValue(false);
var success = jasmine.createSpy('success');
cordova.compile()
- .then(success, function(result) {
- expect(result instanceof Error).toBe(true);
- })
- .fin(function() {
- expect(success).not.toHaveBeenCalled();
- done();
- });
+ .then(success, function (result) {
+ expect(result instanceof Error).toBe(true);
+ })
+ .fin(function () {
+ expect(success).not.toHaveBeenCalled();
+ done();
+ });
});
});
- describe('success', function() {
- it('Test 003 : should run inside a Cordova-based project with at least one added platform and shell out to build', function(done) {
- cordova.compile(['android','ios']).then(function() {
- expect(getPlatformApi).toHaveBeenCalledWith('android');
- expect(getPlatformApi).toHaveBeenCalledWith('ios');
- expect(platformApi.build).toHaveBeenCalled();
- })
- .fail(fail)
- .fin(done);
+ describe('success', function () {
+ it('Test 003 : should run inside a Cordova-based project with at least one added platform and shell out to build', function (done) {
+ cordova.compile(['android', 'ios'])
+ .then(function () {
+ expect(getPlatformApi).toHaveBeenCalledWith('android');
+ expect(getPlatformApi).toHaveBeenCalledWith('ios');
+ expect(platformApi.build).toHaveBeenCalled();
+ })
+ .fail(fail)
+ .fin(done);
});
it('Test 004 : should pass down optional parameters', function (done) {
- cordova.compile({platforms:['blackberry10'], options:{release: true}}).then(function () {
- expect(getPlatformApi).toHaveBeenCalledWith('blackberry10');
- expect(platformApi.build).toHaveBeenCalledWith({release: true});
- })
- .fail(fail)
- .fin(done);
+ cordova.compile({platforms: ['blackberry10'], options: {release: true}})
+ .then(function () {
+ expect(getPlatformApi).toHaveBeenCalledWith('blackberry10');
+ expect(platformApi.build).toHaveBeenCalledWith({release: true});
+ })
+ .fail(fail)
+ .fin(done);
});
it('Test 005 : should convert options 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.compile({platforms:['blackberry10'], options:['--release']}).then(function () {
- expect(getPlatformApi).toHaveBeenCalledWith('blackberry10');
- expect(platformApi.build).toHaveBeenCalledWith({release: true, argv: []});
- })
- .fail(fail)
- .fin(function () {
- cordova.off('warn', warnSpy);
- done();
- });
+ cordova.compile({platforms: ['blackberry10'], options: ['--release']})
+ .then(function () {
+ expect(getPlatformApi).toHaveBeenCalledWith('blackberry10');
+ expect(platformApi.build).toHaveBeenCalledWith({release: true, argv: []});
+ })
+ .fail(fail)
+ .fin(function () {
+ cordova.off('warn', warnSpy);
+ done();
+ });
});
});
- describe('hooks', function() {
- describe('when platforms are added', function() {
- it('Test 006 : should fire before hooks through the hooker module', function(done) {
- cordova.compile(['android', 'ios']).then(function() {
- expect(fire.calls.argsFor(0)).toEqual(['before_compile', {verbose: false, platforms:['android', 'ios'] , options: {}}]);
- done();
- })
- .fail(fail)
- .fin(done);
+ describe('hooks', function () {
+ describe('when platforms are added', function () {
+ it('Test 006 : should fire before hooks through the hooker module', function (done) {
+ cordova.compile(['android', 'ios'])
+ .then(function () {
+ expect(fire.calls.argsFor(0)).toEqual(['before_compile', {verbose: false, platforms: ['android', 'ios'], options: {}}]);
+ done();
+ })
+ .fail(fail)
+ .fin(done);
});
- it('Test 007 : should fire after hooks through the hooker module', function(done) {
- cordova.compile('android').then(function() {
- expect(fire.calls.argsFor(1)).toEqual(['after_compile', {verbose: false, platforms:['android'] , options: {}}]);
- done();
- })
- .fail(fail)
- .fin(done);
+ it('Test 007 : should fire after hooks through the hooker module', function (done) {
+ cordova.compile('android')
+ .then(function () {
+ expect(fire.calls.argsFor(1)).toEqual(['after_compile', {verbose: false, platforms: ['android'], options: {}}]);
+ done();
+ })
+ .fail(fail)
+ .fin(done);
});
});
- describe('with no platforms added', function() {
- it('Test 008 : should not fire the hooker', function(done) {
+ describe('with no platforms added', function () {
+ it('Test 008 : should not fire the hooker', function (done) {
list_platforms.and.returnValue([]);
- Q().then(cordova.compile).then(function() {
+ Q().then(cordova.compile).then(function () {
expect('this call').toBe('fail');
- }, function(err) {
+ }, function (err) {
expect(fire).not.toHaveBeenCalled();
expect(err.message).toContain(
'No platforms added to this project. Please use `cordova platform add <platform>`.'
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/cordova/cordova-lib.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova/cordova-lib.spec.js b/spec/cordova/cordova-lib.spec.js
index 8243d59..e8a4cca 100644
--- a/spec/cordova/cordova-lib.spec.js
+++ b/spec/cordova/cordova-lib.spec.js
@@ -17,7 +17,5 @@
under the License.
*/
-/* jshint unused:false */
-
// Verify that cordova-lib.js can be loaded
-var cordovaLib = require('../../cordova-lib');
+var cordovaLib = require('../../cordova-lib'); // eslint-disable-line no-unused-vars
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/spec/cordova/create.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova/create.spec.js b/spec/cordova/create.spec.js
index b4cb43c..0a088e1 100644
--- a/spec/cordova/create.spec.js
+++ b/spec/cordova/create.spec.js
@@ -17,13 +17,13 @@
under the License.
*/
-var helpers = require('../helpers'),
- path = require('path'),
- shell = require('shelljs'),
- Q = require('q'),
- events = require('cordova-common').events,
- ConfigParser = require('cordova-common').ConfigParser,
- cordova = require('../../src/cordova/cordova');
+var helpers = require('../helpers');
+var path = require('path');
+var shell = require('shelljs');
+var Q = require('q');
+var events = require('cordova-common').events;
+var ConfigParser = require('cordova-common').ConfigParser;
+var cordova = require('../../src/cordova/cordova');
var tmpDir = helpers.tmpDir('create_test');
var appName = 'TestBase';
@@ -38,43 +38,41 @@ var configBasic = {
}
};
-describe('cordova create checks for valid-identifier', function() {
- it('Test 001 : should reject reserved words from start of id', function(done) {
+describe('cordova create checks for valid-identifier', function () {
+ it('Test 001 : should reject reserved words from start of id', function (done) {
cordova.create('projectPath', 'int.bob', 'appName', {}, events)
- .fail(function(err) {
- expect(err.message).toBe('App id contains a reserved word, or is not a valid identifier.');
- })
- .fin(done);
+ .fail(function (err) {
+ expect(err.message).toBe('App id contains a reserved word, or is not a valid identifier.');
+ })
+ .fin(done);
});
-
- it('Test 002 : should reject reserved words from end of id', function(done) {
+
+ it('Test 002 : should reject reserved words from end of id', function (done) {
cordova.create('projectPath', 'bob.class', 'appName', {}, events)
- .fail(function(err) {
- expect(err.message).toBe('App id contains a reserved word, or is not a valid identifier.');
- })
- .fin(done);
+ .fail(function (err) {
+ expect(err.message).toBe('App id contains a reserved word, or is not a valid identifier.');
+ })
+ .fin(done);
});
});
+describe('create basic test (see more in cordova-create)', function () {
+ // this.timeout(240000);
-describe('create basic test (see more in cordova-create)', function() {
- //this.timeout(240000);
-
- beforeEach(function() {
+ beforeEach(function () {
shell.rm('-rf', project);
shell.mkdir('-p', tmpDir);
});
-
- afterEach(function() {
- process.chdir(path.join(__dirname, '..')); // Needed to rm the dir on Windows.
+ afterEach(function () {
+ process.chdir(path.join(__dirname, '..')); // Needed to rm the dir on Windows.
shell.rm('-rf', tmpDir);
});
- function checkProject() {
+ function checkProject () {
// Check if top level dirs exist.
var dirs = ['hooks', 'platforms', 'plugins', 'www'];
- dirs.forEach(function(d) {
+ dirs.forEach(function (d) {
expect(path.join(project, d)).toExist();
});
@@ -91,18 +89,18 @@ describe('create basic test (see more in cordova-create)', function() {
// expect(configXml.name()).toEqual('TestBase');
}
- var results;
- events.on('results', function(res) { results = res; });
+ var results; // eslint-disable-line no-unused-vars
+ events.on('results', function (res) { results = res; });
- it('Test 003 : should successfully run', function(done) {
+ it('Test 003 : should successfully run', function (done) {
// Call cordova create with no args, should return help.
Q()
- .then(function() {
+ .then(function () {
// Create a real project
return cordova.create(project, appId, appName, configBasic, events);
})
.then(checkProject)
- .fail(function(err) {
+ .fail(function (err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org