From fde755fe86b7c93b8505645567781646dc8fb572 Mon Sep 17 00:00:00 2001 From: Mark Koudritsky Date: Tue, 8 Apr 2014 17:50:44 -0400 Subject: [PATCH 1/3] CB-6421: Move tests from e2e to spec Removing the duplicate tests first as a separate commit (for better history). --- spec/create.spec.js | 152 ------------- spec/platform.spec.js | 482 ------------------------------------------ spec/plugin.spec.js | 288 ------------------------- 3 files changed, 922 deletions(-) delete mode 100644 spec/create.spec.js delete mode 100644 spec/platform.spec.js delete mode 100644 spec/plugin.spec.js diff --git a/spec/create.spec.js b/spec/create.spec.js deleted file mode 100644 index a482f4dea..000000000 --- a/spec/create.spec.js +++ /dev/null @@ -1,152 +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 cordova = require('../cordova'), - path = require('path'), - shell = require('shelljs'), - fs = require('fs'), - et = require('elementtree'), - ConfigParser = require('../src/ConfigParser'), - util = require('../src/util'), - config = require('../src/config'), - lazy_load = require('../src/lazy_load'), - xmlHelpers = require('../src/xml-helpers'), - Q = require('q'), - tempDir = path.join(__dirname, '..', 'temp'); - -var TEST_XML = '\n' + - '\n' + - ' Hello Cordova\n' + - ' \n' + - ' A sample Apache Cordova application that responds to the deviceready event.\n' + - ' \n' + - ' \n' + - ' Apache Cordova Team\n' + - ' \n' + - ' \n' + - ' \n' + - ' \n' + - ' \n' + - '\n'; - -describe('create command', function () { - var mkdir, cp, config_spy, load_cordova, load_custom, exists, config_read, config_write; - beforeEach(function() { - shell.rm('-rf', tempDir); - mkdir = spyOn(shell, 'mkdir'); - cp = spyOn(shell, 'cp'); - config_spy = spyOn(cordova, 'config'); - config_read = spyOn(config, 'read').andReturn({}); - config_write = spyOn(config, 'write').andReturn({}); - exists = spyOn(fs, 'existsSync').andCallFake(function(p) { - if (p == 'lib/dir') return true; - return false; - }); - load_cordova = spyOn(lazy_load, 'cordova').andReturn(Q(path.join('lib','dir'))); - load_custom = spyOn(lazy_load, 'custom').andReturn(Q(path.join('lib','dir'))); - spyOn(ConfigParser.prototype, 'write'); - spyOn(xmlHelpers, 'parseElementtreeSync').andCallFake(function() { - return new et.ElementTree(et.XML(TEST_XML)); - }); - }); - - describe('failure', function() { - it('should return a help message if incorrect number of parameters is used', function(done) { - this.after(function() { - cordova.removeAllListeners('results'); - }); - cordova.on('results', function(h) { - expect(h).toMatch(/synopsis/gi); - done(); - }); - cordova.raw.create(); - }); - }); - - describe('success', function() { - it('should create top-level directory structure appropriate for a cordova-cli project', function(done) { - cordova.raw.create(tempDir).then(function() { - expect(mkdir).toHaveBeenCalledWith(path.join(tempDir, 'platforms')); - expect(mkdir).toHaveBeenCalledWith(path.join(tempDir, 'merges')); - expect(mkdir).toHaveBeenCalledWith(path.join(tempDir, 'plugins')); - expect(mkdir).toHaveBeenCalledWith(path.join(tempDir, 'www')); - done(); - }); - }); - it('should create hooks directory', function(done) { - var hooks_dir = path.join(tempDir, 'hooks'); - cordova.raw.create(tempDir).then(function() { - expect(mkdir).toHaveBeenCalledWith(hooks_dir); - expect(cp).toHaveBeenCalledWith( - path.resolve(__dirname, '..', 'templates', 'hooks-README.md'), - jasmine.any(String) - ); - done(); - }); - }); - it('should by default use cordova-app-hello-world as www assets', function(done) { - cordova.raw.create(tempDir).then(function() { - expect(load_cordova).toHaveBeenCalledWith('www'); - done(); - }); - }); - it('should try to lazy load custom www location if specified', function(done) { - var fake_config = { - lib:{ - www:{ - id:'supercordova', - uri:'/supacordoba', - version:'1337' - } - } - }; - config_read.andReturn(fake_config); - config_write.andReturn(fake_config); - cordova.raw.create(tempDir, 'some.app.id', 'SomeAppName', fake_config).then(function() { - expect(load_custom).toHaveBeenCalledWith(fake_config.lib.www.uri, fake_config.lib.www.id, 'www', fake_config.lib.www.version); - done(); - }); - }); - it('should add a missing www/config.xml', function(done) { - cordova.raw.create(tempDir).then(function() { - expect(shell.cp).toHaveBeenCalledWith( - path.resolve(__dirname, '..', 'templates', 'config.xml'), - jasmine.any(String) - ); - done(); - }); - }); - it('should not replace an existing www/config.xml', function(done) { - exists.andCallFake(function(p) { - if (p == 'lib/dir') return true; - if (p.indexOf('config.xml') > -1) return true; - return false; - }); - cordova.raw.create(tempDir).then(function() { - expect(shell.cp).not.toHaveBeenCalledWith( - path.resolve(__dirname, '..', 'templates', 'config.xml'), - jasmine.any(String) - ); - done(); - }); - }); - }); -}); diff --git a/spec/platform.spec.js b/spec/platform.spec.js deleted file mode 100644 index d4ad00014..000000000 --- a/spec/platform.spec.js +++ /dev/null @@ -1,482 +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 cordova = require('../cordova'), - events = require('../src/events'), - path = require('path'), - shell = require('shelljs'), - superspawn = require('../src/superspawn'), - xmlHelpers = require('../src/xml-helpers'), - et = require('elementtree'), - plugman = require('plugman'), - fs = require('fs'), - util = require('../src/util'), - config = require('../src/config'), - hooker = require('../src/hooker'), - lazy_load = require('../src/lazy_load'), - Q = require('q'), - platform = require('../src/platform'), - platforms = require('../platforms'); - -var cwd = process.cwd(); -var supported_platforms = Object.keys(platforms).filter(function(p) { return p != 'www'; }); -var project_dir = path.join('some', 'path'); - -var TEST_XML = '\n' + - ' Hello Cordova\n' + - '\n'; - -function fail(e) { - expect('Got Error: ' + e).toBe(''); -} - -describe('platform command', function() { - var is_cordova, - cd_project_root, - cp, - list_platforms, - fire, - find_plugins, - config_read, - load, - load_custom, - rm, - mkdir, - existsSync, - supports, - spawn, - prep_spy, - plugman_install, - parsers = {}; - beforeEach(function() { - supported_platforms.forEach(function(p) { - parsers[p] = spyOn(platforms[p], 'parser').andReturn({ - staging_dir:function(){}, - www_dir:function(){return 'pwww'} - }); - }); - is_cordova = spyOn(util, 'isCordova').andReturn(project_dir); - cd_project_root = spyOn(util, 'cdProjectRoot').andReturn(project_dir); - fire = spyOn(hooker.prototype, 'fire').andReturn(Q()); - spyOn(xmlHelpers, 'parseElementtreeSync').andCallFake(function() { - return new et.ElementTree(et.XML(TEST_XML)); - }); - find_plugins = spyOn(util, 'findPlugins').andReturn([]); - list_platforms = spyOn(util, 'listPlatforms').andReturn(supported_platforms); - util.libDirectory = path.join('HOMEDIR', '.cordova', 'lib'); - config_read = spyOn(config, 'read').andReturn({}); - - fakeLazyLoad = function(id, platform, version) { - if (platform == 'wp7' || platform == 'wp8') { - return Q(path.join('lib', 'wp', id, version, platform)); - } else { - return Q(path.join('lib', platform, id, version, platforms[platform] && platforms[platform].subdirectory ? platforms[platform].subdirectory : '')); - } - }; - lazyLoadVersion = '3.1.0'; - load = spyOn(lazy_load, 'based_on_config').andCallFake(function(root, platform) { - return fakeLazyLoad('cordova', platform, lazyLoadVersion); - }); - load_custom = spyOn(lazy_load, 'custom').andCallFake(function(url, id, platform, version) { - return fakeLazyLoad(id, platform, version); - }); - - rm = spyOn(shell, 'rm'); - cp = spyOn(shell, 'cp'); - mkdir = spyOn(shell, 'mkdir'); - existsSync = spyOn(fs, 'existsSync').andReturn(false); - var origReadFile = fs.readFileSync; - spyOn(fs, 'readFileSync').andCallFake(function(path) { - if (/VERSION$/.test(path)) { - return '3.3.0'; - } - return origReadFile.apply(this, arguments); - }); - supports = spyOn(platform, 'supports').andReturn(Q()); - spawn = spyOn(superspawn, 'spawn').andCallFake(function() { return Q('3.4.0') }); - prep_spy = spyOn(cordova.raw, 'prepare').andReturn(Q()); - plugman_install = spyOn(plugman, 'install').andReturn(Q()); - }); - - describe('failure', function() { - function expectFailure(p, done, post) { - p.then(function() { - expect('this call').toBe('fail'); - }, post).fin(done); - } - - it('should not run outside of a Cordova-based project by calling util.isCordova', function(done) { - var msg = 'Dummy message about not being in a cordova dir.'; - cd_project_root.andThrow(new Error(msg)); - expectFailure(Q().then(cordova.raw.platform), done, function(err) { - expect(cd_project_root).toHaveBeenCalled(); - expect(err.message).toEqual(msg); - }); - }); - it('should report back an error if used with `add` and no platform is specified', function(done) { - expectFailure(cordova.raw.platform('add'), done, function(err) { - expect(err).toEqual(new Error('You need to qualify `add` or `remove` with one or more platforms!')); - }); - }); - it('should report back an error if used with `rm` and no platform is specified', function(done) { - expectFailure(cordova.raw.platform('rm'), done, function(err) { - expect(err).toEqual(new Error('You need to qualify `add` or `remove` with one or more platforms!')); - }); - }); - }); - - describe('success', function() { - it('should run inside a Cordova-based project by calling util.isCordova', function(done) { - cordova.raw.platform().then(function() { - expect(is_cordova).toHaveBeenCalled(); - }, fail).fin(done); - }); - - describe('`ls`', function() { - afterEach(function() { - cordova.removeAllListeners('results'); - }); - it('should list out no platforms for a fresh project', function(done) { - list_platforms.andReturn([]); - cordova.on('results', function(res) { - expect(res).toMatch(/^Installed platforms:\s*Available platforms:.*$/); - done(); - }); - cordova.raw.platform('list'); - - }); - it('should list out added platforms in a project', function(done) { - cordova.on('results', function(res) { - expect(res).toMatch(RegExp("^Installed platforms: "+supported_platforms.sort().join(", ")+"\\s*Available platforms:\\s*$")); - done(); - }); - cordova.raw.platform('list'); - }); - }); - describe('`add`', function() { - beforeEach(function() { - supported_platforms.forEach(function(p) { - platforms[p].parser.check_requirements = function(){return Q();}; - }); - }); - - it('should shell out to specified platform\'s bin/create, using the version that is specified in platforms manifest', function(done) { - cordova.raw.platform('add', 'android').then(function() { - expect(spawn.mostRecentCall.args.join()).toMatch(/lib.android.cordova.\d.\d.\d[\d\-\w]*.bin.create/gi); - expect(spawn.mostRecentCall.args.join()).toContain(project_dir); - }).then(function() { - return cordova.raw.platform('add', 'wp7'); - }).then(function() { - expect(spawn.mostRecentCall.args.join()).toMatch(/lib.wp.cordova.\d.\d.\d[\d\w\-]*.wp7.*.bin.create/gi); - expect(spawn.mostRecentCall.args.join()).toContain(project_dir); - }).then(function() { - return cordova.raw.platform('add', 'wp8'); - }).then(function() { - expect(spawn.mostRecentCall.args.join()).toMatch(/lib.wp.cordova.\d.\d.\d[\d\w\-]*.wp8.*.bin.create/gi); - expect(spawn.mostRecentCall.args.join()).toContain(project_dir); - }).then(function(){ - return cordova.raw.platform('add', 'windows8'); - }).then(function(){ - expect(spawn.mostRecentCall.args.join()).toMatch(/lib.windows8.cordova.\d.\d.\d[\d\w\-]*.windows8.*.bin.create/gi); - expect(spawn.mostRecentCall.args.join()).toContain(project_dir); - }, fail).fin(done); - }); - it('should call into lazy_load.custom if there is a user-specified configruation for consuming custom libraries', function(done) { - load.andCallThrough(); - config_read.andReturn({ - lib:{ - 'wp8':{ - uri:'haha', - id:'phonegap', - version:'bleeding edge' - } - } - }); - cordova.raw.platform('add', 'wp8').then(function() { - expect(load_custom).toHaveBeenCalledWith('haha', 'phonegap', 'wp8', 'bleeding edge'); - expect(spawn.mostRecentCall.args.join()).toMatch(/lib.wp.phonegap.bleeding edge.wp8.*.bin.create/gi); - expect(spawn.mostRecentCall.args.join()).toContain(project_dir); - }, fail).fin(done); - }); - it('should use a custom template directory if there is one specified in the configuration', function(done) { - var template_dir = "/tmp/custom-template" - load.andCallThrough(); - config_read.andReturn({ - lib: { - android: { - uri: "https://git-wip-us.apache.org/repos/asf?p=cordova-android.git", - version: "3.0.0", - id: "cordova", - template: template_dir - } - } - }); - cordova.raw.platform('add', 'android').then(function() { - expect(spawn.mostRecentCall.args.join()).toContain(project_dir); - expect(spawn.mostRecentCall.args.join()).toContain(template_dir); - }, fail).fin(done); - }); - it('should not use a custom template directory if there is not one specified in the configuration', function(done) { - load.andCallThrough(); - config_read.andReturn({ - lib: { - android: { - uri: "https://git-wip-us.apache.org/repos/asf?p=cordova-android.git", - version: "3.0.0", - id: "cordova", - } - } - }); - cordova.raw.platform('add', 'android').then(function() { - expect(spawn.mostRecentCall.args.join()).toContain(project_dir); - }, fail).fin(done); - }); - it('should not use a custom template directory if there is no user-defined configuration', function(done) { - cordova.raw.platform('add', 'android').then(function() { - expect(spawn.mostRecentCall.args.join()).toContain(project_dir); - }, fail).fin(done); - }); - }); - describe('`remove`',function() { - it('should remove a supported and added platform', function(done) { - cordova.raw.platform('remove', 'android').then(function() { - expect(rm).toHaveBeenCalledWith('-rf', path.join(project_dir, 'platforms', 'android')); - }, fail).fin(done); - }); - - it('should be able to remove multiple platforms', function(done) { - cordova.raw.platform('remove', ['android', 'blackberry10']).then(function() { - expect(rm).toHaveBeenCalledWith('-rf', path.join(project_dir, 'platforms', 'android')); - expect(rm).toHaveBeenCalledWith('-rf', path.join(project_dir, 'platforms', 'blackberry10')); - }, fail).fin(done); - }); - }); - describe('`update`', function() { - describe('failure', function() { - it('should fail if no platform is specified', function(done) { - cordova.raw.platform('update', []).then(function() { - expect('this call').toBe('fail'); - }, function(err) { - expect(err).toEqual(new Error('No platform provided. Please specify a platform to update.')); - }).fin(done); - }); - it('should fail if more than one platform is specified', function(done) { - cordova.raw.platform('update', ['android', 'ios']).then(function() { - expect('this call').toBe('fail'); - }, function(err) { - expect(err).toEqual(new Error('Platform update can only be executed on one platform at a time.')); - }).fin(done); - }); - }); - - // Don't run this test on windows ... iOS will fail always - if(!require('os').platform().match(/^win/)) { - describe('success', function() { - it('should shell out to the platform update script', function(done) { - var oldVersion = lazyLoadVersion; - lazyLoadVersion = '1.0.0'; - cordova.raw.platform('update', ['ios']).then(function() { - expect(exec).toHaveBeenCalledWith('"lib/ios/cordova/1.0.0/bin/update" "some/path/platforms/ios"', jasmine.any(Function)); - }, fail).fin(function() { - lazyLoadVersion = oldVersion; - done(); - }); - }); - }); - } - }); - describe('`check`', function() { - var real_platforms_data = {}, - synthetic_platforms_data = { - current: { - uri: "https://localhost", - version: "3.3.0", - parser: function(){} - }, - stale: { - uri: "https://localhost", - version: "3.3.0", - parser: function(){} - }, - newer: { - uri: "https://localhost", - version: "3.3.0", - parser: function(){} - } - }; - beforeEach(function() { - list_platforms.andReturn(['current', 'stale', 'newer']); - Object.keys(platforms).forEach(function (k) { - real_platforms_data[k] = platforms[k]; - delete platforms[k]; - }); - Object.keys(synthetic_platforms_data).forEach(function (k) { - platforms[k] = synthetic_platforms_data[k]; - }); - }); - afterEach(function() { - list_platforms.andReturn(['current', 'stale', 'newer']); - Object.keys(platforms).forEach(function (k) { - delete platforms[k]; - }); - Object.keys(real_platforms_data).forEach(function (k) { - platforms[k] = real_platforms_data[k]; - }); - }); - it('check platforms current, stale, newer', function() { - existsSync.andCallFake(function(dir) { - if (/cordova-platform-check.*version/.test(dir)) { - return true; - } - if (/cordova-platform-check/.test(dir)) { - return false; - } - return true; - }); - var create = spyOn(cordova.raw, 'create').andCallFake(function() { return Q() }); - - spawn.andCallFake(function(cmd) { - var out; - if (/cordova-platform-check/.test(cmd)) { - out = '3.3.0'; - } else if (/current/.test(cmd)) { - out = '3.3.0'; - } else if (/stale/.test(cmd)) { - out = '3.2.0'; - } else { - out = '3.4.0'; - } - return Q(out); - }); - var results; - events.on('results', function(res) { results = res; }); - - cordova.raw.platform('check'); - waitsFor(function() { - return results; - }, 'promise never resolved', 500); - runs(function() { - expect(results).toEqual("stale @ 3.2.0 could be updated to: 3.3.0"); - }); - }); - }); - }); - describe('hooks', function() { - describe('list (ls) hooks', function(done) { - it('should fire before hooks through the hooker module', function() { - cordova.raw.platform().then(function() { - expect(fire).toHaveBeenCalledWith('before_platform_ls'); - }, fail).fin(done); - }); - it('should fire after hooks through the hooker module', function(done) { - cordova.raw.platform().then(function() { - expect(fire).toHaveBeenCalledWith('after_platform_ls'); - }, fail).fin(done); - }); - }); - describe('remove (rm) hooks', function() { - it('should fire before hooks through the hooker module', function(done) { - cordova.raw.platform('rm', 'android').then(function() { - expect(fire).toHaveBeenCalledWith('before_platform_rm', {platforms:['android']}); - }, fail).fin(done); - }); - it('should fire after hooks through the hooker module', function(done) { - cordova.raw.platform('rm', 'android').then(function() { - expect(fire).toHaveBeenCalledWith('after_platform_rm', {platforms:['android']}); - }, fail).fin(done); - }); - }); - describe('add hooks', function() { - beforeEach(function() { - supported_platforms.forEach(function(p) { - platforms[p].parser.check_requirements = function(){return Q();}; - }); - }); - - it('should fire before and after hooks through the hooker module', function(done) { - cordova.raw.platform('add', 'android').then(function() { - expect(fire).toHaveBeenCalledWith('before_platform_add', {platforms:['android']}); - expect(fire).toHaveBeenCalledWith('after_platform_add', {platforms:['android']}); - }, fail).fin(done); - }); - }); - }); -}); - -describe('platform.supports(name)', function() { - var supports = {}; - beforeEach(function() { - supported_platforms.forEach(function(p) { - supports[p] = spyOn(platforms[p].parser, 'check_requirements').andReturn(Q()); - }); - }); - - function expectFailure(p, done, post) { - p.then(function() { - expect('this call').toBe('fail'); - }, post).fin(done); - } - - it('should require a platform name', function(done) { - expectFailure(cordova.raw.platform.supports(project_dir, undefined), done, function(err) { - expect(err).toEqual(jasmine.any(Error)); - }); - }); - - describe('when platform is unknown', function() { - it('should reject', function(done) { - expectFailure(cordova.raw.platform.supports(project_dir, 'windows-3.1'), done, function(err) { - expect(err).toEqual(jasmine.any(Error)); - done(); - }); - }); - }); - - describe('when platform is supported', function() { - it('should resolve', function(done) { - cordova.raw.platform.supports(project_dir, 'android').then(function() { - expect(1).toBe(1); - }, fail).fin(done); - }); - }); - - describe('when platform is unsupported', function() { - it('should reject', function(done) { - supported_platforms.forEach(function(p) { - supports[p].andReturn(Q.reject(new Error('no sdk'))); - }); - expectFailure(cordova.raw.platform.supports(project_dir, 'android'), done, function(err) { - expect(err).toEqual(jasmine.any(Error)); - }); - }); - }); -}); - -describe('platform parsers', function() { - it('should be exposed on the platform module', function() { - for (var platform in platforms) { - expect(cordova.raw.platform[platform]).toBeDefined(); - for (var prop in platforms[platform]) { - expect(cordova.raw.platform[platform][prop]).toBeDefined(); - } - } - }); -}); diff --git a/spec/plugin.spec.js b/spec/plugin.spec.js deleted file mode 100644 index d427f00a0..000000000 --- a/spec/plugin.spec.js +++ /dev/null @@ -1,288 +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 cordova = require('../cordova'), - path = require('path'), - shell = require('shelljs'), - child_process = require('child_process'), - plugman = require('plugman'), - fs = require('fs'), - util = require('../src/util'), - config = require('../src/config'), - hooker = require('../src/hooker'), - Q = require('q'), - platforms = require('../platforms'); - -var cwd = process.cwd(); -var supported_platforms = Object.keys(platforms).filter(function(p) { return p != 'www'; }).sort(); -var sample_plugins = ['one','two']; -var project_dir = path.join('some','path'); -var plugins_dir = path.join(project_dir, 'plugins'); - -describe('plugin command', function() { - var is_cordova, - cd_project_root, - list_platforms, - fire, - find_plugins, - rm, - mkdir, - existsSync, - exec, - prep_spy, - plugman_install, - plugman_fetch, - parsers = {}, - uninstallPlatform, - uninstallPlugin; - - beforeEach(function() { - is_cordova = spyOn(util, 'isCordova').andReturn(project_dir); - cd_project_root = spyOn(util, 'cdProjectRoot').andReturn(project_dir); - fire = spyOn(hooker.prototype, 'fire').andReturn(Q()); - supported_platforms.forEach(function(p) { - parsers[p] = jasmine.createSpy(p + ' update_project').andReturn(Q()); - spyOn(platforms[p], 'parser').andReturn({}); - }); - list_platforms = spyOn(util, 'listPlatforms').andReturn(supported_platforms); - find_plugins = spyOn(util, 'findPlugins').andReturn(sample_plugins); - rm = spyOn(shell, 'rm'); - mkdir = spyOn(shell, 'mkdir'); - existsSync = spyOn(fs, 'existsSync').andReturn(false); - exec = spyOn(child_process, 'exec').andCallFake(function(cmd, opts, cb) { - if (!cb) cb = opts; - cb(0, '', ''); - }); - prep_spy = spyOn(cordova.raw, 'prepare').andReturn(Q()); - plugman_install = spyOn(plugman.raw, 'install').andReturn(Q()); - plugman_fetch = spyOn(plugman.raw, 'fetch').andCallFake(function(target, plugins_dir, opts) { return Q(path.join(plugins_dir, target)); }); - plugman_search = spyOn(plugman.raw, 'search').andReturn(Q()); - uninstallPlatform = spyOn(plugman.raw.uninstall, 'uninstallPlatform').andReturn(Q()); - uninstallPlugin = spyOn(plugman.raw.uninstall, 'uninstallPlugin').andReturn(Q()); - }); - - describe('failure', function() { - function expectFailure(p, done, post) { - p.then(function() { - expect('this call').toBe('fail'); - }, post).fin(done); - } - - it('should not run outside of a Cordova-based project by calling util.isCordova', function(done) { - var msg = 'Dummy message about not being in a cordova dir.'; - cd_project_root.andThrow(new Error(msg)); - is_cordova.andReturn(false); - expectFailure(Q().then(cordova.raw.plugin), done, function(err) { - expect(err.message).toEqual(msg); - }); - }); - it('should report back an error if used with `add` and no plugin is specified', function(done) { - expectFailure(cordova.raw.plugin('add'), done, function(err) { - expect(err).toEqual(new Error('You need to qualify `add` or `remove` with one or more plugins!')); - }); - }); - it('should report back an error if used with `rm` and no plugin is specified', function(done) { - expectFailure(cordova.raw.plugin('rm'), done, function(err) { - expect(err).toEqual(new Error('You need to qualify `add` or `remove` with one or more plugins!')); - }); - }); - }); - - describe('success', function() { - it('should run inside a Cordova-based project by calling util.isCordova', function(done) { - cordova.raw.plugin().then(function() { - expect(is_cordova).toHaveBeenCalled(); - done(); - }); - }); - - describe('`ls`', function() { - afterEach(function() { - cordova.removeAllListeners('results'); - }); - it('should list out no plugins for a fresh project', function(done) { - find_plugins.andReturn([]); - cordova.on('results', function(res) { - expect(res).toEqual('No plugins added. Use `cordova plugin add `.'); - done(); - }); - cordova.raw.plugin('list'); - }); - it('should list out added plugins in a project', function(done) { - cordova.on('results', function(res) { - expect(res).toEqual(sample_plugins); - done(); - }); - cordova.raw.plugin('list'); - }); - it('should resolve with a list of plugins', function(done) { - cordova.raw.plugin('list', []).then(function(plugins) { - expect(plugins).toEqual(sample_plugins); - }, function(err) { - expect(err).toBeUndefined(); - }).fin(done); - }); - }); - describe('`add`', function() { - it('should call plugman.fetch for each plugin', function(done) { - cordova.raw.plugin('add', sample_plugins).then(function() { - sample_plugins.forEach(function(p) { - expect(plugman_fetch).toHaveBeenCalledWith(p, plugins_dir, {}); - }); - }, function(err) { - expect(err).toBeUndefined(); - }).fin(done); - }); - it('should call plugman.install, for each plugin, for every platform', function(done) { - cordova.raw.plugin('add', sample_plugins).then(function(err) { - sample_plugins.forEach(function(plug) { - supported_platforms.forEach(function(plat) { - expect(plugman_install).toHaveBeenCalledWith((plat=='blackberry'?'blackberry10':plat), path.join(project_dir, 'platforms', plat), plug, plugins_dir, jasmine.any(Object)); - }); - }); - }, function(err) { - expect(err).toBeUndefined(); - }).fin(done); - }); - it('should pass down variables into plugman', function(done) { - cordova.raw.plugin('add', "one", "--variable", "foo=bar").then(function() { - supported_platforms.forEach(function(plat) { - expect(plugman_install).toHaveBeenCalledWith( - (plat=='blackberry'?'blackberry10':plat), - path.join(project_dir, 'platforms', plat), - "one", - plugins_dir, - {cli_variables: { FOO: "bar"}} - ); - }); - }, function(err) { - expect(err).toBeUndefined(); - }).fin(done); - }); - it('should resolve without an error', function(done) { - cordova.raw.plugin('add', sample_plugins).then(function() { - expect(1).toBe(1); - }, function(err) { - expect(err).toBeUndefined(); - }).fin(done); - }); - }); - describe('`search`', function() { - it('should call plugman.search', function(done) { - cordova.raw.plugin('search', sample_plugins).then(function() { - expect(plugman_search).toHaveBeenCalledWith(sample_plugins); - }, function(err) { - expect(err).toBeUndefined(); - }).fin(done); - }); - }); - describe('`remove`',function() { - var plugin_parser; - var subset = ['android', 'wp7']; - beforeEach(function() { - plugin_parser = spyOn(util, 'plugin_parser').andReturn({ - platforms:subset - }); - }); - it('should throw if plugin is not installed', function(done) { - cordova.raw.plugin('rm', 'somethingrandom').then(function() { - expect('this call').toBe('fail'); - }, function(err) { - expect(err).toEqual(new Error('Plugin "somethingrandom" not added to project.')); - }).fin(done); - }); - - it('should call plugman.uninstall.uninstallPlatform for every matching installedplugin-supportedplatform pair', function(done) { - cordova.raw.plugin('rm', sample_plugins).then(function() { - sample_plugins.forEach(function(plug) { - subset.forEach(function(plat) { - expect(uninstallPlatform).toHaveBeenCalledWith(plat, path.join(project_dir, 'platforms', plat), plug, plugins_dir); - }); - }); - }, function(err) { - expect(err).toBeUndefined(); - }).fin(done); - }); - it('should call plugman.uninstall.uninstallPlugin once for every removed plugin', function(done) { - uninstallPlugin.reset(); - cordova.raw.plugin('rm', sample_plugins).then(function() { - expect(uninstallPlugin.callCount).toBe(2); - }, function(err) { - expect(err).toBeUndefined(); - }).fin(done); - }); - it('should resolve without an error', function(done) { - cordova.raw.plugin('rm', sample_plugins).then(function() { - expect(1).toBe(1); - }, function(err) { - expect(err).not.toBeDefined(); - }).fin(done); - }); - }); - }); - describe('hooks', function() { - var plugin_parser; - beforeEach(function() { - plugin_parser = spyOn(util, 'plugin_parser').andReturn({ - platforms:supported_platforms - }); - }); - describe('list (ls) hooks', function() { - it('should fire before hooks through the hooker module', function(done) { - cordova.raw.plugin().then(function() { - expect(fire).toHaveBeenCalledWith('before_plugin_ls'); - }, function(err) { - expect(err).toBeUndefined(); - }).fin(done); - }); - it('should fire after hooks through the hooker module', function(done) { - cordova.raw.plugin().then(function() { - expect(fire).toHaveBeenCalledWith('after_plugin_ls'); - }, function(err) { - expect(err).toBeUndefined(); - }).fin(done); - }); - }); - describe('remove (rm) hooks', function() { - it('should fire before hooks through the hooker module', function(done) { - cordova.raw.plugin('rm', 'two').then(function() { - expect(fire).toHaveBeenCalledWith('before_plugin_rm', {plugins:['two'], options: []}); - }, function(err) { - expect(err).toBeUndefined(); - }).fin(done); - }); - it('should fire after hooks through the hooker module', function(done) { - cordova.raw.plugin('rm', 'one').then(function() { - expect(fire).toHaveBeenCalledWith('after_plugin_rm', {plugins:['one'], options:[]}); - }, function(err) { - expect(err).toBeUndefined(); - }).fin(done); - }); - }); - describe('add hooks', function() { - it('should fire before and after hooks through the hooker module', function(done) { - cordova.raw.plugin('add', 'android').then(function() { - expect(fire).toHaveBeenCalledWith('before_plugin_add', {plugins:['android'], options: []}); - expect(fire).toHaveBeenCalledWith('after_plugin_add', {plugins:['android'], options: []}); - }, function(err) { - expect(err).toBeUndefined(); - }).fin(done); - }); - }); - }); -}); From f4a9597a8a4394ca6e943c285e1ad8eab5a31fd7 Mon Sep 17 00:00:00 2001 From: Mark Koudritsky Date: Tue, 8 Apr 2014 18:27:54 -0400 Subject: [PATCH 2/3] CB-6421: Move tests from e2e to spec Part 2, move all the files and delete e2e dir. For history of old overwritten tests in spec try git log 5cf9d9064005ff7bc6205c05277169b929e52fb5 --- {e2e => spec}/create.spec.js | 0 {e2e => spec}/fixtures/base/.cordova/config.json | 0 {e2e => spec}/fixtures/base/merges/.svn | 0 {e2e => spec}/fixtures/base/platforms/.svn | 0 {e2e => spec}/fixtures/base/plugins/.svn | 0 {e2e => spec}/fixtures/base/www/config.xml | 0 {e2e => spec}/fixtures/base/www/css/index.css | 0 {e2e => spec}/fixtures/base/www/img/logo.png | Bin {e2e => spec}/fixtures/base/www/index.html | 0 {e2e => spec}/fixtures/base/www/js/index.js | 0 {e2e => spec}/fixtures/base/www/spec.html | 0 {e2e => spec}/fixtures/hooks_bat/fail/fail.bat | 0 {e2e => spec}/fixtures/hooks_bat/test/.dotted.bat | 0 {e2e => spec}/fixtures/hooks_bat/test/07.bat | 0 {e2e => spec}/fixtures/hooks_bat/test/1.bat | 0 {e2e => spec}/fixtures/hooks_sh/fail/fail.sh | 0 {e2e => spec}/fixtures/hooks_sh/test/.dotted.sh | 0 {e2e => spec}/fixtures/hooks_sh/test/07.sh | 0 {e2e => spec}/fixtures/hooks_sh/test/1.sh | 0 .../fixtures/platforms/android-lib/VERSION | 0 .../android-lib/framework/assets/www/cordova.js | 0 .../fixtures/platforms/android/AndroidManifest.xml | 0 .../platforms/android/assets/www/config.xml | 0 .../platforms/android/assets/www/cordova.js | 0 .../platforms/android/assets/www/cordova_plugins.js | 0 .../platforms/android/assets/www/css/index.css | 0 .../platforms/android/assets/www/img/logo.png | Bin .../platforms/android/assets/www/index.html | 0 .../platforms/android/assets/www/js/index.js | 0 .../fixtures/platforms/android/assets/www/spec.html | 0 {e2e => spec}/fixtures/platforms/android/build.xml | 0 .../fixtures/platforms/android/cordova/build | 0 .../fixtures/platforms/android/cordova/check_reqs | 0 .../fixtures/platforms/android/cordova/clean | 0 .../fixtures/platforms/android/cordova/defaults.xml | 0 .../platforms/android/cordova/lib/appinfo.js | 0 .../fixtures/platforms/android/cordova/lib/build.js | 0 .../platforms/android/cordova/lib/check_reqs.js | 0 .../fixtures/platforms/android/cordova/lib/clean.js | 0 .../platforms/android/cordova/lib/device.js | 0 .../platforms/android/cordova/lib/emulator.js | 0 .../platforms/android/cordova/lib/install-device | 0 .../platforms/android/cordova/lib/install-emulator | 0 .../platforms/android/cordova/lib/list-devices | 0 .../android/cordova/lib/list-emulator-images | 0 .../android/cordova/lib/list-started-emulators | 0 .../fixtures/platforms/android/cordova/lib/log.js | 0 .../fixtures/platforms/android/cordova/lib/run.js | 0 .../platforms/android/cordova/lib/start-emulator | 0 .../fixtures/platforms/android/cordova/log | 0 .../fixtures/platforms/android/cordova/run | 0 .../fixtures/platforms/android/cordova/version | 0 .../fixtures/platforms/android/local.properties | 0 .../fixtures/platforms/android/proguard-project.txt | 0 .../fixtures/platforms/android/project.properties | 0 .../platforms/android/res/drawable-hdpi/icon.png | Bin .../platforms/android/res/drawable-ldpi/icon.png | Bin .../platforms/android/res/drawable-mdpi/icon.png | Bin .../platforms/android/res/drawable-xhdpi/icon.png | Bin .../platforms/android/res/drawable/icon.png | Bin .../platforms/android/res/values/strings.xml | 0 .../fixtures/platforms/android/res/xml/config.xml | 0 .../platforms/android/src/org/testing/TestBase.java | 0 {e2e => spec}/fixtures/plugins/fake1/plugin.xml | 0 {e2e => spec}/helpers.js | 0 {e2e => spec}/hooker.spec.js | 0 {e2e => spec}/platform.spec.js | 0 {e2e => spec}/plugin.spec.js | 0 68 files changed, 0 insertions(+), 0 deletions(-) rename {e2e => spec}/create.spec.js (100%) rename {e2e => spec}/fixtures/base/.cordova/config.json (100%) rename {e2e => spec}/fixtures/base/merges/.svn (100%) rename {e2e => spec}/fixtures/base/platforms/.svn (100%) rename {e2e => spec}/fixtures/base/plugins/.svn (100%) rename {e2e => spec}/fixtures/base/www/config.xml (100%) rename {e2e => spec}/fixtures/base/www/css/index.css (100%) rename {e2e => spec}/fixtures/base/www/img/logo.png (100%) rename {e2e => spec}/fixtures/base/www/index.html (100%) rename {e2e => spec}/fixtures/base/www/js/index.js (100%) rename {e2e => spec}/fixtures/base/www/spec.html (100%) rename {e2e => spec}/fixtures/hooks_bat/fail/fail.bat (100%) rename {e2e => spec}/fixtures/hooks_bat/test/.dotted.bat (100%) rename {e2e => spec}/fixtures/hooks_bat/test/07.bat (100%) rename {e2e => spec}/fixtures/hooks_bat/test/1.bat (100%) rename {e2e => spec}/fixtures/hooks_sh/fail/fail.sh (100%) rename {e2e => spec}/fixtures/hooks_sh/test/.dotted.sh (100%) rename {e2e => spec}/fixtures/hooks_sh/test/07.sh (100%) rename {e2e => spec}/fixtures/hooks_sh/test/1.sh (100%) rename {e2e => spec}/fixtures/platforms/android-lib/VERSION (100%) rename {e2e => spec}/fixtures/platforms/android-lib/framework/assets/www/cordova.js (100%) rename {e2e => spec}/fixtures/platforms/android/AndroidManifest.xml (100%) rename {e2e => spec}/fixtures/platforms/android/assets/www/config.xml (100%) rename {e2e => spec}/fixtures/platforms/android/assets/www/cordova.js (100%) rename {e2e => spec}/fixtures/platforms/android/assets/www/cordova_plugins.js (100%) rename {e2e => spec}/fixtures/platforms/android/assets/www/css/index.css (100%) rename {e2e => spec}/fixtures/platforms/android/assets/www/img/logo.png (100%) rename {e2e => spec}/fixtures/platforms/android/assets/www/index.html (100%) rename {e2e => spec}/fixtures/platforms/android/assets/www/js/index.js (100%) rename {e2e => spec}/fixtures/platforms/android/assets/www/spec.html (100%) rename {e2e => spec}/fixtures/platforms/android/build.xml (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/build (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/check_reqs (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/clean (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/defaults.xml (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/lib/appinfo.js (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/lib/build.js (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/lib/check_reqs.js (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/lib/clean.js (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/lib/device.js (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/lib/emulator.js (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/lib/install-device (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/lib/install-emulator (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/lib/list-devices (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/lib/list-emulator-images (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/lib/list-started-emulators (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/lib/log.js (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/lib/run.js (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/lib/start-emulator (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/log (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/run (100%) rename {e2e => spec}/fixtures/platforms/android/cordova/version (100%) rename {e2e => spec}/fixtures/platforms/android/local.properties (100%) rename {e2e => spec}/fixtures/platforms/android/proguard-project.txt (100%) rename {e2e => spec}/fixtures/platforms/android/project.properties (100%) rename {e2e => spec}/fixtures/platforms/android/res/drawable-hdpi/icon.png (100%) rename {e2e => spec}/fixtures/platforms/android/res/drawable-ldpi/icon.png (100%) rename {e2e => spec}/fixtures/platforms/android/res/drawable-mdpi/icon.png (100%) rename {e2e => spec}/fixtures/platforms/android/res/drawable-xhdpi/icon.png (100%) rename {e2e => spec}/fixtures/platforms/android/res/drawable/icon.png (100%) rename {e2e => spec}/fixtures/platforms/android/res/values/strings.xml (100%) rename {e2e => spec}/fixtures/platforms/android/res/xml/config.xml (100%) rename {e2e => spec}/fixtures/platforms/android/src/org/testing/TestBase.java (100%) rename {e2e => spec}/fixtures/plugins/fake1/plugin.xml (100%) rename {e2e => spec}/helpers.js (100%) rename {e2e => spec}/hooker.spec.js (100%) rename {e2e => spec}/platform.spec.js (100%) rename {e2e => spec}/plugin.spec.js (100%) diff --git a/e2e/create.spec.js b/spec/create.spec.js similarity index 100% rename from e2e/create.spec.js rename to spec/create.spec.js diff --git a/e2e/fixtures/base/.cordova/config.json b/spec/fixtures/base/.cordova/config.json similarity index 100% rename from e2e/fixtures/base/.cordova/config.json rename to spec/fixtures/base/.cordova/config.json diff --git a/e2e/fixtures/base/merges/.svn b/spec/fixtures/base/merges/.svn similarity index 100% rename from e2e/fixtures/base/merges/.svn rename to spec/fixtures/base/merges/.svn diff --git a/e2e/fixtures/base/platforms/.svn b/spec/fixtures/base/platforms/.svn similarity index 100% rename from e2e/fixtures/base/platforms/.svn rename to spec/fixtures/base/platforms/.svn diff --git a/e2e/fixtures/base/plugins/.svn b/spec/fixtures/base/plugins/.svn similarity index 100% rename from e2e/fixtures/base/plugins/.svn rename to spec/fixtures/base/plugins/.svn diff --git a/e2e/fixtures/base/www/config.xml b/spec/fixtures/base/www/config.xml similarity index 100% rename from e2e/fixtures/base/www/config.xml rename to spec/fixtures/base/www/config.xml diff --git a/e2e/fixtures/base/www/css/index.css b/spec/fixtures/base/www/css/index.css similarity index 100% rename from e2e/fixtures/base/www/css/index.css rename to spec/fixtures/base/www/css/index.css diff --git a/e2e/fixtures/base/www/img/logo.png b/spec/fixtures/base/www/img/logo.png similarity index 100% rename from e2e/fixtures/base/www/img/logo.png rename to spec/fixtures/base/www/img/logo.png diff --git a/e2e/fixtures/base/www/index.html b/spec/fixtures/base/www/index.html similarity index 100% rename from e2e/fixtures/base/www/index.html rename to spec/fixtures/base/www/index.html diff --git a/e2e/fixtures/base/www/js/index.js b/spec/fixtures/base/www/js/index.js similarity index 100% rename from e2e/fixtures/base/www/js/index.js rename to spec/fixtures/base/www/js/index.js diff --git a/e2e/fixtures/base/www/spec.html b/spec/fixtures/base/www/spec.html similarity index 100% rename from e2e/fixtures/base/www/spec.html rename to spec/fixtures/base/www/spec.html diff --git a/e2e/fixtures/hooks_bat/fail/fail.bat b/spec/fixtures/hooks_bat/fail/fail.bat similarity index 100% rename from e2e/fixtures/hooks_bat/fail/fail.bat rename to spec/fixtures/hooks_bat/fail/fail.bat diff --git a/e2e/fixtures/hooks_bat/test/.dotted.bat b/spec/fixtures/hooks_bat/test/.dotted.bat similarity index 100% rename from e2e/fixtures/hooks_bat/test/.dotted.bat rename to spec/fixtures/hooks_bat/test/.dotted.bat diff --git a/e2e/fixtures/hooks_bat/test/07.bat b/spec/fixtures/hooks_bat/test/07.bat similarity index 100% rename from e2e/fixtures/hooks_bat/test/07.bat rename to spec/fixtures/hooks_bat/test/07.bat diff --git a/e2e/fixtures/hooks_bat/test/1.bat b/spec/fixtures/hooks_bat/test/1.bat similarity index 100% rename from e2e/fixtures/hooks_bat/test/1.bat rename to spec/fixtures/hooks_bat/test/1.bat diff --git a/e2e/fixtures/hooks_sh/fail/fail.sh b/spec/fixtures/hooks_sh/fail/fail.sh similarity index 100% rename from e2e/fixtures/hooks_sh/fail/fail.sh rename to spec/fixtures/hooks_sh/fail/fail.sh diff --git a/e2e/fixtures/hooks_sh/test/.dotted.sh b/spec/fixtures/hooks_sh/test/.dotted.sh similarity index 100% rename from e2e/fixtures/hooks_sh/test/.dotted.sh rename to spec/fixtures/hooks_sh/test/.dotted.sh diff --git a/e2e/fixtures/hooks_sh/test/07.sh b/spec/fixtures/hooks_sh/test/07.sh similarity index 100% rename from e2e/fixtures/hooks_sh/test/07.sh rename to spec/fixtures/hooks_sh/test/07.sh diff --git a/e2e/fixtures/hooks_sh/test/1.sh b/spec/fixtures/hooks_sh/test/1.sh similarity index 100% rename from e2e/fixtures/hooks_sh/test/1.sh rename to spec/fixtures/hooks_sh/test/1.sh diff --git a/e2e/fixtures/platforms/android-lib/VERSION b/spec/fixtures/platforms/android-lib/VERSION similarity index 100% rename from e2e/fixtures/platforms/android-lib/VERSION rename to spec/fixtures/platforms/android-lib/VERSION diff --git a/e2e/fixtures/platforms/android-lib/framework/assets/www/cordova.js b/spec/fixtures/platforms/android-lib/framework/assets/www/cordova.js similarity index 100% rename from e2e/fixtures/platforms/android-lib/framework/assets/www/cordova.js rename to spec/fixtures/platforms/android-lib/framework/assets/www/cordova.js diff --git a/e2e/fixtures/platforms/android/AndroidManifest.xml b/spec/fixtures/platforms/android/AndroidManifest.xml similarity index 100% rename from e2e/fixtures/platforms/android/AndroidManifest.xml rename to spec/fixtures/platforms/android/AndroidManifest.xml diff --git a/e2e/fixtures/platforms/android/assets/www/config.xml b/spec/fixtures/platforms/android/assets/www/config.xml similarity index 100% rename from e2e/fixtures/platforms/android/assets/www/config.xml rename to spec/fixtures/platforms/android/assets/www/config.xml diff --git a/e2e/fixtures/platforms/android/assets/www/cordova.js b/spec/fixtures/platforms/android/assets/www/cordova.js similarity index 100% rename from e2e/fixtures/platforms/android/assets/www/cordova.js rename to spec/fixtures/platforms/android/assets/www/cordova.js diff --git a/e2e/fixtures/platforms/android/assets/www/cordova_plugins.js b/spec/fixtures/platforms/android/assets/www/cordova_plugins.js similarity index 100% rename from e2e/fixtures/platforms/android/assets/www/cordova_plugins.js rename to spec/fixtures/platforms/android/assets/www/cordova_plugins.js diff --git a/e2e/fixtures/platforms/android/assets/www/css/index.css b/spec/fixtures/platforms/android/assets/www/css/index.css similarity index 100% rename from e2e/fixtures/platforms/android/assets/www/css/index.css rename to spec/fixtures/platforms/android/assets/www/css/index.css diff --git a/e2e/fixtures/platforms/android/assets/www/img/logo.png b/spec/fixtures/platforms/android/assets/www/img/logo.png similarity index 100% rename from e2e/fixtures/platforms/android/assets/www/img/logo.png rename to spec/fixtures/platforms/android/assets/www/img/logo.png diff --git a/e2e/fixtures/platforms/android/assets/www/index.html b/spec/fixtures/platforms/android/assets/www/index.html similarity index 100% rename from e2e/fixtures/platforms/android/assets/www/index.html rename to spec/fixtures/platforms/android/assets/www/index.html diff --git a/e2e/fixtures/platforms/android/assets/www/js/index.js b/spec/fixtures/platforms/android/assets/www/js/index.js similarity index 100% rename from e2e/fixtures/platforms/android/assets/www/js/index.js rename to spec/fixtures/platforms/android/assets/www/js/index.js diff --git a/e2e/fixtures/platforms/android/assets/www/spec.html b/spec/fixtures/platforms/android/assets/www/spec.html similarity index 100% rename from e2e/fixtures/platforms/android/assets/www/spec.html rename to spec/fixtures/platforms/android/assets/www/spec.html diff --git a/e2e/fixtures/platforms/android/build.xml b/spec/fixtures/platforms/android/build.xml similarity index 100% rename from e2e/fixtures/platforms/android/build.xml rename to spec/fixtures/platforms/android/build.xml diff --git a/e2e/fixtures/platforms/android/cordova/build b/spec/fixtures/platforms/android/cordova/build similarity index 100% rename from e2e/fixtures/platforms/android/cordova/build rename to spec/fixtures/platforms/android/cordova/build diff --git a/e2e/fixtures/platforms/android/cordova/check_reqs b/spec/fixtures/platforms/android/cordova/check_reqs similarity index 100% rename from e2e/fixtures/platforms/android/cordova/check_reqs rename to spec/fixtures/platforms/android/cordova/check_reqs diff --git a/e2e/fixtures/platforms/android/cordova/clean b/spec/fixtures/platforms/android/cordova/clean similarity index 100% rename from e2e/fixtures/platforms/android/cordova/clean rename to spec/fixtures/platforms/android/cordova/clean diff --git a/e2e/fixtures/platforms/android/cordova/defaults.xml b/spec/fixtures/platforms/android/cordova/defaults.xml similarity index 100% rename from e2e/fixtures/platforms/android/cordova/defaults.xml rename to spec/fixtures/platforms/android/cordova/defaults.xml diff --git a/e2e/fixtures/platforms/android/cordova/lib/appinfo.js b/spec/fixtures/platforms/android/cordova/lib/appinfo.js similarity index 100% rename from e2e/fixtures/platforms/android/cordova/lib/appinfo.js rename to spec/fixtures/platforms/android/cordova/lib/appinfo.js diff --git a/e2e/fixtures/platforms/android/cordova/lib/build.js b/spec/fixtures/platforms/android/cordova/lib/build.js similarity index 100% rename from e2e/fixtures/platforms/android/cordova/lib/build.js rename to spec/fixtures/platforms/android/cordova/lib/build.js diff --git a/e2e/fixtures/platforms/android/cordova/lib/check_reqs.js b/spec/fixtures/platforms/android/cordova/lib/check_reqs.js similarity index 100% rename from e2e/fixtures/platforms/android/cordova/lib/check_reqs.js rename to spec/fixtures/platforms/android/cordova/lib/check_reqs.js diff --git a/e2e/fixtures/platforms/android/cordova/lib/clean.js b/spec/fixtures/platforms/android/cordova/lib/clean.js similarity index 100% rename from e2e/fixtures/platforms/android/cordova/lib/clean.js rename to spec/fixtures/platforms/android/cordova/lib/clean.js diff --git a/e2e/fixtures/platforms/android/cordova/lib/device.js b/spec/fixtures/platforms/android/cordova/lib/device.js similarity index 100% rename from e2e/fixtures/platforms/android/cordova/lib/device.js rename to spec/fixtures/platforms/android/cordova/lib/device.js diff --git a/e2e/fixtures/platforms/android/cordova/lib/emulator.js b/spec/fixtures/platforms/android/cordova/lib/emulator.js similarity index 100% rename from e2e/fixtures/platforms/android/cordova/lib/emulator.js rename to spec/fixtures/platforms/android/cordova/lib/emulator.js diff --git a/e2e/fixtures/platforms/android/cordova/lib/install-device b/spec/fixtures/platforms/android/cordova/lib/install-device similarity index 100% rename from e2e/fixtures/platforms/android/cordova/lib/install-device rename to spec/fixtures/platforms/android/cordova/lib/install-device diff --git a/e2e/fixtures/platforms/android/cordova/lib/install-emulator b/spec/fixtures/platforms/android/cordova/lib/install-emulator similarity index 100% rename from e2e/fixtures/platforms/android/cordova/lib/install-emulator rename to spec/fixtures/platforms/android/cordova/lib/install-emulator diff --git a/e2e/fixtures/platforms/android/cordova/lib/list-devices b/spec/fixtures/platforms/android/cordova/lib/list-devices similarity index 100% rename from e2e/fixtures/platforms/android/cordova/lib/list-devices rename to spec/fixtures/platforms/android/cordova/lib/list-devices diff --git a/e2e/fixtures/platforms/android/cordova/lib/list-emulator-images b/spec/fixtures/platforms/android/cordova/lib/list-emulator-images similarity index 100% rename from e2e/fixtures/platforms/android/cordova/lib/list-emulator-images rename to spec/fixtures/platforms/android/cordova/lib/list-emulator-images diff --git a/e2e/fixtures/platforms/android/cordova/lib/list-started-emulators b/spec/fixtures/platforms/android/cordova/lib/list-started-emulators similarity index 100% rename from e2e/fixtures/platforms/android/cordova/lib/list-started-emulators rename to spec/fixtures/platforms/android/cordova/lib/list-started-emulators diff --git a/e2e/fixtures/platforms/android/cordova/lib/log.js b/spec/fixtures/platforms/android/cordova/lib/log.js similarity index 100% rename from e2e/fixtures/platforms/android/cordova/lib/log.js rename to spec/fixtures/platforms/android/cordova/lib/log.js diff --git a/e2e/fixtures/platforms/android/cordova/lib/run.js b/spec/fixtures/platforms/android/cordova/lib/run.js similarity index 100% rename from e2e/fixtures/platforms/android/cordova/lib/run.js rename to spec/fixtures/platforms/android/cordova/lib/run.js diff --git a/e2e/fixtures/platforms/android/cordova/lib/start-emulator b/spec/fixtures/platforms/android/cordova/lib/start-emulator similarity index 100% rename from e2e/fixtures/platforms/android/cordova/lib/start-emulator rename to spec/fixtures/platforms/android/cordova/lib/start-emulator diff --git a/e2e/fixtures/platforms/android/cordova/log b/spec/fixtures/platforms/android/cordova/log similarity index 100% rename from e2e/fixtures/platforms/android/cordova/log rename to spec/fixtures/platforms/android/cordova/log diff --git a/e2e/fixtures/platforms/android/cordova/run b/spec/fixtures/platforms/android/cordova/run similarity index 100% rename from e2e/fixtures/platforms/android/cordova/run rename to spec/fixtures/platforms/android/cordova/run diff --git a/e2e/fixtures/platforms/android/cordova/version b/spec/fixtures/platforms/android/cordova/version similarity index 100% rename from e2e/fixtures/platforms/android/cordova/version rename to spec/fixtures/platforms/android/cordova/version diff --git a/e2e/fixtures/platforms/android/local.properties b/spec/fixtures/platforms/android/local.properties similarity index 100% rename from e2e/fixtures/platforms/android/local.properties rename to spec/fixtures/platforms/android/local.properties diff --git a/e2e/fixtures/platforms/android/proguard-project.txt b/spec/fixtures/platforms/android/proguard-project.txt similarity index 100% rename from e2e/fixtures/platforms/android/proguard-project.txt rename to spec/fixtures/platforms/android/proguard-project.txt diff --git a/e2e/fixtures/platforms/android/project.properties b/spec/fixtures/platforms/android/project.properties similarity index 100% rename from e2e/fixtures/platforms/android/project.properties rename to spec/fixtures/platforms/android/project.properties diff --git a/e2e/fixtures/platforms/android/res/drawable-hdpi/icon.png b/spec/fixtures/platforms/android/res/drawable-hdpi/icon.png similarity index 100% rename from e2e/fixtures/platforms/android/res/drawable-hdpi/icon.png rename to spec/fixtures/platforms/android/res/drawable-hdpi/icon.png diff --git a/e2e/fixtures/platforms/android/res/drawable-ldpi/icon.png b/spec/fixtures/platforms/android/res/drawable-ldpi/icon.png similarity index 100% rename from e2e/fixtures/platforms/android/res/drawable-ldpi/icon.png rename to spec/fixtures/platforms/android/res/drawable-ldpi/icon.png diff --git a/e2e/fixtures/platforms/android/res/drawable-mdpi/icon.png b/spec/fixtures/platforms/android/res/drawable-mdpi/icon.png similarity index 100% rename from e2e/fixtures/platforms/android/res/drawable-mdpi/icon.png rename to spec/fixtures/platforms/android/res/drawable-mdpi/icon.png diff --git a/e2e/fixtures/platforms/android/res/drawable-xhdpi/icon.png b/spec/fixtures/platforms/android/res/drawable-xhdpi/icon.png similarity index 100% rename from e2e/fixtures/platforms/android/res/drawable-xhdpi/icon.png rename to spec/fixtures/platforms/android/res/drawable-xhdpi/icon.png diff --git a/e2e/fixtures/platforms/android/res/drawable/icon.png b/spec/fixtures/platforms/android/res/drawable/icon.png similarity index 100% rename from e2e/fixtures/platforms/android/res/drawable/icon.png rename to spec/fixtures/platforms/android/res/drawable/icon.png diff --git a/e2e/fixtures/platforms/android/res/values/strings.xml b/spec/fixtures/platforms/android/res/values/strings.xml similarity index 100% rename from e2e/fixtures/platforms/android/res/values/strings.xml rename to spec/fixtures/platforms/android/res/values/strings.xml diff --git a/e2e/fixtures/platforms/android/res/xml/config.xml b/spec/fixtures/platforms/android/res/xml/config.xml similarity index 100% rename from e2e/fixtures/platforms/android/res/xml/config.xml rename to spec/fixtures/platforms/android/res/xml/config.xml diff --git a/e2e/fixtures/platforms/android/src/org/testing/TestBase.java b/spec/fixtures/platforms/android/src/org/testing/TestBase.java similarity index 100% rename from e2e/fixtures/platforms/android/src/org/testing/TestBase.java rename to spec/fixtures/platforms/android/src/org/testing/TestBase.java diff --git a/e2e/fixtures/plugins/fake1/plugin.xml b/spec/fixtures/plugins/fake1/plugin.xml similarity index 100% rename from e2e/fixtures/plugins/fake1/plugin.xml rename to spec/fixtures/plugins/fake1/plugin.xml diff --git a/e2e/helpers.js b/spec/helpers.js similarity index 100% rename from e2e/helpers.js rename to spec/helpers.js diff --git a/e2e/hooker.spec.js b/spec/hooker.spec.js similarity index 100% rename from e2e/hooker.spec.js rename to spec/hooker.spec.js diff --git a/e2e/platform.spec.js b/spec/platform.spec.js similarity index 100% rename from e2e/platform.spec.js rename to spec/platform.spec.js diff --git a/e2e/plugin.spec.js b/spec/plugin.spec.js similarity index 100% rename from e2e/plugin.spec.js rename to spec/plugin.spec.js From 38db7a2db44fbb251df3af1567699df3b1a3ec1e Mon Sep 17 00:00:00 2001 From: Mark Koudritsky Date: Wed, 9 Apr 2014 15:23:48 -0400 Subject: [PATCH 3/3] CB-6421: Move tests from e2e to spec - cli test After e2e dir was merged into spec/ there were interferences between the e2e tests and cli.spec.js. Jasmine runs all tests in a single process, therefore process-global settings like event listener (un)registration can cause interference between the tests. github: close #159 --- package.json | 2 +- spec/cli.spec.js | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 87d2eb135..ae02211c7 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "cordova": "./bin/cordova" }, "scripts": { - "test": "jasmine-node --color spec e2e" + "test": "jasmine-node --color spec" }, "repository": { "type": "git", diff --git a/spec/cli.spec.js b/spec/cli.spec.js index 835e8eb83..c09042df0 100644 --- a/spec/cli.spec.js +++ b/spec/cli.spec.js @@ -16,11 +16,21 @@ specific language governing permissions and limitations under the License. */ + var CLI = require("../src/cli"), Q = require('q'), + plugman = require('plugman'), cordova = require("../cordova"); describe("cordova cli", function () { + beforeEach(function () { + // Event registration is currently process-global. Since all jasmine + // tests in a directory run in a single process (and in parallel), + // logging events registered as a result of the "--verbose" flag in + // CLI testing below would cause lots of logging messages printed out by other specs. + spyOn(cordova, "on"); + spyOn(plugman, "on"); + }); describe("options", function () { describe("version", function () { @@ -51,10 +61,6 @@ describe("cordova cli", function () { spyOn(cordova.raw, "build").andReturn(Q()); }); - afterEach(function () { - cordova.removeAllListeners(); - }); - it("will call command with all arguments passed through", function () { new CLI(["node", "cordova", "build", "blackberry10", "-k", "abcd1234"]); expect(cordova.raw.build).toHaveBeenCalledWith({verbose: false, silent: false, platforms: ["blackberry10"], options: ["-k", "abcd1234"]}); @@ -91,10 +97,6 @@ describe("cordova cli", function () { spyOn(cordova.raw, "plugin").andReturn(Q()); }); - afterEach(function () { - cordova.removeAllListeners(); - }); - it("will call command with all arguments passed through", function () { new CLI(["node", "cordova", "plugin", "add", "facebook", "--variable", "FOO=foo"]); expect(cordova.raw.plugin).toHaveBeenCalledWith("add", ["facebook", "--variable", "FOO=foo"], {searchpath: undefined});