Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2BD89200CAE for ; Wed, 7 Jun 2017 06:59:25 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 27AFE160C0A; Wed, 7 Jun 2017 04:59:25 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 014E8160BE2 for ; Wed, 7 Jun 2017 06:59:21 +0200 (CEST) Received: (qmail 79100 invoked by uid 500); 7 Jun 2017 04:59:21 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 78829 invoked by uid 99); 7 Jun 2017 04:59:20 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jun 2017 04:59:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AEE03DFF9F; Wed, 7 Jun 2017 04:59:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: steven@apache.org To: commits@cordova.apache.org Date: Wed, 07 Jun 2017 04:59:23 -0000 Message-Id: In-Reply-To: <8af46fa5d2194d7d8675d497cb3a11c3@git.apache.org> References: <8af46fa5d2194d7d8675d497cb3a11c3@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [04/51] [partial] cordova-lib git commit: CB-11980: removed fetch, common and serve into their own repos archived-at: Wed, 07 Jun 2017 04:59:25 -0000 http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/fc72293c/cordova-lib/spec-cordova/save.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-cordova/save.spec.js b/cordova-lib/spec-cordova/save.spec.js deleted file mode 100644 index 1af7d66..0000000 --- a/cordova-lib/spec-cordova/save.spec.js +++ /dev/null @@ -1,700 +0,0 @@ -/** - 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'), - node_util = require('util'), - prepare = require('../src/cordova/prepare'), - registry = require('../src/plugman/registry/registry'), - PlatformApi = require('../src/platforms/PlatformApiPoly'), - events = require('cordova-common').events, - platform = rewire('../src/cordova/platform'); - - var appName = 'testApp', - tempPath = path.join(__dirname, 'temp'), - appPath = path.join(tempPath, appName), - //srcProject = path.join(__dirname, '..', 'spec-plugman','projects', 'android'), - platformName = helpers.testPlatform, - platformVersionOld = '5.0.0', - platformVersionNew = '6.0.0', - platformVersionNewer = '6.2.1', - platformLocalPathOld = path.join(__dirname, 'cordova-' + platformName + '-old'), - platformLocalPathNew = path.join(__dirname, 'cordova-' + platformName + '-new'), - platformLocalPathNewer = path.join(__dirname, 'cordova-' + platformName + '-newer'), - 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', - otherPlatformName = 'windows', - otherPlatformSpec = '4.0.0', - pluginName = 'cordova-plugin-console', - pluginVersion = '1.0.0', - pluginName2 = 'cordova-plugin-globalization', - pluginVersion2 = '1.0.2', - pluginGitUrl = 'https://github.com/apache/cordova-plugin-console.git', - pluginOldName = 'org.apache.cordova.console', - pluginOldVersion = '0.2.11', - gitPluginName = 'cordova-plugin-device', - gitPluginUrl = 'https://github.com/apache/cordova-plugin-device.git', - variablePluginName = 'cordova-plugin-facebook4', - variablePluginUrl = 'https://github.com/jeduan/cordova-plugin-facebook4', - localPluginName = 'org.apache.cordova.fakeplugin1', - localPluginPath = path.join(__dirname, 'fixtures', 'plugins', 'fake1'), - TIMEOUT = 60 * 1000, - BIG_TIMEOUT = 2 * 60 * 1000; - - //mock variables - var revertInstallPluginsForNewPlatform, - revertDownloadPlatform, - createPlatformOrig = PlatformApi.createPlatform; - - function mockDownloadPlatform(libDir, version) { - revertDownloadPlatform = platform.__set__('downloadPlatform', function () { - return Q({ - libDir: libDir, - platform: platformName, - version: version - }); - }); - } - - /** - * For testing scoped packages. We don't have those packages published, so just - * redirect the registry calls to their un-scoped counterparts - */ - function redirectRegistryCalls(id) { - var originalFetch = registry.fetch; - spyOn(registry, 'fetch').and.callFake(function(package) { - return originalFetch([id]); - }); - - var originalInfo = registry.info; - spyOn(registry, 'info').and.callFake(function(package) { - return originalInfo([id]); - }); - } - - beforeEach(function (done) { - // initial cleanup - shell.rm('-rf', tempPath); - shell.mkdir(tempPath); - - //jasmine mocks - spyOn(util, 'isCordova').and.returnValue(appPath); - spyOn(util, 'cdProjectRoot').and.returnValue(appPath); - spyOn(cordova.raw, 'prepare').and.returnValue(Q()); - spyOn(prepare, 'preparePlatforms').and.returnValue(Q()); - - spyOn(PlatformApi, 'createPlatform').and.returnValue(Q()); - spyOn(PlatformApi, 'updatePlatform').and.returnValue(Q()); - - //rewire mocks - revertInstallPluginsForNewPlatform = platform.__set__('installPluginsForNewPlatform', function () { return Q(); }); - - //creating test app - cordova.raw.create(appPath, undefined, undefined, {}, events).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(); - }); - }, TIMEOUT); - - afterEach(function () { - revertInstallPluginsForNewPlatform(); - }); - - function gitClone(repo, dir, ref, cb) { - var gitTemplate = 'git clone --branch %s --depth=1 %s %s'; - var gitCommand = node_util.format(gitTemplate, ref, repo, dir); - shell.exec(gitCommand, { silent: true }, cb); - } - - describe('preparing fixtures', function () { - it('Test 001 : cloning "old" platform', function (done) { - shell.rm('-rf', platformLocalPathOld); - gitClone(platformGitUrl, platformLocalPathOld, platformVersionOld, function (err) { - expect(err).toBe(0); - done(); - }); - }, BIG_TIMEOUT); - - it('Test 002 : cloning "new" platform', function (done) { - shell.rm('-rf', platformLocalPathNew); - gitClone(platformGitUrl, platformLocalPathNew, platformVersionNew, function (err) { - expect(err).toBe(0); - done(); - }); - }, BIG_TIMEOUT); - - it('Test 003 : cloning "newer" platform', function (done) { - shell.rm('-rf', platformLocalPathNewer); - gitClone(platformGitUrl, platformLocalPathNewer, platformVersionNewer, function (err) { - expect(err).toBe(0); - done(); - }); - }, BIG_TIMEOUT); - }); - - describe('platform add --save', function () { - it('Test 004 : spec.1 should support custom tgz files', function (done) { - helpers.removeEngine(appPath, platformName); - platform('add', platformName + '@' + platformTgzUrl, { 'save': true }) - .then(function () { - expect(helpers.getEngineSpec(appPath, platformName)).toBe(platformTgzUrl); - done(); - }).catch(function (err) { - console.log(err); - expect(false).toBe(true); - done(); - }); - }, BIG_TIMEOUT); - - it('Test 005 : spec.2 should save platform to config', function (done) { - helpers.removeEngine(appPath, platformName); - mockDownloadPlatform(platformLocalPathNew, platformVersionNew); - - platform('add', platformName, { 'save': true }) - .then(function () { - expect(helpers.getEngineSpec(appPath, platformName)).toBe('~' + platformVersionNew); - done(); - }).catch(function (err) { - console.log(err); - expect(false).toBe(true); - done(); - }).finally(function () { - revertDownloadPlatform(); - }); - }, TIMEOUT); - - it('Test 006 : spec.3 should overwrite platform in config, spec = version', function (done) { - helpers.setEngineSpec(appPath, platformName, platformVersionOld); - mockDownloadPlatform(platformLocalPathOld, platformVersionOld); - - platform('add', platformName, { 'save': true }) - .then(function () { - expect(helpers.getEngineSpec(appPath, platformName)).toBe('~' + platformVersionOld); - done(); - }).catch(function (err) { - console.log(err); - expect(false).toBe(true); - done(); - }).finally(function () { - revertDownloadPlatform(); - }); - }, TIMEOUT); - - it('Test 007 : spec.4 should overwrite platform in config, spec = path', function (done) { - helpers.setEngineSpec(appPath, platformName, platformLocalPathNewer); - mockDownloadPlatform(platformLocalPathNewer, platformVersionNewer); - - platform('add', platformName, { 'save': true }) - .then(function () { - expect(helpers.getEngineSpec(appPath, platformName)).toBe(platformLocalPathNewer); - done(); - }).catch(function (err) { - console.log(err); - expect(false).toBe(true); - done(); - }).finally(function () { - revertDownloadPlatform(); - }); - }, TIMEOUT); - - it('Test 008 : spec.5 should fail and should not update config if invalid version is specified', function (done) { - helpers.removeEngine(appPath, platformName); - - platform('add', platformName + '@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, platformName)).toBe(null); - done(); - }); - }, TIMEOUT); - - it('Test 009 : spec.6 should save local path as spec if added using only local path', function (done) { - helpers.removeEngine(appPath, platformName); - - platform('add', platformLocalPathNewer, { 'save': true }) - .then(function () { - expect(helpers.getEngineSpec(appPath, platformName)).toBe(platformLocalPathNewer); - done(); - }).catch(function (err) { - console.log(err); - expect(false).toBe(true); - done(); - }); - }, TIMEOUT); - - it('Test 010 : spec.7 should save git url with git ref properly', function (done) { - var platformUrl = platformGitUrl + '#' + platformGitRef; - helpers.removeEngine(appPath, platformName); - mockDownloadPlatform(platformLocalPathNew, platformVersionNew); - - platform('add', platformUrl, { 'save': true }) - .then(function () { - expect(helpers.getEngineSpec(appPath, platformName)).toBe(platformUrl); - done(); - }).catch(function (err) { - console.log(err); - expect(false).toBe(true); - done(); - }).finally(function () { - revertDownloadPlatform(); - }); - }, TIMEOUT); - }); - - describe('platform remove --save', function () { - it('Test 011 : spec.8 should not update config if there is no engine in it', function (done) { - helpers.removeEngine(appPath, platformName); - - platform('add', platformLocalPathNewer) - .then(function () { - return cordova.raw.platform('rm', platformName, { 'save': true }); - }).then(function () { - expect(helpers.getEngineSpec(appPath, platformName)).toBe(null); - done(); - }).catch(function (err) { - console.log(err); - expect(false).toBe(true); - done(); - }); - }, TIMEOUT); - - it('Test 012 : spec.9 should remove engine from config', function (done) { - helpers.setEngineSpec(appPath, platformName, platformLocalPathNewer); - - platform('add', platformLocalPathNewer) - .then(function () { - return cordova.raw.platform('rm', platformName, { 'save': true }); - }).then(function () { - expect(helpers.getEngineSpec(appPath, platformName)).toBe(null); - done(); - }).catch(function (err) { - console.log(err); - expect(false).toBe(true); - done(); - }); - }, TIMEOUT); - }); - - describe('platform update --save', function () { - it('Test 013 : spec.10 should update config with new spec', function (done) { - helpers.setEngineSpec(appPath, platformName, platformVersionNew); - mockDownloadPlatform(platformLocalPathNew, platformVersionNew); - - platform('add', platformName + '@' + platformVersionNew) - .then(function () { - var fsExistsSync = fs.existsSync.bind(fs); - spyOn(fs, 'existsSync').and.callFake(function (somePath) { - return (somePath === path.join(appPath, 'platforms', platformName)) || fsExistsSync(somePath); - }); - - revertDownloadPlatform(); - mockDownloadPlatform(platformLocalPathOld, platformVersionOld); - - return platform('update', platformName + '@' + platformVersionOld, { 'save': true }); - }).then(function () { - expect(helpers.getEngineSpec(appPath, platformName)).toBe('~' + platformVersionOld); - done(); - }).catch(function (err) { - console.log(err); - expect(false).toBe(true); - done(); - }).finally(function () { - revertDownloadPlatform(); - }); - }, TIMEOUT); - - it('Test 014 : spec.11 should update spec with git url when updating using git url', function (done) { - helpers.setEngineSpec(appPath, platformName, platformVersionNew); - mockDownloadPlatform(platformLocalPathOld, platformVersionOld); - - platform('add', platformName + '@' + platformVersionOld) - .then(function () { - revertDownloadPlatform(); - var fsExistsSync = fs.existsSync.bind(fs); - spyOn(fs, 'existsSync').and.callFake(function (somePath) { - return (somePath === path.join(appPath, 'platforms', platformName)) || fsExistsSync(somePath); - }); - mockDownloadPlatform(platformLocalPathNew, platformVersionNew); - return platform('update', platformGitUrl, { 'save': true }); - }).then(function () { - revertDownloadPlatform(); - var spec = helpers.getEngineSpec(appPath, platformName); - expect(spec).not.toBe(null); - expect(spec).not.toBe(platformVersionNew); - done(); - }).catch(function (err) { - console.log(err); - expect(false).toBe(true); - done(); - }).finally(function (err) { - - }); - }, TIMEOUT); - }); - - describe('plugin add --save', function () { - - it('Test 015 : spec.12 should save plugin to config', function (done) { - cordova.raw.plugin('add', pluginName, { 'save': true }) - .then(function () { - expect(helpers.getPluginSpec(appPath, pluginName)).not.toBe(null); - done(); - }).catch(function (err) { - console.log(err.message); - expect(err).toBeUndefined(); - done(); - }); - }, TIMEOUT); - - it('Test 016 : spec.13 should create new plugin tag in config with old plugin id when downgrading from plugin with new id', function (done) { - helpers.setPluginSpec(appPath, pluginName, pluginOldVersion); - 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('Test 017 : spec.14 should save variables', function (done) { - 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(); - }); - }, BIG_TIMEOUT); - - it('Test 018 : spec.14.1 should restore plugin with variables', function (done) { - 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'); - return cordova.raw.plugin('rm', variablePluginName); - }).then(function() { - expect(path.join(appPath, 'plugins', variablePluginName)).not.toExist(); - return cordova.raw.plugin('add', variablePluginName); - }).then(function() { - expect(path.join(appPath, 'plugins', variablePluginName)).toExist(); - done(); - }).catch(function (err) { - console.log(err.message); - expect(true).toBe(false); - done(); - }); - }, BIG_TIMEOUT); - - it('Test 019 : spec.15 save git url as spec', function (done) { - 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('Test 020 : spec.16 should save local directory as spec', function (done) { - 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); - - it('Test 021 : spec.16.1 save scoped registry packages as spec', function (done) { - redirectRegistryCalls(pluginName + '@' + pluginVersion); - var scopedPackage = '@test-scope/' + pluginName; - - cordova.raw.plugin('add', scopedPackage + '@' + pluginVersion, { 'save': true }) - .then(function () { - expect(registry.fetch).toHaveBeenCalledWith([scopedPackage + '@' + pluginVersion]); - expect(helpers.getPluginSpec(appPath, pluginName)).toBe(scopedPackage + '@~' + pluginVersion); - done(); - }).catch(function (err) { - expect(true).toBe(false); - console.log(err.message); - done(); - }); - }, TIMEOUT); - }); - - describe('plugin remove --save', function () { - it('Test 022 : spec.17 should not add plugin to config', function (done) { - 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('Test 023 : spec.18 should remove plugin from config', function (done) { - 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('platform save', function () { - it('Test 024 : spec.19 should not update config when there are no platforms installed', function (done) { - var configContent = helpers.getConfigContent(appPath); - platform('save') - .then(function () { - expect(helpers.getConfigContent(appPath)).toBe(configContent); - done(); - }).catch(function (err) { - expect(true).toBe(false); - console.log(err.message); - done(); - }); - }, TIMEOUT); - - it('Test 025 : spec.20 should add platform to config', function (done) { - mockDownloadPlatform(platformLocalPathNew, platformVersionNew); - - platform('add', platformName + '@' + platformVersionNew) - .then(function () { - return platform('save'); - }).then(function () { - expect(helpers.getEngineSpec(appPath, platformName)).toBe('~' + platformVersionNew); - done(); - }).catch(function (err) { - expect(true).toBe(false); - console.log(err.message); - done(); - }).finally(function () { - revertDownloadPlatform(); - }); - }, TIMEOUT); - }); - - describe('plugin save', function () { - it('Test 026: spec.21 should not update config when there are no plugins installed', function (done) { - var configContent = helpers.getConfigContent(appPath); - cordova.raw.plugin('save') - .finally(function () { - expect(helpers.getConfigContent(appPath)).toBe(configContent); - done(); - }); - }, TIMEOUT); - - it('Test 027 : spec.22 should update config with plugins: one with version, one with local folder and another one vith git url', function (done) { - cordova.raw.plugin('add', pluginName + '@' + pluginVersion) - .then(function () { - return cordova.raw.plugin('add', gitPluginUrl); - }).then(function () { - return cordova.raw.plugin('add', localPluginPath); - }).then(function () { - return cordova.raw.plugin('save'); - }).then(function () { - expect(helpers.getPluginSpec(appPath, pluginName)).toBe('~' + pluginVersion); - expect(helpers.getPluginSpec(appPath, gitPluginName)).toBe(gitPluginUrl); - expect(helpers.getPluginSpec(appPath, localPluginName)).toBe(localPluginPath); - done(); - }).catch(function (err) { - expect(true).toBe(false); - console.log(err.message); - done(); - }); - }, TIMEOUT); - - it('Test 028 : spec.22.1 should update config with a spec that includes the scope for scoped plugins', function (done) { - // Fetching globalization rather than console to avoid conflicts with earlier tests - redirectRegistryCalls(pluginName2 + '@' + pluginVersion2); - var scopedPackage = '@test-scope/' + pluginName2; - cordova.raw.plugin('add', scopedPackage + '@' + pluginVersion2) - .then(function () { - return cordova.raw.plugin('save'); - }).then(function () { - expect(registry.fetch).toHaveBeenCalledWith([scopedPackage + '@' + pluginVersion2]); - expect(helpers.getPluginSpec(appPath, pluginName2)).toBe(scopedPackage + '@~' + pluginVersion2); - done(); - }).catch(function (err) { - expect(true).toBe(false); - console.log(err.message); - done(); - }); - }, TIMEOUT); - }); - - describe('prepare', function () { - beforeEach(function () { - // Restore back mocked createPlatform functionality - PlatformApi.createPlatform = createPlatformOrig; - }); - - it('Test 029 : spec.23 should restore all platforms and plugins', function (done) { - helpers.setEngineSpec(appPath, platformName, platformLocalPathNewer); - helpers.setPluginSpec(appPath, localPluginName, localPluginPath); - prepare() - .then(function () { - expect(path.join(appPath, 'platforms', platformName)).toExist(); - expect(path.join(appPath, 'plugins', localPluginName)).toExist(); - done(); - }).catch(function (err) { - expect(true).toBe(false); - console.log(err.message); - done(); - }); - }, TIMEOUT); - - it('Test 030 : spec.23.2 should restore plugins without spec attribute', function (done) { - redirectRegistryCalls(pluginName2); - helpers.setEngineSpec(appPath, platformName, platformLocalPathNewer); - helpers.setPluginSpec(appPath, pluginName2/**, do not specify spec here */); - prepare() - .then(function () { - expect(registry.fetch).toHaveBeenCalledWith([pluginName2]); - expect(path.join(appPath, 'plugins', pluginName2)).toExist(); - }).catch(function (err) { - expect(true).toBe(false); - console.log(err.message); - }) - .fin(done); - }, TIMEOUT); - - it('Test 031 : spec.23.1 should restore scoped plugins', function (done) { - redirectRegistryCalls(pluginName2 + '@~' + pluginVersion2); - var scopedPackage = '@test-scope/' + pluginName2; - helpers.setEngineSpec(appPath, platformName, platformLocalPathNewer); - helpers.setPluginSpec(appPath, pluginName2, scopedPackage + '@~' + pluginVersion2); - prepare() - .then(function () { - expect(registry.fetch).toHaveBeenCalledWith([scopedPackage + '@~' + pluginVersion2]); - expect(path.join(appPath, 'plugins', pluginName2)).toExist(); - done(); - }).catch(function (err) { - expect(true).toBe(false); - console.log(err.message); - done(); - }); - }, TIMEOUT); - - it('Test 032 : spec.24 should restore only specified platform', function (done) { - - helpers.setEngineSpec(appPath, platformName, platformLocalPathNewer); - helpers.setEngineSpec(appPath, otherPlatformName, otherPlatformSpec); - var options = { - verbose: false, - platforms: [ platformName ], - options: [] - }; - prepare(options) - .then(function () { - expect(path.join(appPath, 'platforms', platformName)).toExist(); - expect(path.join(appPath, 'platforms', otherPlatformName)).not.toExist(); - done(); - }).catch(function (err) { - expect(true).toBe(false); - console.log(err.message); - done(); - }); - }, BIG_TIMEOUT); - - xit('Test 033 : spec.25 should install plugins already added to the project into platform when restoring it', function (done) { - var fail = jasmine.createSpy('fail').and.callFake(function (err) { - console.log(err.message); - }); - - cordova.raw.plugin('add', localPluginPath) - .then(function() { - helpers.setEngineSpec(appPath, platformName, platformLocalPathNewer); - return prepare({ platforms: [ platformName ] }); - }) - .then(function() { - console.log('prepare ran'); - expect(path.join(appPath, 'platforms', platformName)).toExist(); - // Validate that plugin has been installed to platform by checking - console.log(path.join(appPath, 'platforms', platformName, platformName + '.json')); - // platformJson file for plugin entry added - var platformJson = require(path.join(appPath, 'platforms', platformName, platformName + '.json')); - console.log(platformJson); - //console.log(fs.readFileSync(path.join(appPath, 'config.xml'), 'utf8')) - expect(platformJson.installed_plugins[localPluginName]).toBeDefined(); - }) - .finally(function () { - expect(fail).not.toHaveBeenCalled(); - done(); - }); - }, BIG_TIMEOUT); - }); - - describe('(cleanup)', function () { - it('Test 034 : removing temp dir', function () { - shell.rm('-rf', tempPath); - shell.rm('-rf', platformLocalPathNewer); - shell.rm('-rf', platformLocalPathNew); - shell.rm('-rf', platformLocalPathOld); - }); - }); -}); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/fc72293c/cordova-lib/spec-cordova/serve.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-cordova/serve.spec.js b/cordova-lib/spec-cordova/serve.spec.js deleted file mode 100644 index 0ec5e02..0000000 --- a/cordova-lib/spec-cordova/serve.spec.js +++ /dev/null @@ -1,192 +0,0 @@ -/** - 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. -*/ - -/* jshint expr: true */ -/* global xdescribe */ - -var cordova = require('../src/cordova/cordova'), - console = require('console'), - path = require('path'), - shell = require('shelljs'), - fs = require('fs'), - Q = require('q'), - tempDir, - http = require('http'); - -var cwd = process.cwd(); - -//skipped because of CB-7078 -xdescribe('serve command', function() { - var payloads = {}, - consoleSpy; - beforeEach(function() { - // Make a temp directory - tempDir = path.join(__dirname, '..', 'temp-' + Date.now()); - shell.rm('-rf', tempDir); - shell.mkdir('-p', tempDir); - consoleSpy = spyOn(console, 'log'); - }); - afterEach(function() { - process.chdir(cwd); - process.env.PWD = cwd; - shell.rm('-rf', tempDir); - }); - it('Test 001 : should not run outside of a Cordova-based project', function() { - process.chdir(tempDir); - - expect(function() { - cordova.serve().then(function(server) { - expect(server).toBe(null); - server.close(); - }); - }).toThrow('Current working directory is not a Cordova-based project.'); - }); - - describe('`serve`', function() { - var done = false, failed = false; - beforeEach(function() { - done = false; - failed = false; - }); - - afterEach(function() { - payloads = {}; - }); - - function cit(cond) { - if (cond) { - return it; - } - return xit; - } - function itifapps(apps) { - return cit(apps.every(function (bin) {return shell.which(bin);})); - } - - function test_serve(platform, ref, expectedContents, opts) { - var timeout = opts && 'timeout' in opts && opts.timeout || 1000; - return function() { - var server; - runs(function() { - cordova.raw.create(tempDir).then(function () { - process.chdir(tempDir); - process.env.PWD = tempDir; - var plats = []; - Object.getOwnPropertyNames(payloads).forEach(function(plat) { - var d = Q.defer(); - plats.push(d.promise); - cordova.raw.platform('add', plat, {spawnoutput:'ignore'}).then(function () { - var dir = path.join(tempDir, 'merges', plat); - shell.mkdir('-p', dir); - // Write testing HTML files into the directory. - fs.writeFileSync(path.join(dir, 'test.html'), payloads[plat]); - d.resolve(); - }).catch(function (e) { - expect(e).toBeUndefined(); - failed = true; - }); - }); - Q.allSettled(plats).then(function () { - opts && 'setup' in opts && opts.setup(); - cordova.serve(opts && 'port' in opts && opts.port).then(function (srv) { - server = srv; - }); - }).catch(function (e) { - expect(e).toBeUndefined(); - failed = true; - }); - }).catch(function (e) { - expect(e).toBeUndefined(); - failed = true; - }); - }); - - waitsFor(function() { - return server || failed; - }, 'the server should start', timeout); - - var done, errorCB; - runs(function() { - if (failed) { - return; - } - expect(server).toBeDefined(); - errorCB = jasmine.createSpy(); - http.get({ - host: 'localhost', - port: opts && 'port' in opts ? opts.port : 8000, - path: '/' + platform + '/www' + ref, - connection: 'Close' - }).on('response', function(res) { - var response = ''; - res.on('data', function(data) { - response += data; - }); - res.on('end', function() { - expect(response).toEqual(expectedContents); - if (response === expectedContents) { - expect(res.statusCode).toEqual(200); - } - done = true; - }); - }).on('error', errorCB); - }); - - waitsFor(function() { - return done || failed; - }, 'the HTTP request should complete', timeout); - - runs(function() { - if (!failed) { - expect(done).toBeTruthy(); - expect(errorCB).not.toHaveBeenCalled(); - } - opts && 'cleanup' in opts && opts.cleanup(); - server && server.close(); - }); - }; - } - - itifapps([ - 'android', - 'ant', - ])('should fall back to assets/www on Android', function() { - payloads.android = 'This is the Android test file.'; - test_serve('android', '/test.html', payloads.android, {timeout: 20000})(); - }); - - itifapps([ - 'blackberry-nativepackager', - 'blackberry-deploy', - 'blackberry-signer', - 'blackberry-debugtokenrequest', - ])('should fall back to www on BlackBerry10', function() { - payloads.blackberry10 = 'This is the BlackBerry10 test file.'; - test_serve('blackberry10', '/test.html', payloads.blackberry10, {timeout: 10000})(); - }); - - itifapps([ - 'xcodebuild', - ])('should fall back to www on iOS', function() { - payloads.ios = 'This is the iOS test file.'; - test_serve('ios', '/test.html', payloads.ios, {timeout: 10000})(); - }); - }); -}); - http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/fc72293c/cordova-lib/spec-cordova/test-config-2.xml ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-cordova/test-config-2.xml b/cordova-lib/spec-cordova/test-config-2.xml deleted file mode 100644 index bbfbffb..0000000 --- a/cordova-lib/spec-cordova/test-config-2.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - Hello Cordova - - A sample Apache Cordova application that responds to the deviceready event. - - - Apache Cordova Team - - - - - - - - - - - - - - - -   - http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/fc72293c/cordova-lib/spec-cordova/test-config.xml ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-cordova/test-config.xml b/cordova-lib/spec-cordova/test-config.xml deleted file mode 100644 index ffe8cf7..0000000 --- a/cordova-lib/spec-cordova/test-config.xml +++ /dev/null @@ -1,114 +0,0 @@ - - - Hello Cordova - - A sample Apache Cordova application that responds to the deviceready event. - - - Apache Cordova Team - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/fc72293c/cordova-lib/spec-cordova/util.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-cordova/util.spec.js b/cordova-lib/spec-cordova/util.spec.js deleted file mode 100644 index 2df7a8d..0000000 --- a/cordova-lib/spec-cordova/util.spec.js +++ /dev/null @@ -1,310 +0,0 @@ -/** - 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. -*/ - -/* jshint sub: true */ - -var shell = require('shelljs'), - path = require('path'), - fs = require('fs'), - util = require('../src/cordova/util'), - events = require('../cordova-lib').events, - helpers = require('./helpers'), - temp = path.join(__dirname, '..', 'temp'); - -var cwd = process.cwd(); -var home = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME']; -var origPWD = process.env['PWD']; - -describe('util module', function() { - describe('isCordova method', function() { - afterEach(function() { - process.env['PWD'] = origPWD; - process.chdir(cwd); - }); - function removeDir(directory) { - shell.rm('-rf', directory); - } - it('Test 001 : should return false if it hits the home directory', function() { - var somedir = path.join(home, 'somedir'); - removeDir(somedir); - shell.mkdir(somedir); - expect(util.isCordova(somedir)).toEqual(false); - }); - it('Test 002 : should return false if it cannot find a .cordova directory up the directory tree', function() { - var somedir = path.join(home, '..'); - expect(util.isCordova(somedir)).toEqual(false); - }); - it('Test 003 : should return the first directory it finds with a .cordova folder in it', function() { - var somedir = path.join(home,'somedir'); - var anotherdir = path.join(somedir, 'anotherdir'); - removeDir(somedir); - shell.mkdir('-p', anotherdir); - shell.mkdir('-p', path.join(somedir, 'www', 'config.xml')); - expect(util.isCordova(somedir)).toEqual(somedir); - }); - it('Test 004 : should ignore PWD when its undefined', function() { - delete process.env['PWD']; - var somedir = path.join(home,'somedir'); - var anotherdir = path.join(somedir, 'anotherdir'); - removeDir(somedir); - shell.mkdir('-p', anotherdir); - shell.mkdir('-p', path.join(somedir, 'www')); - shell.mkdir('-p', path.join(somedir, 'config.xml')); - process.chdir(anotherdir); - expect(util.isCordova()).toEqual(somedir); - }); - it('Test 005 : should use PWD when available', function() { - var somedir = path.join(home,'somedir'); - var anotherdir = path.join(somedir, 'anotherdir'); - removeDir(somedir); - shell.mkdir('-p', anotherdir); - shell.mkdir('-p', path.join(somedir, 'www', 'config.xml')); - process.env['PWD'] = anotherdir; - process.chdir(path.sep); - expect(util.isCordova()).toEqual(somedir); - }); - it('Test 006 : should use cwd as a fallback when PWD is not a cordova dir', function() { - var somedir = path.join(home,'somedir'); - var anotherdir = path.join(somedir, 'anotherdir'); - removeDir(somedir); - shell.mkdir('-p', anotherdir); - shell.mkdir('-p', path.join(somedir, 'www', 'config.xml')); - process.env['PWD'] = path.sep; - process.chdir(anotherdir); - expect(util.isCordova()).toEqual(somedir); - }); - it('Test 007 : should ignore platform www/config.xml', function() { - var somedir = path.join(home,'somedir'); - var anotherdir = path.join(somedir, 'anotherdir'); - removeDir(somedir); - shell.mkdir('-p', anotherdir); - shell.mkdir('-p', path.join(anotherdir, 'www', 'config.xml')); - shell.mkdir('-p', path.join(somedir, 'www')); - shell.mkdir('-p', path.join(somedir, 'config.xml')); - expect(util.isCordova(anotherdir)).toEqual(somedir); - }); - }); - describe('deleteSvnFolders method', function() { - afterEach(function() { - shell.rm('-rf', temp); - }); - it('Test 008 : should delete .svn folders in any subdirectory of specified dir', function() { - var one = path.join(temp, 'one'); - var two = path.join(temp, 'two'); - var one_svn = path.join(one, '.svn'); - var two_svn = path.join(two, '.svn'); - shell.mkdir('-p', one_svn); - shell.mkdir('-p', two_svn); - util.deleteSvnFolders(temp); - expect(fs.existsSync(one_svn)).toEqual(false); - expect(fs.existsSync(two_svn)).toEqual(false); - }); - }); - describe('listPlatforms method', function() { - afterEach(function() { - shell.rm('-rf', temp); - }); - it('Test 009 : should only return supported platform directories present in a cordova project dir', function() { - var platforms = path.join(temp, 'platforms'); - - shell.mkdir('-p', path.join(platforms, 'android')); - shell.mkdir('-p', path.join(platforms, 'ios')); - shell.mkdir('-p', path.join(platforms, 'wp8')); - shell.mkdir('-p', path.join(platforms, 'atari')); - - // create a typical platforms.json file, it should not be returned as a platform - shell.exec('touch ' + path.join(platforms,'platforms.json')); - - var res = util.listPlatforms(temp); - expect(res.length).toEqual(4); - }); - }); - describe('getInstalledPlatformsWithVersions method', function() { - afterEach(function() { - shell.rm('-rf', temp); - }); - it('Test 010 : should get the supported platforms in the cordova project dir along with their reported versions', function(done) { - var platforms = path.join(temp, 'platforms'); - var android = path.join(platforms, 'android'); - - shell.mkdir('-p', android); - - shell.cp('-R', - path.join(__dirname, 'fixtures', 'platforms', helpers.testPlatform), platforms); - util.getInstalledPlatformsWithVersions(temp) - .then(function(platformMap) { - expect(platformMap['android']).toBe('3.1.0'); - }).fin(done); - }); - }); - describe('findPlugins method', function() { - afterEach(function() { - shell.rm('-rf', temp); - }); - it('Test 011 : should only return plugin directories present in a cordova project dir', function() { - var plugins = path.join(temp, 'plugins'); - var android = path.join(plugins, 'android'); - var ios = path.join(plugins, 'ios'); - var wp8_dir = path.join(plugins, 'wp8'); - var atari = path.join(plugins, 'atari'); - shell.mkdir('-p', android); - shell.mkdir('-p', ios); - shell.mkdir('-p', wp8_dir); - shell.mkdir('-p', atari); - var res = util.findPlugins(plugins); - expect(res.length).toEqual(4); - }); - it('Test 012 : should not return ".svn" directories', function() { - var plugins = path.join(temp, 'plugins'); - var android = path.join(plugins, 'android'); - var ios = path.join(plugins, 'ios'); - var svn = path.join(plugins, '.svn'); - shell.mkdir('-p', android); - shell.mkdir('-p', ios); - shell.mkdir('-p', svn); - var res = util.findPlugins(plugins); - expect(res.length).toEqual(2); - expect(res.indexOf('.svn')).toEqual(-1); - }); - it('Test 013 : should not return "CVS" directories', function() { - var plugins = path.join(temp, 'plugins'); - var android = path.join(plugins, 'android'); - var ios = path.join(plugins, 'ios'); - var cvs = path.join(plugins, 'CVS'); - shell.mkdir('-p', android); - shell.mkdir('-p', ios); - shell.mkdir('-p', cvs); - var res = util.findPlugins(plugins); - expect(res.length).toEqual(2); - expect(res.indexOf('CVS')).toEqual(-1); - }); - }); - - describe('preprocessOptions method', function() { - - var isCordova, listPlatforms; - var DEFAULT_OPTIONS = { - // 'android' is here because we create a spy - // for listPlatforms below that returns 'android' - platforms: ['android'], - verbose: false - }; - - beforeEach(function() { - isCordova = spyOn(util, 'isCordova').and.returnValue('/fake/path'); - listPlatforms = spyOn(util, 'listPlatforms').and.returnValue(['android']); - }); - - it('Test 014 : should throw if called outside of cordova project', function() { - isCordova.and.returnValue(false); - expect(function() { util.preProcessOptions(); }).toThrow(); - }); - - it('Test 015 : should throw when no platforms added to project', function() { - listPlatforms.and.returnValue([]); - expect(function () { util.preProcessOptions(); }).toThrow(); - }); - - it('Test 016 : should return default options when no arguments passed', function() { - expect(util.preProcessOptions()).toEqual(jasmine.objectContaining(DEFAULT_OPTIONS)); - }); - - it('Test 017 : should accept single string argument as platform name', function() { - expect(util.preProcessOptions('ios')).toEqual(jasmine.objectContaining({platforms: ['ios']})); - }); - - it('Test 018 : should accept array of strings as platform names', function() { - expect(util.preProcessOptions(['ios', 'windows'])).toEqual(jasmine.objectContaining({platforms: ['ios', 'windows']})); - }); - - it('Test 019 : should fall back to installed platform if input doesn\'t contain platforms list', function() { - expect(util.preProcessOptions({verbose: true})) - .toEqual(jasmine.objectContaining({platforms: ['android'], verbose: true})); - }); - - it('Test 020 : should pick buildConfig if no option is provided, but buildConfig.json exists', function() { - spyOn(fs, 'existsSync').and.returnValue(true); - // Using path.join below to normalize path separators - expect(util.preProcessOptions()) - .toEqual(jasmine.objectContaining({options: {buildConfig: path.join('/fake/path/build.json')}})); - }); - - describe('ensurePlatformOptionsCompatible', function() { - - var unknownOptions = ['--foo', '--appx=uap', '--gradleArg=--no-daemon']; - var validOptions = ['--debug', '--release', '--device', '--emulator', '--nobuild', '--list', - '--buildConfig=/fake/path/build.json', '--target=foo', '--archs="x86 x64"']; - - it('Test 021 : should return \'options\' unchanged if they are not an array', function() { - ['foo', true, {bar: true}].forEach(function (optionValue) { - expect(util.preProcessOptions({options: optionValue})) - .toEqual(jasmine.objectContaining({options: optionValue})); - }); - }); - - it('Test 022 : should emit \'warn\' event if \'options\' is an Array', function() { - var warnSpy = jasmine.createSpy('warnSpy'); - events.on('warn', warnSpy); - util.preProcessOptions({options: ['foo']}); - expect(warnSpy).toHaveBeenCalled(); - expect(warnSpy.calls.argsFor(0)).toMatch('consider updating your cordova.raw.* method calls'); - events.removeListener('warn', warnSpy); - }); - - it('Test 023 : should convert options Array into object with \'argv\' field', function() { - expect(util.preProcessOptions({options: []})) - .toEqual(jasmine.objectContaining({options: {argv: []}})); - }); - - it('Test 024 : should convert known options (platform-agnostic) into resultant object\'s fields', function () { - var expectedResult = { - 'debug': true, 'release': true, - 'device': true, 'emulator': true, - 'nobuild': true, 'list': true, - 'buildConfig': '/fake/path/build.json', - 'target': 'foo', - 'archs': '\"x86 x64\"' - }; - - expect(util.preProcessOptions({options: validOptions}).options) - .toEqual(jasmine.objectContaining(expectedResult)); - - validOptions.forEach(function (validOption) { - expect(util.preProcessOptions({options: validOptions}).options.argv) - .not.toContain(validOption); - }); - }); - - it('Test 025 : should try to convert unknown options (platform-specific) into resultant object\'s fields', function () { - var expectedResult = { - 'foo': true, 'appx': 'uap', 'gradleArg': '--no-daemon' - }; - - expect(util.preProcessOptions({options: unknownOptions}).options) - .toEqual(jasmine.objectContaining(expectedResult)); - }); - - it('Test 026 : should copy unknown options (platform-specific) into resultant object\'s argv field', function () { - unknownOptions.forEach(function (validOption) { - expect(util.preProcessOptions({options: unknownOptions}).options.argv).toContain(validOption); - }); - }); - }); - }); -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/fc72293c/cordova-lib/spec-cordova/wrappers.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-cordova/wrappers.spec.js b/cordova-lib/spec-cordova/wrappers.spec.js deleted file mode 100644 index 9c6af7f..0000000 --- a/cordova-lib/spec-cordova/wrappers.spec.js +++ /dev/null @@ -1,60 +0,0 @@ -/** - 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. -*/ - -/* jshint loopfunc: true */ - -var Q = require('q'), - cordova = require('../src/cordova/cordova'); - -describe('callback wrapper', function() { - var calls = ['prepare', 'build', 'create', 'emulate', 'plugin', 'platform', 'compile', 'run']; - for (var i = 0; i < calls.length; i++) { - var call = calls[i]; - - describe('`' + call + '`', function() { - var raw; - beforeEach(function() { - raw = spyOn(cordova.raw, call); - }); - - it('Test 001 : should work with no callback and success', function() { - raw.and.returnValue(Q()); - cordova[call](); - expect(raw).toHaveBeenCalled(); - }); - - it('Test 002 : should call the callback on success', function(done) { - raw.and.returnValue(Q()); - cordova[call](function(err) { - expect(err).toBeUndefined(); - done(); - }); - }); - - it('Test 003 : should call the callback with the error on failure', function(done) { - var err = new Error('junk'); - raw.and.returnValue(Q.reject(err)); - cordova[call](function(e) { - expect(e).toEqual(err); - done(); - }); - }); - }); - } -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/fc72293c/cordova-lib/spec-plugman/.jshintrc ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/.jshintrc b/cordova-lib/spec-plugman/.jshintrc deleted file mode 100644 index 17eae32..0000000 --- a/cordova-lib/spec-plugman/.jshintrc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "node": true - , "bitwise": true - , "undef": true - , "trailing": true - , "quotmark": true - , "indent": 4 - , "unused": "vars" - , "latedef": "nofunc" - , "jasmine": true -} http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/fc72293c/cordova-lib/spec-plugman/add_platform.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/add_platform.spec.js b/cordova-lib/spec-plugman/add_platform.spec.js deleted file mode 100644 index 15524c7..0000000 --- a/cordova-lib/spec-plugman/add_platform.spec.js +++ /dev/null @@ -1,74 +0,0 @@ -/** - 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. -*/ -var platform = require('../src/plugman/platform'), - Q = require('q'), - fs = require('fs'); - -describe( 'platform add/remove', function() { - it( 'Test 001 : should call platform add', function() { - var sPlatformA = spyOn( platform, 'add' ).and.returnValue(Q()), - sPlatformR = spyOn( platform, 'remove' ).and.returnValue(Q()); - platform.add(); - expect(sPlatformA).toHaveBeenCalled(); - platform.remove(); - expect(sPlatformR).toHaveBeenCalled(); - }); -}); - - -describe( 'platform add', function() { - var done = false, - existsSync; - - beforeEach( function() { - existsSync = spyOn( fs, 'existsSync' ).and.returnValue( false ); - done = false; - }); - it( 'Test 002 : should error on non existing plugin.xml', function(done) { - platform.add().then(function(result){ - expect(false).toBe(true); - done(); - }, - function err(errMsg) { - expect(errMsg.toString()).toContain('can\'t find a plugin.xml. Are you in the plugin?'); - done(); - }); - }, 6000); -}); - - -describe( 'platform remove', function() { - var done = false, - existsSync; - - beforeEach( function() { - existsSync = spyOn( fs, 'existsSync' ).and.returnValue( false ); - done = false; - }); - it( 'Test 003 : should error on non existing plugin.xml', function(done) { - platform.remove().then(function(result) { - expect(false).toBe(true); - done(); - }, - function err(errMsg) { - expect(errMsg.toString()).toContain( 'can\'t find a plugin.xml. Are you in the plugin?' ); - done(); - }); - }, 6000); -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/fc72293c/cordova-lib/spec-plugman/common.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/common.js b/cordova-lib/spec-plugman/common.js deleted file mode 100644 index dd29539..0000000 --- a/cordova-lib/spec-plugman/common.js +++ /dev/null @@ -1,80 +0,0 @@ -/** - 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. -*/ - -// nopt = require('nopt'); - -// var known_opts = { -// 'verbose' : Boolean, -// 'debug' : Number -// }, shortHands = { 'd' : ['--debug'] }; - -// var opt = nopt(known_opts, shortHands); -// var mapNames = { -// 'verbose' : 7, -// 'info' : 6, -// 'notice' : 5, -// 'warn' : 4, -// 'error' : 3 -// } - -// if(opt.verbose) -// opt.debug = 7; - -// if(opt.debug) { -// for(var i in mapNames) { -// if(mapNames[i] <= opt.debug) -// plugman.on(i, console.log); -// } - -// if(opt.debug >= 6) -// plugman.on('log', console.log); -// } -var common = {}; - -module.exports = common = { - spy: { - getInstall: function(emitSpy){ - return common.spy.startsWith(emitSpy, 'Install start'); - }, - - getDeleted: function(emitSpy){ - return common.spy.startsWith(emitSpy, 'Deleted'); - }, - - 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]); - }); - return match; - }, - - 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]); - }); - return match; - } - } -}; http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/fc72293c/cordova-lib/spec-plugman/config.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/config.spec.js b/cordova-lib/spec-plugman/config.spec.js deleted file mode 100644 index 99c9dcb..0000000 --- a/cordova-lib/spec-plugman/config.spec.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - 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. -*/ -var config = require('../src/plugman/config'), - Q = require('q'), - registry = require('../src/plugman/registry/registry'); - -describe('config', function() { - it('Test 001 : should run config', function() { - var sConfig = spyOn(registry, 'config').and.returnValue(Q()); - var params = ['set', 'registry', 'http://registry.cordova.io']; - config(params); - expect(sConfig).toHaveBeenCalledWith(params); - }); -}); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/fc72293c/cordova-lib/spec-plugman/create.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/create.spec.js b/cordova-lib/spec-plugman/create.spec.js deleted file mode 100644 index 64b0cdc..0000000 --- a/cordova-lib/spec-plugman/create.spec.js +++ /dev/null @@ -1,77 +0,0 @@ -/** - 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. -*/ -var create = require('../src/plugman/create'), - Q = require('q'), - fs = require('fs'), - shell = require('shelljs'), - plugman = require('../src/plugman/plugman'); - -describe( 'create', function() { - it( 'Test 001 : should call create', function() { - var sCreate = spyOn( plugman, 'create' ).and.returnValue(Q()); - plugman.create(); - expect(sCreate).toHaveBeenCalled(); - }); -}); - -describe( 'create plugin', function() { - var done = false, - existsSync, - mkdir, - writeFileSync; - - beforeEach( function() { - existsSync = spyOn( fs, 'existsSync' ).and.returnValue( false ); - mkdir = spyOn( shell, 'mkdir' ).and.returnValue( true ); - writeFileSync = spyOn( fs, 'writeFileSync' ); - done = false; - }); - - it( 'Test 002 : should be successful', function(done) { - create('name', 'org.plugin.id', '0.0.0', '.', []) - .then(function(result) { - expect( writeFileSync.calls.count() ).toEqual( 2 ); - done(); - }).fail(function err(errMsg) { - expect(errMsg).toBeUndefined(); - done(); - }); - }, 6000); -}); - -describe( 'create plugin in existing plugin', function() { - var done = false, - existsSync; - - beforeEach( function() { - existsSync = spyOn( fs, 'existsSync' ).and.returnValue( true ); - done = false; - }); - - it( 'Test 003 : should fail due to an existing plugin.xml', function(done) { - create() - .then(function(result) { - expect(false).toBe(true); - done(); - }).fail(function err(errMsg) { - expect(errMsg.toString()).toContain( 'plugin.xml already exists. Are you already in a plugin?' ); - done(); - }); - }, 6000); -}); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org