cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [13/50] [abbrv] cordova-lib git commit: CB-11960 : rebased, fixed async issues, and updated tests, tests 000, 005, and 007 still fail in pkgJson-restore
Date Thu, 09 Mar 2017 20:39:16 GMT
CB-11960 : rebased, fixed async issues, and updated tests, tests 000, 005, and 007 still fail
in pkgJson-restore


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/b77129a9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/b77129a9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/b77129a9

Branch: refs/heads/common-2.0.x
Commit: b77129a97687f3ca31678bb18399e40cf8697759
Parents: d7a1487
Author: audreyso <auso@adobe.com>
Authored: Wed Jan 18 10:55:59 2017 -0800
Committer: Audrey So <audreyso@apache.org>
Committed: Thu Jan 26 17:36:52 2017 -0800

----------------------------------------------------------------------
 .../spec-cordova/pkgJson-restore.spec.js        | 475 +++++++++++--------
 cordova-lib/spec-cordova/pkgJson.spec.js        |   2 +-
 cordova-lib/spec-plugman/fetch.spec.js          |   9 +-
 3 files changed, 279 insertions(+), 207 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b77129a9/cordova-lib/spec-cordova/pkgJson-restore.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/pkgJson-restore.spec.js b/cordova-lib/spec-cordova/pkgJson-restore.spec.js
index 4d5dfec..496ec32 100644
--- a/cordova-lib/spec-cordova/pkgJson-restore.spec.js
+++ b/cordova-lib/spec-cordova/pkgJson-restore.spec.js
@@ -58,15 +58,6 @@ describe('tests platform/spec restore with --save', function () {
             expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1);
         });
     }
-
-    function fullPlatformList() {
-        return cordova.raw.platform('list').then(function() {
-            var installed = results.match(/Installed platforms:\n  (.*)/);
-            expect(installed).toBeDefined();
-            expect(installed[1].indexOf(helpers.testPlatform)).toBeGreaterThan(-1);
-        });
-    }
-
     /** Test#000 will check that when a platform is added with a spec, it will 
     *   add to pkg.json with a '^' and to config.xml with a '~'. When prepare is run,
     *   pkg.json will have no change and config.xml (first char) will change from a '~' to
a '^'.
@@ -138,199 +129,6 @@ describe('tests platform/spec restore with --save', function () {
     // Cordova prepare needs extra wait time to complete.
     },30000);
 
-    /** Test#001 will add a platform to package.json with the 'save' flag.
-    *   It will remove it from platforms.json without the save flag.
-    *   After running cordova prepare, that platform should be restored in the
-    *   installed platform list in platforms.json.
-    */
-    it('Test#001 : should restore platform that has been removed from project', function(done)
{
-        var cwd = process.cwd();
-        var pkgJsonPath = path.join(cwd,'package.json');
-        delete require.cache[require.resolve(pkgJsonPath)];
-        var pkgJson;
-        var platformsFolderPath = path.join(cwd,'platforms/platforms.json');
-        var platformsJson;
-
-        emptyPlatformList().then(function() {
-            // Add the testing platform with --save.
-            return cordova.raw.platform('add', [helpers.testPlatform], {'save':true});
-        }).then(function() {
-            delete require.cache[require.resolve(pkgJsonPath)];
-            pkgJson = require(pkgJsonPath);
-            // Require platformsFolderPath
-            delete require.cache[require.resolve(platformsFolderPath)];
-            platformsJson = require(platformsFolderPath);
-            // Check the platform add was successful in package.json.
-            expect(pkgJson.cordova.platforms).toBeDefined();
-            expect(pkgJson.cordova.platforms.indexOf(helpers.testPlatform)).toBeGreaterThan(-1);
-            // Expect that "helpers.testPlatform" in the installed platform list in platforms.json
-            expect(platformsJson).toBeDefined();
-            expect(platformsJson[helpers.testPlatform]).toBeDefined();
-        }).then(fullPlatformList) // Platform should still be in platform ls.
-          .then(function() {
-            // And now remove helpers.testPlatform without --save.
-            return cordova.raw.platform('rm', [helpers.testPlatform]);
-        }).then(function() {
-            // Delete any previous caches of require(package.json) and (platforms.json)
-            delete require.cache[require.resolve(platformsFolderPath)];
-            platformsJson = require(platformsFolderPath);
-            delete require.cache[require.resolve(pkgJsonPath)];
-            pkgJson = require(pkgJsonPath);
-            // Check that the platform removed without --save is still in platforms key.
-            expect(pkgJson.cordova.platforms.indexOf(helpers.testPlatform)).toBeGreaterThan(-1);
-            // Check that the platform was removed from the platforms.json
-            expect(platformsJson[helpers.testPlatform]).toBeUndefined();
-        }).then(function() {
-            // Run cordova prepare.
-            return cordova.raw.prepare();
-        }).then(function() {
-            // Delete any previous caches of platforms.json.
-            delete require.cache[require.resolve(platformsFolderPath)];
-            platformsJson = require(platformsFolderPath);
-            // Expect "helpers.testPlatform" to be in the installed platforms list in platforms.json.
-            expect(platformsJson[helpers.testPlatform]).toBeDefined();
-        }).fail(function(err) {
-            expect(err).toBeUndefined();
-        }).fin(done);
-    // Cordova prepare needs extra wait time to complete.
-    },30000);
-
-    /** Test#002 will add two platforms to package.json with the 'save' flag.
-    *   It will remove one platform from pkg.json without the 'save' flag and remove
-    *   the other platform with the 'save' flag. After running cordova prepare, 
-    *   the platform removed with the 'save' flag should NOT be restored in platforms.json.
-    */
-    it('Test#002 : should NOT restore platform that was removed with --save', function(done)
{
-        var cwd = process.cwd();
-        var pkgJsonPath = path.join(cwd,'package.json');
-        var pkgJson;
-        var platformsFolderPath = path.join(cwd,'platforms/platforms.json');
-        var platformsJson;
-        var secondPlatformAdded = 'ios';
-    
-        emptyPlatformList().then(function() {
-            // Add the testing platform with --save.
-            return cordova.raw.platform('add', [helpers.testPlatform], {'save':true});
-        }).then(function() {
-            // Add the 'ios' platform with --save
-            return cordova.raw.platform('add',secondPlatformAdded, {'save':true});
-        }).then(function() {
-            // Delete any previous caches of require(package.json) and (platforms.json).
-            delete require.cache[require.resolve(pkgJsonPath)];
-            pkgJson = require(pkgJsonPath);
-            delete require.cache[require.resolve(platformsFolderPath)];
-            platformsJson = require(platformsFolderPath);
-            // Check the platform add of both platforms (to pkg.Json) was successful.
-            expect(pkgJson.cordova.platforms).toBeDefined();
-            expect(pkgJson.cordova.platforms.indexOf(helpers.testPlatform)).toEqual(0);
-            expect(pkgJson.cordova.platforms.indexOf(secondPlatformAdded)).toEqual(1);
-            // Expect that "helpers.testPlatform" in the installed platform list in platforms.json.
-            expect(platformsJson).toBeDefined();
-            expect(platformsJson[helpers.testPlatform]).toBeDefined();
-            expect(platformsJson[secondPlatformAdded]).toBeDefined();
-        }).then(fullPlatformList) // Platform should still be in platform ls.
-          .then(function() {
-            // Remove helpers.testPlatform with --save.
-            return cordova.raw.platform('rm', [helpers.testPlatform], {'save':true});
-        }).then(function() {
-            // Remove secondPlatformAdded without --save.
-            return cordova.raw.platform('rm', secondPlatformAdded);
-        }).then(function() {
-            // Delete any previous caches of require(package.json) and (platformsJson).
-            delete require.cache[require.resolve(platformsFolderPath)];
-            platformsJson = require(platformsFolderPath);
-            delete require.cache[require.resolve(pkgJsonPath)];
-            pkgJson = require(pkgJsonPath);
-            // Check that ONLY the platform removed without --save is still in (pkg.json)
platforms key.
-            expect(pkgJson.cordova.platforms.indexOf(secondPlatformAdded)).toEqual(0);
-            expect(pkgJson.cordova.platforms.indexOf(helpers.testPlatform)).toEqual(-1);
-            // Check that both platforms were removed from the platforms.json list.
-            expect(platformsJson[helpers.testPlatform]).toBeUndefined();
-            expect(platformsJson[secondPlatformAdded]).toBeUndefined();
-        }).then(function() {
-            // Run cordova prepare.
-            return cordova.raw.prepare();
-        }).then(function() {
-            // Delete any previous caches of platformsJson.
-            delete require.cache[require.resolve(platformsFolderPath)];
-            platformsJson = require(platformsFolderPath);
-            // Expect "helpers.testPlatform" to be in the installed platforms list in platforms.json
-            expect(platformsJson[helpers.testPlatform]).toBeUndefined();
-            // Expect 'ios' not to be in platforms.json and has not been restored.
-            expect(platformsJson[secondPlatformAdded]).toBeDefined();
-        }).fail(function(err) {
-            expect(err).toBeUndefined();
-        }).fin(done);
-    // Cordova prepare needs extra wait time to complete.
-    },30000);
-
-    /** Test#003 will add two platforms to package.json - one with the 'save' flag and one
-    *   without the 'save' flag. It will remove both platforms without a 'save' flag.
-    *   After running cordova prepare, only the platform added with the 'save' flag is restored
-    *   in platforms.json.
-    */
-    it('Test#003 : should NOT restore platform that was not saved and removed', function(done)
{
-        var cwd = process.cwd();
-        var pkgJsonPath = path.join(cwd,'package.json');
-        var pkgJson;
-        var platformsFolderPath = path.join(cwd,'platforms/platforms.json');
-        var secondPlatformAdded = 'ios';
-        var platformsJson;
-
-        emptyPlatformList().then(function() {
-            // Add 'ios' platform to project without --save
-            return cordova.raw.platform('add', secondPlatformAdded);
-        }).then(function() {
-            // Add helpers.testPlatform to project with --save
-            return cordova.raw.platform('add', [helpers.testPlatform], {'save':true});
-        }).then(function() {
-            // Delete any previous caches of require(package.json) and (platformsJson)
-            delete require.cache[require.resolve(pkgJsonPath)];
-            pkgJson = require(pkgJsonPath);
-            delete require.cache[require.resolve(platformsFolderPath)];
-            platformsJson = require(platformsFolderPath);
-            // Check the platform add of only helpers.testPlatform was successful in package.json.
-            expect(pkgJson.cordova.platforms).toBeDefined();
-            expect(pkgJson.cordova.platforms.indexOf(helpers.testPlatform)).toBeGreaterThan(-1);
-            expect(pkgJson.cordova.platforms.indexOf(secondPlatformAdded)).toEqual(-1);
-            // Expect both platforms to be installed platform list in platforms.json
-            expect(platformsJson[helpers.testPlatform]).toBeDefined();
-            expect(platformsJson[secondPlatformAdded]).toBeDefined();
-        }).then(fullPlatformList) // Platforms should still be in platform ls.
-          .then(function() {
-            // Remove helpers.testPlatform without --save.
-            return cordova.raw.platform('rm', [helpers.testPlatform]);
-        }).then(function() {
-            // Remove secondPlatformAdded without --save.
-            return cordova.raw.platform('rm', secondPlatformAdded);
-        }).then(function() {
-            // Delete any previous caches of require(pkgJson) and (platformsJson)
-            delete require.cache[require.resolve(platformsFolderPath)];
-            platformsJson = require(platformsFolderPath);
-            delete require.cache[require.resolve(pkgJsonPath)];
-            pkgJson = require(pkgJsonPath);
-            // Check that the platform that was added with --save is still in package.json.
-            expect(pkgJson.cordova.platforms.indexOf(helpers.testPlatform)).toBeGreaterThan(-1);
-            // Check that both platforms were removed from the platforms.json.
-            expect(platformsJson[secondPlatformAdded]).toBeUndefined();
-            expect(platformsJson[helpers.testPlatform]).toBeUndefined();
-        }).then(function() {
-            // Run cordova prepare
-            return cordova.raw.prepare();
-        }).then(function() {
-            // Delete any previous caches of platformsJson
-            delete require.cache[require.resolve(platformsFolderPath)];
-            platformsJson = require(platformsFolderPath);
-            // Expect "helpers.testPlatform" to be in the installed platforms list.
-            expect(platformsJson[helpers.testPlatform]).toBeDefined();
-            // Expect that 'ios' will not be in platforms.json and has not been restored.
-            expect(platformsJson[secondPlatformAdded]).toBeUndefined();
-        }).fail(function(err) {
-            expect(err).toBeUndefined();
-        }).fin(done);
-    // Cordova prepare needs extra wait time to complete.
-    },30000);
-
     /** Test#017
     *   When platform is added with url and fetch and restored with fetch, 
     *   pkg.json and config.xml would add it to their files properly.
@@ -490,6 +288,112 @@ describe('tests platform/spec restore with --save', function () {
     },30000);
 });
 
+// Use basePkgJson
+describe('tests platform/spec restore with --save', function () {
+    var tmpDir = helpers.tmpDir('platform_test_pkgjson2');
+    var project = path.join(tmpDir, 'project');
+    var results;
+
+    beforeEach(function() {
+        shell.rm('-rf', tmpDir);
+        // Copy then move because we need to copy everything, but that means it will copy
the whole directory.
+        // Using /* doesn't work because of hidden files.
+        shell.cp('-R', path.join(__dirname, 'fixtures', 'basePkgJson'), tmpDir);
+        shell.mv(path.join(tmpDir, 'basePkgJson'), project);
+        process.chdir(project);
+        events.on('results', function(res) { results = res; });
+    });
+
+    afterEach(function() {
+        delete require.cache[require.resolve(path.join(process.cwd(),'package.json'))];
+        process.chdir(path.join(__dirname, '..'));  // Needed to rm the dir on Windows.
+        shell.rm('-rf', tmpDir);
+    });
+
+    // Factoring out some repeated checks.
+    function emptyPlatformList() {
+        return cordova.raw.platform('list').then(function() {
+            var installed = results.match(/Installed platforms:\n  (.*)/);
+            expect(installed).toBeDefined();
+            expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1);
+        });
+    }
+
+    function fullPlatformList() {
+        return cordova.raw.platform('list').then(function() {
+            var installed = results.match(/Installed platforms:\n  (.*)/);
+            expect(installed).toBeDefined();
+            expect(installed[1].indexOf(helpers.testPlatform)).toBeGreaterThan(-1);
+        });
+    }
+    /** Test#003 will add two platforms to package.json - one with the 'save' flag and one
+    *   without the 'save' flag. It will remove both platforms without a 'save' flag.
+    *   After running cordova prepare, only the platform added with the 'save' flag is restored
+    *   in platforms.json.
+    */
+    it('Test#003 : should NOT restore platform that was not saved and removed', function(done)
{
+        var cwd = process.cwd();
+        var pkgJsonPath = path.join(cwd,'package.json');
+        var pkgJson;
+        var platformsFolderPath = path.join(cwd,'platforms/platforms.json');
+        var secondPlatformAdded = 'ios';
+        var platformsJson;
+
+        emptyPlatformList().then(function() {
+            // Add 'ios' platform to project without --save
+            return cordova.raw.platform('add', secondPlatformAdded);
+        }).then(function() {
+            // Add helpers.testPlatform to project with --save
+            return cordova.raw.platform('add', [helpers.testPlatform], {'save':true});
+        }).then(function() {
+            // Delete any previous caches of require(package.json) and (platformsJson)
+            delete require.cache[require.resolve(pkgJsonPath)];
+            pkgJson = require(pkgJsonPath);
+            delete require.cache[require.resolve(platformsFolderPath)];
+            platformsJson = require(platformsFolderPath);
+            // Check the platform add of only helpers.testPlatform was successful in package.json.
+            expect(pkgJson.cordova.platforms).toBeDefined();
+            expect(pkgJson.cordova.platforms.indexOf(helpers.testPlatform)).toBeGreaterThan(-1);
+            expect(pkgJson.cordova.platforms.indexOf(secondPlatformAdded)).toEqual(-1);
+            // Expect both platforms to be installed platform list in platforms.json
+            expect(platformsJson[helpers.testPlatform]).toBeDefined();
+            expect(platformsJson[secondPlatformAdded]).toBeDefined();
+        }).then(fullPlatformList) // Platforms should still be in platform ls.
+          .then(function() {
+            // Remove helpers.testPlatform without --save.
+            return cordova.raw.platform('rm', [helpers.testPlatform]);
+        }).then(function() {
+            // Remove secondPlatformAdded without --save.
+            return cordova.raw.platform('rm', secondPlatformAdded);
+        }).then(function() {
+            // Delete any previous caches of require(pkgJson) and (platformsJson)
+            delete require.cache[require.resolve(platformsFolderPath)];
+            platformsJson = require(platformsFolderPath);
+            delete require.cache[require.resolve(pkgJsonPath)];
+            pkgJson = require(pkgJsonPath);
+            // Check that the platform that was added with --save is still in package.json.
+            expect(pkgJson.cordova.platforms.indexOf(helpers.testPlatform)).toBeGreaterThan(-1);
+            // Check that both platforms were removed from the platforms.json.
+            expect(platformsJson[secondPlatformAdded]).toBeUndefined();
+            expect(platformsJson[helpers.testPlatform]).toBeUndefined();
+        }).then(function() {
+            // Run cordova prepare
+            return cordova.raw.prepare();
+        }).then(function() {
+            // Delete any previous caches of platformsJson
+            delete require.cache[require.resolve(platformsFolderPath)];
+            platformsJson = require(platformsFolderPath);
+            // Expect "helpers.testPlatform" to be in the installed platforms list.
+            expect(platformsJson[helpers.testPlatform]).toBeDefined();
+            // Expect that 'ios' will not be in platforms.json and has not been restored.
+            expect(platformsJson[secondPlatformAdded]).toBeUndefined();
+        }).fail(function(err) {
+            expect(err).toBeUndefined();
+        }).fin(done);
+    // Cordova prepare needs extra wait time to complete.
+    },30000);
+});
+
 // Use basePkgJson6 because pkg.json and config.xml contain only android
 describe('files should not be modified if their platforms are identical', function () {
     var tmpDir = helpers.tmpDir('platform_test_pkgjson');
@@ -693,7 +597,7 @@ describe('update empty package.json to match config.xml', function ()
{
             return elem.name;
         });
         var configEngArray = engNames.slice();
-    
+
         // Expect that pkg.json exists without a cordova key.
         expect(pkgJson).toBeDefined();
         expect(pkgJson.cordova).toBeUndefined();
@@ -1496,3 +1400,168 @@ describe('platforms and plugins should be restored with config.xml
even without
 });
 
 
+// Use basePkgJson
+describe('tests platform/spec restore with --save', function () {
+    var tmpDir = helpers.tmpDir('platform_test_pkgjson2');
+    var project = path.join(tmpDir, 'project');
+    var results;
+
+    beforeEach(function() {
+        shell.rm('-rf', tmpDir);
+        // Copy then move because we need to copy everything, but that means it will copy
the whole directory.
+        // Using /* doesn't work because of hidden files.
+        shell.cp('-R', path.join(__dirname, 'fixtures', 'basePkgJson'), tmpDir);
+        shell.mv(path.join(tmpDir, 'basePkgJson'), project);
+        process.chdir(project);
+        events.on('results', function(res) { results = res; });
+    });
+
+    afterEach(function() {
+        delete require.cache[require.resolve(path.join(process.cwd(),'package.json'))];
+        process.chdir(path.join(__dirname, '..'));  // Needed to rm the dir on Windows.
+        shell.rm('-rf', tmpDir);
+    });
+
+    // Factoring out some repeated checks.
+    function emptyPlatformList() {
+        return cordova.raw.platform('list').then(function() {
+            var installed = results.match(/Installed platforms:\n  (.*)/);
+            expect(installed).toBeDefined();
+            expect(installed[1].indexOf(helpers.testPlatform)).toBe(-1);
+        });
+    }
+
+    function fullPlatformList() {
+        return cordova.raw.platform('list').then(function() {
+            var installed = results.match(/Installed platforms:\n  (.*)/);
+            expect(installed).toBeDefined();
+            expect(installed[1].indexOf(helpers.testPlatform)).toBeGreaterThan(-1);
+        });
+    }
+
+    /** Test#001 will add a platform to package.json with the 'save' flag.
+    *   It will remove it from platforms.json without the save flag.
+    *   After running cordova prepare, that platform should be restored in the
+    *   installed platform list in platforms.json.
+    */
+    it('Test#001 : should restore platform that has been removed from project', function(done)
{
+        var cwd = process.cwd();
+        var pkgJsonPath = path.join(cwd,'package.json');
+        delete require.cache[require.resolve(pkgJsonPath)];
+        var pkgJson;
+        var platformsFolderPath = path.join(cwd,'platforms/platforms.json');
+        var platformsJson;
+
+        emptyPlatformList().then(function() {
+            // Add the testing platform with --save.
+            return cordova.raw.platform('add', 'android', {'save':true});
+        }).then(function() {
+            delete require.cache[require.resolve(pkgJsonPath)];
+            pkgJson = require(pkgJsonPath);
+            // Require platformsFolderPath
+            delete require.cache[require.resolve(platformsFolderPath)];
+            platformsJson = require(platformsFolderPath);
+            // Check the platform add was successful in package.json.
+            expect(pkgJson.cordova.platforms).toBeDefined();
+            expect(pkgJson.cordova.platforms.indexOf(helpers.testPlatform)).toBeGreaterThan(-1);
+            // Expect that "helpers.testPlatform" in the installed platform list in platforms.json
+            expect(platformsJson).toBeDefined();
+            expect(platformsJson[helpers.testPlatform]).toBeDefined();
+        }).then(fullPlatformList) // Platform should still be in platform ls.
+          .then(function() {
+            // And now remove helpers.testPlatform without --save.
+            return cordova.raw.platform('rm', [helpers.testPlatform]);
+        }).then(function() {
+            // Delete any previous caches of require(package.json) and (platforms.json)
+            delete require.cache[require.resolve(platformsFolderPath)];
+            platformsJson = require(platformsFolderPath);
+            delete require.cache[require.resolve(pkgJsonPath)];
+            pkgJson = require(pkgJsonPath);
+            // Check that the platform removed without --save is still in platforms key.
+            expect(pkgJson.cordova.platforms.indexOf(helpers.testPlatform)).toBeGreaterThan(-1);
+            // Check that the platform was removed from the platforms.json
+            expect(platformsJson[helpers.testPlatform]).toBeUndefined();
+        }).then(function() {
+            // Run cordova prepare.
+            return cordova.raw.prepare();
+        }).then(function() {
+            // Delete any previous caches of platforms.json.
+            delete require.cache[require.resolve(platformsFolderPath)];
+            platformsJson = require(platformsFolderPath);
+            // Expect "helpers.testPlatform" to be in the installed platforms list in platforms.json.
+            expect(platformsJson[helpers.testPlatform]).toBeDefined();
+        }).fail(function(err) {
+            expect(err).toBeUndefined();
+        }).fin(done);
+    // Cordova prepare needs extra wait time to complete.
+    },30000);
+
+    /** Test#002 will add two platforms to package.json with the 'save' flag.
+    *   It will remove one platform from pkg.json without the 'save' flag and remove
+    *   the other platform with the 'save' flag. After running cordova prepare, 
+    *   the platform removed with the 'save' flag should NOT be restored in platforms.json.
+    */
+    it('Test#002 : should NOT restore platform that was removed with --save', function(done)
{
+        var cwd = process.cwd();
+        var pkgJsonPath = path.join(cwd,'package.json');
+        var pkgJson;
+        var platformsFolderPath = path.join(cwd,'platforms/platforms.json');
+        var platformsJson;
+        var secondPlatformAdded = 'ios';
+    
+        emptyPlatformList().then(function() {
+            // Add the testing platform with --save.
+            return cordova.raw.platform('add', [helpers.testPlatform], {'save':true});
+        }).then(function() {
+            // Add the 'ios' platform with --save
+            return cordova.raw.platform('add',secondPlatformAdded, {'save':true});
+        }).then(function() {
+            // Delete any previous caches of require(package.json) and (platforms.json).
+            delete require.cache[require.resolve(pkgJsonPath)];
+            pkgJson = require(pkgJsonPath);
+            delete require.cache[require.resolve(platformsFolderPath)];
+            platformsJson = require(platformsFolderPath);
+            // Check the platform add of both platforms (to pkg.Json) was successful.
+            expect(pkgJson.cordova.platforms).toBeDefined();
+            expect(pkgJson.cordova.platforms.indexOf(helpers.testPlatform)).toEqual(0);
+            expect(pkgJson.cordova.platforms.indexOf(secondPlatformAdded)).toEqual(1);
+            // Expect that "helpers.testPlatform" in the installed platform list in platforms.json.
+            expect(platformsJson).toBeDefined();
+            expect(platformsJson[helpers.testPlatform]).toBeDefined();
+            expect(platformsJson[secondPlatformAdded]).toBeDefined();
+        }).then(fullPlatformList) // Platform should still be in platform ls.
+          .then(function() {
+            // Remove helpers.testPlatform with --save.
+            return cordova.raw.platform('rm', [helpers.testPlatform], {'save':true});
+        }).then(function() {
+            // Remove secondPlatformAdded without --save.
+            return cordova.raw.platform('rm', secondPlatformAdded);
+        }).then(function() {
+            // Delete any previous caches of require(package.json) and (platformsJson).
+            delete require.cache[require.resolve(platformsFolderPath)];
+            platformsJson = require(platformsFolderPath);
+            delete require.cache[require.resolve(pkgJsonPath)];
+            pkgJson = require(pkgJsonPath);
+            // Check that ONLY the platform removed without --save is still in (pkg.json)
platforms key.
+            expect(pkgJson.cordova.platforms.indexOf(secondPlatformAdded)).toEqual(0);
+            expect(pkgJson.cordova.platforms.indexOf(helpers.testPlatform)).toEqual(-1);
+            // Check that both platforms were removed from the platforms.json list.
+            expect(platformsJson[helpers.testPlatform]).toBeUndefined();
+            expect(platformsJson[secondPlatformAdded]).toBeUndefined();
+        }).then(function() {
+            // Run cordova prepare.
+            return cordova.raw.prepare();
+        }).then(function() {
+            // Delete any previous caches of platformsJson.
+            delete require.cache[require.resolve(platformsFolderPath)];
+            platformsJson = require(platformsFolderPath);
+            // Expect "helpers.testPlatform" to be in the installed platforms list in platforms.json
+            expect(platformsJson[helpers.testPlatform]).toBeUndefined();
+            // Expect 'ios' not to be in platforms.json and has not been restored.
+            expect(platformsJson[secondPlatformAdded]).toBeDefined();
+        }).fail(function(err) {
+            expect(err).toBeUndefined();
+        }).fin(done);
+    // Cordova prepare needs extra wait time to complete.
+    },30000);
+});

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b77129a9/cordova-lib/spec-cordova/pkgJson.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/pkgJson.spec.js b/cordova-lib/spec-cordova/pkgJson.spec.js
index 3920c1a..654fb1d 100644
--- a/cordova-lib/spec-cordova/pkgJson.spec.js
+++ b/cordova-lib/spec-cordova/pkgJson.spec.js
@@ -393,7 +393,7 @@ describe('platform end-to-end with --save', function () {
         // Check there are no platforms yet.
         emptyPlatformList().then(function() {
             // Add the testing platform with --save and add specific version to android platform.
-            return cordova.raw.platform('add', ['android@6.1.0', 'ios'], {'save':true, 'fetch':true});
+            return cordova.raw.platform('add', ['android@6.1.0', 'ios@4.3.0'], {'save':true,
'fetch':true});
         }).then(function() {
             // Delete any previous caches of require(package.json).
             delete require.cache[require.resolve(pkgJsonPath)];

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b77129a9/cordova-lib/spec-plugman/fetch.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/fetch.spec.js b/cordova-lib/spec-plugman/fetch.spec.js
index 10e93c4..ce72895 100644
--- a/cordova-lib/spec-plugman/fetch.spec.js
+++ b/cordova-lib/spec-plugman/fetch.spec.js
@@ -214,20 +214,23 @@ describe('fetch', 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();
             });
-        });
+        }, 20000);
         // 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() {
                 expect(1).toBe(1);
+                done();
             });
-        });
+        }, 20000);
         // 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() {
                 expect(1).toBe(1);
+                done();
             });
-        });
+        }, 20000);
     });
 
     describe('fetch recursive error CB-8809', function(){


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message