Github user omefire commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/246#discussion_r32539540
  
    --- Diff: cordova-lib/spec-cordova/save.spec.js ---
    @@ -0,0 +1,435 @@
    +/**
    +    Licensed to the Apache Software Foundation (ASF) under one
    +    or more contributor license agreements.  See the NOTICE file
    +    distributed with this work for additional information
    +    regarding copyright ownership.  The ASF licenses this file
    +    to you under the Apache License, Version 2.0 (the
    +    "License"); you may not use this file except in compliance
    +    with the License.  You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +    Unless required by applicable law or agreed to in writing,
    +    software distributed under the License is distributed on an
    +    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +    KIND, either express or implied.  See the License for the
    +    specific language governing permissions and limitations
    +    under the License.
    +*/
    +
    +describe('(save flag)', function () {
    +    var rewire      = require('rewire'),
    +        cordova     = require('../src/cordova/cordova'),
    +        helpers     = require('./helpers'),
    +        path        = require('path'),
    +        Q           = require('q'),
    +        fs          = require('fs'),
    +        shell       = require('shelljs'),
    +        util        = require('../src/cordova/util'),
    +        platform    = rewire('../src/cordova/platform.js');
    +
    +    var appName             = 'testApp',
    +        tempPath            = path.join(__dirname, 'temp'),
    +        appPath             = path.join(tempPath, appName),
    +        platformName        = helpers.testPlatform,
    +        platformVersionOld  = '4.0.0',
    +        platformVersionNew  = '4.0.1',
    +        platformLocalPath   = path.join(tempPath, 'cordova-' + 
platformName),
    +        platformGitUrl      = 'https://github.com/apache/cordova-' + 
platformName,
    +        platformGitRef      = '4.0.x',
    +        platformTgzUrl      = 
'https://git-wip-us.apache.org/repos/asf?p=cordova-' + platformName + 
'.git;a=snapshot;h=' + platformVersionNew + ';sf=tgz',
    +        pluginName          = 'cordova-plugin-console',
    +        pluginVersion       = '1.0.0',
    +        pluginGitUrl        = 
'https://github.com/apache/cordova-plugin-console.git',
    +        pluginOldName       = 'org.apache.cordova.console',
    +        pluginOldVersion    = '0.2.11',
    +        variablePluginName  = 'com.phonegap.plugins.facebookconnect',
    +        variablePluginUrl   = 
'https://github.com/Wizcorp/phonegap-facebook-plugin',
    +        localPluginName     = 'org.apache.cordova.fakeplugin1',
    +        localPluginPath     = path.join(__dirname, 'fixtures', 'plugins', 
'fake1'),
    +        timeout             = 60 * 1000;
    +
    +    //mocks
    +    var is_cordova, cd_project_root, prepare,
    +        revert_copy_cordova_js, revert_copy_cordovajs_src, 
revert_install_plugins_for_new_platform;
    +
    +    beforeEach(function (done) {
    +        is_cordova = spyOn(util, 'isCordova').andReturn(appPath);
    +        cd_project_root = spyOn(util, 'cdProjectRoot').andReturn(appPath);
    +        prepare = spyOn(cordova.raw, 'prepare').andReturn(Q());
    +
    +        fs.exists(appPath, function (exists) {
    +            if (exists) {
    +                cordova.raw.platform('rm', platformName).then(done, done);
    +            } else {
    +                done();
    +            }
    +        });
    +    });
    +
    +    describe('(preparing fixtures)', function () {
    +        it('preparing temp dir', function () {
    +            shell.rm('-rf', tempPath);
    +            shell.mkdir(tempPath);
    +        });
    +
    +        it('creating mocks', function () {
    +            revert_copy_cordova_js = platform.__set__('copy_cordova_js', 
function () {});
    +            revert_copy_cordovajs_src = 
platform.__set__('copy_cordovajs_src', function () {});
    +            revert_install_plugins_for_new_platform = 
platform.__set__('installPluginsForNewPlatform', function () { return Q(); });
    +        });
    +
    +        it('creating test app', function (done) {
    +            cordova.raw.create(appPath, undefined, undefined, 
{}).then(function () {
    +                //removing unnecessary whitelist plugin from config
    +                helpers.removePlugin(appPath, 'cordova-plugin-whitelist');
    +                done();
    +            }, function (err) {
    +                expect(true).toBe(false);
    +                console.log(err);
    +                done();
    +            });
    +        });
    +
    +        it('cloning platform', function (done) {
    +            shell.exec('git clone ' + platformGitUrl + ' --depth 1 ' + 
platformLocalPath, { silent: true }, function (err) {
    +                expect(err).toBe(0);
    +                done();
    +            });
    +        }, timeout);
    +    });
    +
    +    describe('(platform add)', function () {
    +        it('spec.1 cusom tgz support: cordova platform add 
android@url_to_tgz', function (done) {
    +            helpers.removeEngine(appPath);
    +            platform('add', platformName + '@' + platformTgzUrl, { 'save': 
true })
    +            .then(function () {
    +                
expect(helpers.getEngineSpec(appPath)).toBe(platformTgzUrl);
    +                done();
    +            }).catch(function (err) {
    +                console.log(err);
    +                expect(false).toBe(true);
    +                done();
    +            });
    +        }, timeout);
    +
    +        it('spec.2 cordova platform add android --save [empty 
config.xml]', function (done) {
    +            helpers.removeEngine(appPath);
    +            platform('add', platformName, { 'save': true })
    +            .then(function () {
    +                expect(helpers.getEngineSpec(appPath)).not.toBe(null);
    +                done();
    +            }).catch(function (err) {
    +                console.log(err);
    +                expect(false).toBe(true);
    +                done();
    +            });
    +        }, timeout);
    +
    +        it('spec.3 cordova platform add android --save [config.xml already 
contains android@4.0.0]', function (done) {
    +            helpers.setEngineSpec(appPath, platformVersionOld);
    +            platform('add', platformName, { 'save': true })
    +            .then(function () {
    +                expect(helpers.getEngineSpec(appPath)).toBe('^' + 
platformVersionOld);
    +                done();
    +            }).catch(function (err) {
    +                console.log(err);
    +                expect(false).toBe(true);
    +                done();
    +            });
    +        }, timeout);
    +
    +        it('spec.4 cordova platform add android --save [config.xml 
contains android@file://C:/path/to/android]', function (done) {
    +            helpers.setEngineSpec(appPath, platformLocalPath);
    +            platform('add', platformName, { 'save': true })
    +            .then(function () {
    +                
expect(helpers.getEngineSpec(appPath)).toBe(platformLocalPath);
    +                done();
    +            }).catch(function (err) {
    +                console.log(err);
    +                expect(false).toBe(true);
    +                done();
    +            });
    +        }, timeout);
    +
    +        it('spec.5 cordova platform add android@3.969.696 --save [invalid 
version => should fail and should not update config.xml]', function (done) {
    +            helpers.removeEngine(appPath);
    +            platform('add', helpers.testPlatform + '@3.969.696', { 'save': 
true })
    +            .then(function () {
    +                expect(false).toBe(true);
    +                done();
    +            }).catch(function (err) {
    +                expect(err.message.indexOf('version not found') >= 
0).toBe(true);
    +                expect(helpers.getEngineSpec(appPath)).toBe(null);
    +                done();
    +            });
    +        });
    +
    +        it('spec.6 cordova platform add C://path/to/android/platform 
--save', function (done) {
    +            helpers.removeEngine(appPath);
    +            platform('add', platformLocalPath, { 'save': true })
    +            .then(function () {
    +                
expect(helpers.getEngineSpec(appPath)).toBe(platformLocalPath);
    +                done();
    +            }).catch(function (err) {
    +                console.log(err);
    +                expect(false).toBe(true);
    +                done();
    +            });
    +        }, timeout);
    +
    +        it('spec.7 should support cordova platform add 
https://github.com/apache/cordova-android.git#4.0.x', function (done) {
    +            var platformUrl = platformGitUrl + '#' + platformGitRef;
    +            helpers.removeEngine(appPath);
    +            platform('add', platformUrl, { 'save': true })
    +            .then(function () {
    +                expect(helpers.getEngineSpec(appPath)).toBe(platformUrl);
    +                done();
    +            }).catch(function (err) {
    +                console.log(err);
    +                expect(false).toBe(true);
    +                done();
    +            });
    +        }, timeout);
    +    });
    +
    +    describe('(platform remove)', function () {
    +        it('spec.8 cordova platform remove android --save [config.xml is 
empty]', function (done) {
    +            helpers.removeEngine(appPath);
    +            platform('add', platformLocalPath)
    +            .then(function () {
    +                return cordova.raw.platform('rm', platformName, { 'save': 
true });
    +            }).then(function () {
    +                expect(helpers.getEngineSpec(appPath)).toBe(null);
    +                done();
    +            }).catch(function (err) {
    +                console.log(err);
    +                expect(false).toBe(true);
    +                done();
    +            });
    +        }, timeout);
    +
    +        it('spec.9 cordova platform remove android --save [config.xml 
contains android@C:/path/to/android/platform]', function (done) {
    +            helpers.setEngineSpec(appPath, platformLocalPath);
    +            platform('add', platformLocalPath)
    +            .then(function () {
    +                return cordova.raw.platform('rm', platformName, { 'save': 
true });
    +            }).then(function () {
    +                expect(helpers.getEngineSpec(appPath)).toBe(null);
    +                done();
    +            }).catch(function (err) {
    +                console.log(err);
    +                expect(false).toBe(true);
    +                done();
    +            });
    +        }, timeout);
    +    });
    +
    +    describe('(platform update)', function () {
    +        it('spec. 10 cordova platform update android@4.0.0  --save 
[config.xml already contains android@4.0.1]', function (done) {
    +            helpers.setEngineSpec(appPath, platformVersionNew);
    +            platform('add', platformName + '@' + platformVersionNew)
    +            .then(function () {
    +                return cordova.raw.platform('update', platformName + '@' + 
platformVersionOld, { 'save': true });
    +            }).then(function () {
    +                expect(helpers.getEngineSpec(appPath)).toBe('^' + 
platformVersionOld);
    +                done();
    +            }).catch(function (err) {
    +                console.log(err);
    +                expect(false).toBe(true);
    +                done();
    +            });
    +        }, timeout);
    +
    +        it('spec.11 support for git-urls: cordova platform update 
https://github.com/apache/cordova-android.git –save', function (done) {
    +            helpers.setEngineSpec(appPath, platformVersionNew);
    +            platform('add', platformName + '@' + platformVersionNew)
    +            .then(function () {
    +                return cordova.raw.platform('update', platformGitUrl, { 
'save': true });
    +            }).then(function () {
    +                expect(helpers.getEngineSpec(appPath)).not.toBe(null);
    +                
expect(helpers.getEngineSpec(appPath)).not.toBe(platformVersionNew);
    +                done();
    +            }).catch(function (err) {
    +                console.log(err);
    +                expect(false).toBe(true);
    +                done();
    +            });
    +        }, timeout);
    +    });
    +
    +    describe('(plugin add)', function () {
    +        beforeEach(function (done) {
    +            cordova.raw.plugin('rm', [ pluginName, pluginOldName, 
variablePluginName, localPluginName ])
    +            .finally(function () {
    +                helpers.removePlugin(appPath, pluginName);
    +                helpers.removePlugin(appPath, pluginOldName);
    +                helpers.removePlugin(appPath, variablePluginName);
    +                helpers.removePlugin(appPath, localPluginName);
    +                done();
    +            });
    +        });
    +
    +        it('spec.12 cordova plugin add cordova-plugin-console –-save 
[config.xml empty]', function (done) {
    +            platform('add', platformLocalPath)
    +            .then(function () {
    +                return cordova.raw.plugin('add', pluginName, { 'save': 
true });
    +            }).then(function () {
    +                expect(helpers.getPluginSpec(appPath, 
pluginName)).not.toBe(null);
    +                done();
    +            }).catch(function (err) {
    +                expect(true).toBe(false);
    +                console.log(err.message);
    +                done();
    +            });
    +        }, timeout);
    +
    +        it('spec.13 cordova plugin add cordova-plugin-console –-save 
[config.xml already contains cordova-plugin-console@0.2.11]', function (done) {
    +            platform('add', platformLocalPath)
    +            .then(function () {
    +                helpers.setPluginSpec(appPath, pluginName, 
pluginOldVersion);
    +                return cordova.raw.plugin('add', pluginName, { 'save': 
true });
    +            }).then(function () {
    +                expect(helpers.getPluginSpec(appPath, 
pluginOldName)).toBe('^' + pluginOldVersion);
    +                done();
    +            }).catch(function (err) {
    +                expect(true).toBe(false);
    +                console.log(err.message);
    +                done();
    +            });
    +        }, timeout);
    +
    +        it('spec.14 cordova plugin add facebook-plugins –-variables … 
-–save [testing variables support]', function (done) {
    +            platform('add', platformLocalPath)
    +            .then(function () {
    +                return cordova.raw.plugin('add', variablePluginUrl, {
    +                    'save': true,
    +                    'cli_variables': {
    +                        'APP_ID':'123456789',
    +                        'APP_NAME':'myApplication'
    +                    }
    +                });
    +            }).then(function () {
    +                expect(helpers.getPluginVariable(appPath, 
variablePluginName, 'APP_ID')).toBe('123456789');
    +                expect(helpers.getPluginVariable(appPath, 
variablePluginName, 'APP_NAME')).toBe('myApplication');
    +                done();
    +            }).catch(function (err) {
    +                expect(true).toBe(false);
    +                console.log(err.message);
    +                done();
    +            });
    +        }, timeout);
    +
    +        it('spec.15 cordova plugin add git_url --save', function (done) {
    +            platform('add', platformLocalPath)
    +            .then(function () {
    +                return cordova.raw.plugin('add', pluginGitUrl, { 'save': 
true });
    +            }).then(function () {
    +                expect(helpers.getPluginSpec(appPath, 
pluginName)).toBe(pluginGitUrl);
    +                done();
    +            }).catch(function (err) {
    +                expect(true).toBe(false);
    +                console.log(err.message);
    +                done();
    +            });
    +        }, timeout);
    +
    +        it('spec.16 cordova plugin add local_folder --save', function 
(done) {
    +            platform('add', platformLocalPath)
    +            .then(function () {
    +                return cordova.raw.plugin('add', localPluginPath, { 
'save': true });
    +            }).then(function () {
    +                expect(helpers.getPluginSpec(appPath, 
localPluginName)).toBe(localPluginPath);
    +                done();
    +            }).catch(function (err) {
    +                expect(true).toBe(false);
    +                console.log(err.message);
    +                done();
    +            });
    +        }, timeout);
    +    });
    +
    +    describe('(plugin remove)', function () {
    +        it('spec.17 cordova plugin remove plugin-id --save [config.xml is 
empty]', function (done) {
    +            platform('add', platformLocalPath)
    +            .then(function () {
    +                return cordova.raw.plugin('add', pluginName);
    +            }).then(function () {
    +                return cordova.raw.plugin('rm', pluginName, { 'save': true 
});
    +            }).then(function () {
    +                expect(helpers.getPluginSpec(appPath, 
pluginName)).toBe(null);
    +                done();
    +            }).catch(function (err) {
    +                expect(true).toBe(false);
    +                console.log(err.message);
    +                done();
    +            });
    +        }, timeout);
    +
    +        it('spec.18 cordova plugin remove plugin-id --save [config.xml 
contains git-url of plugin]', function (done) {
    +            platform('add', platformLocalPath)
    +            .then(function () {
    +                return cordova.raw.plugin('add', pluginName);
    +            }).then(function () {
    +                helpers.setPluginSpec(appPath, pluginName, pluginGitUrl);
    +                return cordova.raw.plugin('rm', pluginName, { 'save': true 
});
    +            }).then(function () {
    +                expect(helpers.getPluginSpec(appPath, 
pluginName)).toBe(null);
    +                done();
    +            }).catch(function (err) {
    +                expect(true).toBe(false);
    +                console.log(err.message);
    +                done();
    +            });
    +        }, timeout);
    +    });
    +
    +    describe('plugin update', function () {
    +        //plugin update functionality is not yet implemented in cordova-cli
    +        xit('spec.19 cordova plugin update cordova-plugin-console --save', 
function (done) {
    --- End diff --
    
    That's because there's no 'cordova plugin update' functionality. Please, 
delete those tests.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org

Reply via email to