You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2013/06/13 19:53:14 UTC
[2/2] git commit: most of the way with android parser specs,
fix in platform
most of the way with android parser specs, fix in platform
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/23b9e798
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/23b9e798
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/23b9e798
Branch: refs/heads/lazy
Commit: 23b9e798fe7a96cc4f3f206213c803279244a85e
Parents: a5a861e
Author: Fil Maj <ma...@gmail.com>
Authored: Thu Jun 13 10:53:02 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 13 10:53:02 2013 -0700
----------------------------------------------------------------------
spec/metadata/android_parser.spec.js | 164 ++++++++++++
spec/metadata/blackberry/blackberry.spec.js | 107 ++++++++
.../blackberry/blackberry_parser.spec.js | 248 +++++++++++++++++++
spec/metadata/ios/ios.spec.js | 90 +++++++
spec/metadata/ios/ios_parser.spec.js | 227 +++++++++++++++++
spec/metadata/wp7/wp7.spec.js | 99 ++++++++
spec/metadata/wp7/wp7_parser.spec.js | 247 ++++++++++++++++++
spec/metadata/wp8/wp8.spec.js | 99 ++++++++
spec/metadata/wp8/wp8_parser.spec.js | 247 ++++++++++++++++++
spec/platform-script/android/android.spec.js | 89 -------
.../android/android_parser.spec.js | 244 ------------------
.../blackberry/blackberry.spec.js | 107 --------
.../blackberry/blackberry_parser.spec.js | 248 -------------------
spec/platform-script/ios/ios.spec.js | 90 -------
spec/platform-script/ios/ios_parser.spec.js | 227 -----------------
spec/platform-script/wp7/wp7.spec.js | 99 --------
spec/platform-script/wp7/wp7_parser.spec.js | 247 ------------------
spec/platform-script/wp8/wp8.spec.js | 99 --------
spec/platform-script/wp8/wp8_parser.spec.js | 247 ------------------
src/metadata/android_parser.js | 1 -
src/platform.js | 2 +-
21 files changed, 1529 insertions(+), 1699 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/23b9e798/spec/metadata/android_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/android_parser.spec.js b/spec/metadata/android_parser.spec.js
new file mode 100644
index 0000000..82662fa
--- /dev/null
+++ b/spec/metadata/android_parser.spec.js
@@ -0,0 +1,164 @@
+/**
+ 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 platforms = require('../../platforms'),
+ util = require('../../src/util'),
+ path = require('path'),
+ shell = require('shelljs'),
+ fs = require('fs'),
+ et = require('elementtree'),
+ cordova = require('../../cordova');
+
+describe('android project parser', function() {
+ var proj = '/some/path';
+ var exists, exec;
+ beforeEach(function() {
+ exists = spyOn(fs, 'existsSync').andReturn(true);
+ exec = spyOn(shell, 'exec').andCallFake(function(cmd, opts, cb) {
+ cb(0, 'android-17');
+ });
+ });
+
+ describe('constructions', function() {
+ it('should throw if provided directory does not contain an AndroidManifest.xml', function() {
+ exists.andReturn(false);
+ expect(function() {
+ new platforms.android.parser(proj);
+ }).toThrow('The provided path "/some/path" is not an Android project.');
+ });
+ it('should create an instance with path, strings, manifest and android_config properties', function() {
+ expect(function() {
+ var p = new platforms.android.parser(proj);
+ expect(p.path).toEqual(proj);
+ expect(p.strings).toEqual(path.join(proj, 'res', 'values', 'strings.xml'));
+ expect(p.manifest).toEqual(path.join(proj, 'AndroidManifest.xml'));
+ expect(p.android_config).toEqual(path.join(proj, 'res', 'xml', 'config.xml'));
+ }).not.toThrow();
+ });
+ });
+
+ describe('check_requirements', function() {
+ it('should fire a callback if there is an error during shelling out', function(done) {
+ exec.andCallFake(function(cmd, opts, cb) {
+ cb(50, 'there was an errorz!');
+ });
+ platforms.android.parser.check_requirements(function(err) {
+ expect(err).toContain('there was an errorz!');
+ done();
+ });
+ });
+ it('should fire a callback if `android list target` does not return anything containing "android-17"', function(done) {
+ exec.andCallFake(function(cmd, opts, cb) {
+ cb(0, 'android-15');
+ });
+ platforms.android.parser.check_requirements(function(err) {
+ expect(err).toEqual('Please install Android target 17 (the Android 4.2 SDK). Make sure you have the latest Android tools installed as well. Run `android` from your command-line to install/update any missing SDKs or tools.');
+ done();
+ });
+ });
+ it('should check that `android` is on the path by calling `android list target`', function(done) {
+ platforms.android.parser.check_requirements(function(err) {
+ expect(err).toEqual(false);
+ expect(exec).toHaveBeenCalledWith('android list target', jasmine.any(Object), jasmine.any(Function));
+ done();
+ });
+ });
+ it('should check that we can update an android project by calling `android update project`', function(done) {
+ platforms.android.parser.check_requirements(function(err) {
+ expect(err).toEqual(false);
+ expect(exec.mostRecentCall.args[0]).toMatch(/^android update project -p .*framework -t android-17$/gi);
+ done();
+ });
+ });
+ });
+
+ describe('instance', function() {
+ var p, cp, is_cordova;
+ beforeEach(function() {
+ p = new platforms.android.parser(proj);
+ cp = spyOn(shell, 'cp');
+ is_cordova = spyOn(util, 'isCordova').andReturn(proj);
+ });
+
+ describe('update_from_config method', function() {
+ });
+ describe('www_dir method', function() {
+ });
+ describe('staging_dir method', function() {
+ });
+ describe('config_xml method', function() {
+ });
+ describe('update_www method', function() {
+ });
+ describe('update_overrides method', function() {
+ it('should do nothing if merges directory does not exist', function() {
+ });
+ it('should copy merges path into www', function() {
+ });
+ });
+ describe('update_staging method', function() {
+ it('should do nothing if staging dir does not exist', function() {
+ exists.andReturn(false);
+ p.update_staging();
+ expect(cp).not.toHaveBeenCalled();
+ });
+ it('should copy the staging dir into www if staging dir exists', function() {
+ p.update_staging();
+ expect(cp).toHaveBeenCalled();
+ });
+ });
+ describe('update_project method', function() {
+ var config, www, overrides, staging, svn;
+ beforeEach(function() {
+ config = spyOn(p, 'update_from_config');
+ www = spyOn(p, 'update_www');
+ overrides = spyOn(p, 'update_overrides');
+ staging = spyOn(p, 'update_staging');
+ svn = spyOn(util, 'deleteSvnFolders');
+ });
+ it('should call update_from_config', function() {
+ p.update_project();
+ expect(config).toHaveBeenCalled();
+ });
+ it('should throw if update_from_config throws', function(done) {
+ var err = new Error('uh oh!');
+ config.andCallFake(function() { throw err; });
+ p.update_project({}, function(err) {
+ expect(err).toEqual(err);
+ done();
+ });
+ });
+ it('should call update_www', function() {
+ p.update_project();
+ expect(www).toHaveBeenCalled();
+ });
+ it('should call update_overrides', function() {
+ p.update_project();
+ expect(overrides).toHaveBeenCalled();
+ });
+ it('should call update_staging', function() {
+ p.update_project();
+ expect(staging).toHaveBeenCalled();
+ });
+ it('should call deleteSvnFolders', function() {
+ p.update_project();
+ expect(svn).toHaveBeenCalled();
+ });
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/23b9e798/spec/metadata/blackberry/blackberry.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/blackberry/blackberry.spec.js b/spec/metadata/blackberry/blackberry.spec.js
new file mode 100644
index 0000000..bb59973
--- /dev/null
+++ b/spec/metadata/blackberry/blackberry.spec.js
@@ -0,0 +1,107 @@
+var cordova = require('../../../cordova'),
+ shell = require('shelljs'),
+ path = require('path'),
+ fs = require('fs'),
+ blackberry_parser = require('../../../src/metadata/blackberry_parser'),
+ tempDir = path.join(__dirname, '..', '..', '..', 'temp'),
+ fixtures = path.join(__dirname, '..', '..', 'fixtures'),
+ cordova_project = path.join(fixtures, 'projects', 'cordova');
+
+var cwd = process.cwd();
+
+describe('Test:', function() {
+
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+
+ describe('\'platform add blackberry\'', function() {
+ var sh, cr;
+ var fake_reqs_check = function() {
+ expect(cr.mostRecentCall.args).toBeDefined();
+ cr.mostRecentCall.args[0](false);
+ };
+ var fake_create = function(a_path) {
+ shell.mkdir('-p', path.join(a_path, 'www'));
+ fs.writeFileSync(path.join(a_path, 'project.json'), 'hi', 'utf-8');
+ shell.cp('-rf', path.join(cordova_project, 'platforms', 'blackberry', 'www', 'config.xml'), path.join(a_path, 'www'));
+ sh.mostRecentCall.args[2](0, '');
+ };
+ beforeEach(function() {
+ sh = spyOn(shell, 'exec');
+ cr = spyOn(blackberry_parser, 'check_requirements');
+ shell.rm('-rf', tempDir);
+ cordova.create(tempDir);
+ process.chdir(tempDir);
+ });
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+ it('should check requirements when adding', function() {
+ cordova.platform('add', 'blackberry');
+ expect(blackberry_parser.check_requirements).toHaveBeenCalled();
+ });
+ it('should shell out to blackberry bin/create', function() {
+ cordova.platform('add', 'blackberry');
+ fake_reqs_check();
+ var shell_cmd = sh.mostRecentCall.args[0];
+ var create_cmd = path.join('blackberry', 'bin', 'create');
+ expect(shell_cmd).toContain(create_cmd);
+ });
+ it('should call blackberry_parser\'s update_project', function() {
+ spyOn(blackberry_parser.prototype, 'update_project');
+ cordova.platform('add', 'blackberry');
+ fake_reqs_check();
+ fake_create(path.join(tempDir, 'platforms', 'blackberry'));
+ expect(blackberry_parser.prototype.update_project).toHaveBeenCalled();
+ });
+ });
+
+ describe('\'emulate blackberry\'', function() {
+ beforeEach(function() {
+ process.chdir(tempDir);
+ spyOn(blackberry_parser.prototype, 'get_cordova_config').andReturn({
+ signing_password:'pwd'
+ });
+ });
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+ shell.rm('-rf', tempDir);
+ cordova.create(tempDir);
+ shell.cp('-rf', path.join(cordova_project, 'platforms', 'blackberry'), path.join(tempDir, 'platforms'));
+ it('should shell out to run command with a specific target', function() {
+ var proj_spy = spyOn(blackberry_parser.prototype, 'update_project');
+ spyOn(blackberry_parser.prototype, 'get_all_targets').andReturn([{name:'fakesim',type:'simulator'}]);
+ var s = spyOn(require('shelljs'), 'exec');
+ cordova.emulate('blackberry');
+ proj_spy.mostRecentCall.args[1](); // update_project fake
+ expect(s).toHaveBeenCalled();
+ var emulate_cmd = 'cordova.run" --target=fakesim -k pwd$';
+ expect(s.mostRecentCall.args[0]).toMatch(emulate_cmd);
+ });
+ it('should call blackberry_parser\'s update_project', function() {
+ spyOn(require('shelljs'), 'exec');
+ spyOn(blackberry_parser.prototype, 'update_project');
+ cordova.emulate('blackberry');
+ expect(blackberry_parser.prototype.update_project).toHaveBeenCalled();
+ });
+ });
+
+ describe('\'compile blackberry\'', function() {
+ beforeEach(function() {
+ process.chdir(tempDir);
+ });
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+ shell.rm('-rf', tempDir);
+ cordova.create(tempDir);
+ shell.cp('-rf', path.join(cordova_project, 'platforms', 'blackberry'), path.join(tempDir, 'platforms'));
+ it('should shell out to build command', function() {
+ var s = spyOn(require('shelljs'), 'exec').andReturn({code:0});
+ cordova.compile('blackberry');
+ expect(s.mostRecentCall.args[0]).toMatch(/blackberry.cordova.build"$/gi);
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/23b9e798/spec/metadata/blackberry/blackberry_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/blackberry/blackberry_parser.spec.js b/spec/metadata/blackberry/blackberry_parser.spec.js
new file mode 100644
index 0000000..ec836e4
--- /dev/null
+++ b/spec/metadata/blackberry/blackberry_parser.spec.js
@@ -0,0 +1,248 @@
+/**
+ 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 blackberry_parser = require('../../../src/metadata/blackberry_parser'),
+ config_parser = require('../../../src/config_parser'),
+ path = require('path'),
+ util = require('../../../src/util'),
+ et = require('elementtree'),
+ shell = require('shelljs'),
+ cordova = require('../../../cordova'),
+ fs = require('fs'),
+ projects_path = path.join(__dirname, '..', '..', 'fixtures', 'projects'),
+ blackberry_path = path.join(projects_path, 'native', 'blackberry_fixture'),
+ project_path = path.join(projects_path, 'cordova'),
+ blackberry_project_path = path.join(project_path, 'platforms', 'blackberry');
+
+var www_config = util.projectConfig(project_path);
+var original_www_config = fs.readFileSync(www_config, 'utf-8');
+
+describe('blackberry project parser', function() {
+ beforeEach(function() {
+ spyOn(process.stdout, 'write'); // silence console output
+ });
+
+ it('should throw an exception with a path that is not a native blackberry project', function() {
+ expect(function() {
+ var project = new blackberry_parser(process.cwd());
+ }).toThrow();
+ });
+ it('should accept a proper native blackberry project path as construction parameter', function() {
+ var project;
+ expect(function() {
+ project = new blackberry_parser(blackberry_path);
+ }).not.toThrow();
+ expect(project).toBeDefined();
+ });
+
+ describe('update_from_config method', function() {
+ var project, config;
+
+ var blackberry_config = path.join(blackberry_path, 'www', 'config.xml');
+ var original_blackberry_config = fs.readFileSync(blackberry_config, 'utf-8');
+
+ beforeEach(function() {
+ project = new blackberry_parser(blackberry_path);
+ config = new config_parser(www_config);
+ });
+ afterEach(function() {
+ fs.writeFileSync(blackberry_config, original_blackberry_config, 'utf-8');
+ fs.writeFileSync(www_config, original_www_config, 'utf-8');
+ });
+ it('should throw an exception if a non config_parser object is passed into it', function() {
+ expect(function() {
+ project.update_from_config({});
+ }).toThrow();
+ });
+ it('should update the application name properly', function() {
+ config.name('bond. james bond.');
+ project.update_from_config(config);
+
+ var bb_cfg = new config_parser(blackberry_config);
+
+ expect(bb_cfg.name()).toBe('bond. james bond.');
+ });
+ it('should update the application package name properly', function() {
+ config.packageName('sofa.king.awesome');
+ project.update_from_config(config);
+
+ var bb_cfg = new config_parser(blackberry_config);
+ expect(bb_cfg.packageName()).toBe('sofa.king.awesome');
+ });
+ describe('whitelist', function() {
+ it('should update the whitelist when using access elements with origin attribute', function() {
+ config.access.remove('*');
+ config.access.add('http://blackberry.com');
+ config.access.add('http://rim.com');
+ project.update_from_config(config);
+
+ var bb_cfg = new et.ElementTree(et.XML(fs.readFileSync(blackberry_config, 'utf-8')));
+ var as = bb_cfg.getroot().findall('access');
+ expect(as.length).toEqual(2);
+ expect(as[0].attrib.uri).toEqual('http://blackberry.com');
+ expect(as[1].attrib.uri).toEqual('http://rim.com');
+ });
+ it('should update the whitelist when using access elements with uri attributes', function() {
+ fs.writeFileSync(www_config, fs.readFileSync(www_config, 'utf-8').replace(/origin="\*/,'uri="http://rim.com'), 'utf-8');
+ config = new config_parser(www_config);
+ project.update_from_config(config);
+
+ var bb_cfg = new et.ElementTree(et.XML(fs.readFileSync(blackberry_config, 'utf-8')));
+ var as = bb_cfg.getroot().findall('access');
+ expect(as.length).toEqual(1);
+ expect(as[0].attrib.uri).toEqual('http://rim.com');
+ });
+ });
+ });
+
+ describe('cross-platform project level methods', function() {
+ var parser, config;
+
+ var blackberry_config = path.join(blackberry_project_path, 'www', 'config.xml');
+ var original_blackberry_config = fs.readFileSync(blackberry_config, 'utf-8');
+
+ beforeEach(function() {
+ parser = new blackberry_parser(blackberry_project_path);
+ config = new config_parser(www_config);
+ });
+ afterEach(function() {
+ fs.writeFileSync(blackberry_config, original_blackberry_config, 'utf-8');
+ fs.writeFileSync(www_config, original_www_config, 'utf-8');
+ });
+
+ describe('update_www method', function() {
+ it('should update all www assets', function() {
+ var newFile = path.join(util.projectWww(project_path), 'somescript.js');
+ this.after(function() {
+ shell.rm('-f', newFile);
+ });
+ fs.writeFileSync(newFile, 'alert("sup");', 'utf-8');
+ parser.update_www();
+ expect(fs.existsSync(path.join(blackberry_project_path, 'www', 'somescript.js'))).toBe(true);
+ });
+ it('should not overwrite the blackberry-specific config.xml', function() {
+ var www_cfg = fs.readFileSync(util.projectConfig(project_path), 'utf-8');
+ parser.update_www();
+ var bb_cfg = fs.readFileSync(blackberry_config, 'utf-8');
+ expect(bb_cfg).not.toBe(www_cfg);
+ });
+ });
+
+ describe('update_overrides method',function() {
+ var mergesPath = path.join(util.appDir(project_path), 'merges', 'blackberry');
+ var newFile = path.join(mergesPath, 'merge.js');
+ beforeEach(function() {
+ shell.mkdir('-p', mergesPath);
+ fs.writeFileSync(newFile, 'alert("sup");', 'utf-8');
+ });
+ afterEach(function() {
+ shell.rm('-rf', mergesPath);
+ });
+
+ it('should copy a new file from merges into www', function() {
+ parser.update_overrides();
+ expect(fs.existsSync(path.join(blackberry_project_path, 'www', 'merge.js'))).toBe(true);
+ });
+
+ it('should copy a file from merges over a file in www', function() {
+ var newFileWWW = path.join(util.projectWww(project_path), 'merge.js');
+ fs.writeFileSync(newFileWWW, 'var foo=1;', 'utf-8');
+ this.after(function() {
+ shell.rm('-rf', newFileWWW);
+ });
+ parser.update_overrides();
+ expect(fs.existsSync(path.join(blackberry_project_path, 'www', 'merge.js'))).toBe(true);
+ expect(fs.readFileSync(path.join(blackberry_project_path, 'www', 'merge.js'),'utf-8')).toEqual('alert("sup");');
+ });
+ });
+
+ describe('update_project method', function() {
+ var cordova_config_path = path.join(project_path, '.cordova', 'config.json');
+ var original_config_json = fs.readFileSync(cordova_config_path, 'utf-8');
+
+ describe('with stubbed out config for BlackBerry SDKs', function() {
+ beforeEach(function() {
+ fs.writeFileSync(cordova_config_path, JSON.stringify({
+ blackberry:{
+ qnx:{
+ }
+ }
+ }), 'utf-8');
+ });
+ afterEach(function() {
+ fs.writeFileSync(cordova_config_path, original_config_json, 'utf-8');
+ });
+ it('should invoke update_www', function() {
+ var spyWww = spyOn(parser, 'update_www');
+ parser.update_project(config);
+ expect(spyWww).toHaveBeenCalled();
+ });
+ it('should invoke update_from_config', function() {
+ var spyConfig = spyOn(parser, 'update_from_config');
+ parser.update_project(config);
+ expect(spyConfig).toHaveBeenCalled();
+ });
+ it('should not invoke get_blackberry_environment', function() {
+ var spyEnv = spyOn(parser, 'get_blackberry_environment');
+ parser.update_project(config);
+ expect(spyEnv).not.toHaveBeenCalled();
+ });
+ it('should write out project properties', function(done) {
+ var spyProps = spyOn(parser, 'write_blackberry_environment');
+ parser.update_project(config, function() {
+ expect(spyProps).toHaveBeenCalled();
+ done();
+ });
+ });
+ it('should call out to util.deleteSvnFolders', function(done) {
+ var spy = spyOn(util, 'deleteSvnFolders');
+ parser.update_project(config, function() {
+ expect(spy).toHaveBeenCalled();
+ done();
+ });
+ });
+ });
+ describe('with empty BlackBerry SDKs in config', function() {
+ afterEach(function() {
+ fs.writeFileSync(cordova_config_path, original_config_json, 'utf-8');
+ });
+ it('should invoke get_blackberry_environment', function() {
+ var spyEnv = spyOn(parser, 'get_blackberry_environment');
+ var promptSpy = spyOn(require('prompt'), 'get');
+ parser.update_project(config);
+ expect(spyEnv).toHaveBeenCalled();
+ });
+ it('should write out project properties', function(done) {
+ var spyProps = spyOn(parser, 'write_blackberry_environment');
+ var promptSpy = spyOn(require('prompt'), 'get');
+ parser.update_project(config, function() {
+ expect(spyProps).toHaveBeenCalled();
+ done();
+ });
+ promptSpy.mostRecentCall.args[1](null, {});
+ });
+ });
+ });
+ });
+
+ describe('write_project_properties method', function() {
+ });
+
+ describe('get_blackberry_environment method', function() {
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/23b9e798/spec/metadata/ios/ios.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/ios/ios.spec.js b/spec/metadata/ios/ios.spec.js
new file mode 100644
index 0000000..2723b83
--- /dev/null
+++ b/spec/metadata/ios/ios.spec.js
@@ -0,0 +1,90 @@
+var cordova = require('../../../cordova'),
+ shell = require('shelljs'),
+ path = require('path'),
+ fs = require('fs'),
+ ios_parser = require('../../../src/metadata/ios_parser'),
+ tempDir = path.join(__dirname, '..', '..', '..', 'temp'),
+ fixtures = path.join(__dirname, '..', '..', 'fixtures'),
+ cordova_project = path.join(fixtures, 'projects', 'cordova');
+
+var cwd = process.cwd();
+
+describe('Test:', function() {
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+
+ describe('\'platform add ios\'', function() {
+ var sh, cr;
+ var fake_reqs_check = function() {
+ cr.mostRecentCall.args[0](false);
+ };
+ var fake_create = function(a_path) {
+ shell.mkdir('-p', a_path);
+ fs.writeFileSync(path.join(a_path, 'poo.xcodeproj'), 'hi', 'utf-8');
+ shell.mkdir('-p', path.join(a_path, 'poo'));
+ shell.cp(path.join(cordova_project, 'www', 'config.xml'), path.join(a_path, 'poo', 'config.xml'));
+ sh.mostRecentCall.args[2](0, '');
+ };
+ beforeEach(function() {
+ sh = spyOn(shell, 'exec');
+ cr = spyOn(ios_parser, 'check_requirements');
+ shell.rm('-rf', tempDir);
+ cordova.create(tempDir);
+ process.chdir(tempDir);
+ });
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+ it('should shell out to ios /bin/create', function() {
+ cordova.platform('add', 'ios');
+ fake_reqs_check();
+ var shell_cmd = sh.mostRecentCall.args[0];
+ var create_cmd = path.join('ios', 'bin', 'create');
+ expect(shell_cmd).toContain(create_cmd);
+ });
+ it('should call ios_parser\'s update_project', function() {
+ spyOn(ios_parser.prototype, 'update_project');
+ cordova.platform('add', 'ios');
+ fake_reqs_check();
+ fake_create(path.join(tempDir, 'platforms', 'ios'));
+ expect(ios_parser.prototype.update_project).toHaveBeenCalled();
+ });
+ });
+
+ describe('\'emulate ios\'', function() {
+ beforeEach(function() {
+ process.chdir(tempDir);
+ });
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+ shell.rm('-rf', tempDir);
+ cordova.create(tempDir);
+ shell.cp('-rf', path.join(cordova_project, 'platforms', 'ios'), path.join(tempDir, 'platforms'));
+ it('should call ios_parser\'s update_project', function() {
+ spyOn(require('shelljs'), 'exec');
+ spyOn(ios_parser.prototype, 'update_project');
+ cordova.emulate('ios');
+ expect(ios_parser.prototype.update_project).toHaveBeenCalled();
+ });
+ });
+
+ describe('\'compile ios\'', function() {
+ beforeEach(function() {
+ process.chdir(tempDir);
+ });
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+ shell.rm('-rf', tempDir);
+ cordova.create(tempDir);
+ shell.cp('-rf', path.join(cordova_project, 'platforms', 'ios'), path.join(tempDir, 'platforms'));
+ it('should shell out to build command', function() {
+ var build_cmd = path.join('ios', 'cordova', 'build');
+ var s = spyOn(require('shelljs'), 'exec').andReturn({code:0});
+ cordova.compile('ios');
+ expect(s.mostRecentCall.args[0]).toContain(build_cmd);
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/23b9e798/spec/metadata/ios/ios_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/ios/ios_parser.spec.js b/spec/metadata/ios/ios_parser.spec.js
new file mode 100644
index 0000000..25f7833
--- /dev/null
+++ b/spec/metadata/ios/ios_parser.spec.js
@@ -0,0 +1,227 @@
+/**
+ 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 ios_parser = require('../../../src/metadata/ios_parser'),
+ config_parser = require('../../../src/config_parser'),
+ cordova = require('../../../cordova'),
+ util = require('../../../src/util'),
+ path = require('path'),
+ shell = require('shelljs'),
+ fs = require('fs'),
+ os = require('os'),
+ et = require('elementtree'),
+ projects_path = path.join(__dirname, '..', '..', 'fixtures', 'projects')
+ ios_path = path.join(projects_path, 'native', 'ios_fixture'),
+ project_path = path.join(projects_path, 'cordova'),
+ ios_project_path = path.join(project_path, 'platforms', 'ios');
+
+var www_config = util.projectConfig(project_path);
+var original_www_config = fs.readFileSync(www_config, 'utf-8');
+
+describe('ios project parser', function () {
+ it('should throw an exception with a path that is not a native ios project', function () {
+ expect(function () {
+ var project = new ios_parser(process.cwd());
+ }).toThrow();
+ });
+ it('should accept a proper native ios project path as construction parameter', function () {
+ var project;
+ expect(function () {
+ project = new ios_parser(ios_path);
+ }).not.toThrow();
+ expect(project).toBeDefined();
+ });
+
+ describe('update_from_config method', function () {
+ var project, config;
+
+ var ios_plist = path.join(ios_path, 'cordovaExample', 'cordovaExample-Info.plist'),
+ ios_pbx = path.join(ios_path, 'cordovaExample.xcodeproj', 'project.pbxproj'),
+ ios_config_xml = path.join(ios_path, 'cordovaExample', 'config.xml');
+
+ var original_pbx = fs.readFileSync(ios_pbx, 'utf-8');
+ var original_plist = fs.readFileSync(ios_plist, 'utf-8');
+ var original_ios_config = fs.readFileSync(ios_config_xml, 'utf-8');
+
+ beforeEach(function () {
+ project = new ios_parser(ios_path);
+ config = new config_parser(www_config);
+ });
+ afterEach(function () {
+ fs.writeFileSync(ios_pbx, original_pbx, 'utf-8');
+ fs.writeFileSync(ios_config_xml, original_ios_config, 'utf-8');
+ fs.writeFileSync(ios_plist, original_plist, 'utf-8');
+ fs.writeFileSync(www_config, original_www_config, 'utf-8');
+ });
+ it('should throw an exception if a non config_parser object is passed into it', function () {
+ expect(function () {
+ project.update_from_config({});
+ }).toThrow();
+ });
+ it('should update the application name properly', function (done) {
+ config.name('bond. james bond.');
+ project.update_from_config(config, function () {
+ var pbx_contents = fs.readFileSync(ios_pbx, 'utf-8');
+ expect(pbx_contents.match(/PRODUCT_NAME\s*=\s*"bond. james bond."/)[0]).toBe('PRODUCT_NAME = "bond. james bond."');
+ done();
+ });
+ });
+ it('should update the application package name (bundle identifier) properly', function (done) {
+ config.packageName('ca.filmaj.dewd');
+ project.update_from_config(config, function () {
+ var plist_contents = fs.readFileSync(ios_plist, 'utf-8');
+ expect(plist_contents).toMatch(/<string>ca.filmaj.dewd/);
+ done();
+ });
+ });
+ it('should update the application version (CFBundleVersion) properly', function (done) {
+ config.version('2.0.1');
+ project.update_from_config(config, function () {
+ var plist_contents = fs.readFileSync(ios_plist, 'utf-8');
+ expect(plist_contents).toMatch(/<string>2.0.1/);
+ done();
+ });
+ });
+ it('should update the whitelist in the project config.xml', function (done) {
+ project.update_from_config(config, function () {
+ var config_contents = fs.readFileSync(ios_config_xml, 'utf-8');
+ expect(config_contents).toMatch(/<access origin="\*" \/>/);
+ done();
+ });
+ });
+ describe('preferences', function () {
+ it('should not change default project preferences and copy over additional project preferences to platform-level config.xml', function (done) {
+ config.preference.add({name:'henrik', value:'sedin'});
+ project.update_from_config(config, function () {
+ var native_config = new et.ElementTree(et.XML(fs.readFileSync(ios_config_xml, 'utf-8')));
+ var ps = native_config.findall('preference');
+ expect(ps.length).toEqual(17);
+ expect(ps[0].attrib.name).toEqual('KeyboardDisplayRequiresUserAction');
+ expect(ps[0].attrib.value).toEqual('true');
+ expect(ps[16].attrib.name).toEqual('henrik');
+ expect(ps[16].attrib.value).toEqual('sedin');
+ done();
+ });
+ });
+ it('should override a default project preference if applicable', function (done) {
+ config.preference.add({name:'UIWebViewBounce', value:'false'});
+ project.update_from_config(config, function () {
+ var native_config = new et.ElementTree(et.XML(fs.readFileSync(ios_config_xml, 'utf-8')));
+ var ps = native_config.findall('preference');
+ expect(ps.length).toEqual(16);
+ expect(ps[2].attrib.name).toEqual('UIWebViewBounce');
+ expect(ps[2].attrib.value).toEqual('false');
+ done();
+ });
+ });
+ });
+ });
+
+ describe('cross-platform project level methods', function () {
+ var parser, config;
+ var ios_plist = path.join(ios_project_path, 'cordovaExample', 'cordovaExample-Info.plist'),
+ ios_pbx = path.join(ios_project_path, 'cordovaExample.xcodeproj', 'project.pbxproj'),
+ ios_config_xml = path.join(ios_project_path, 'cordovaExample', 'config.xml');
+
+ var original_pbx = fs.readFileSync(ios_pbx, 'utf-8');
+ var original_plist = fs.readFileSync(ios_plist, 'utf-8');
+ var original_ios_config = fs.readFileSync(ios_config_xml, 'utf-8');
+
+ beforeEach(function () {
+ parser = new ios_parser(ios_project_path);
+ config = new config_parser(www_config);
+ });
+ afterEach(function () {
+ fs.writeFileSync(ios_pbx, original_pbx, 'utf-8');
+ fs.writeFileSync(ios_config_xml, original_ios_config, 'utf-8');
+ fs.writeFileSync(ios_plist, original_plist, 'utf-8');
+ fs.writeFileSync(www_config, original_www_config, 'utf-8');
+ });
+
+ describe('update_www method', function () {
+ it('should update all www assets', function () {
+ var newFile = path.join(util.projectWww(project_path), 'somescript.js');
+ this.after(function () {
+ shell.rm('-f', newFile);
+ });
+ fs.writeFileSync(newFile, 'alert("sup");', 'utf-8');
+ parser.update_www();
+ expect(fs.existsSync(path.join(ios_project_path, 'www', 'somescript.js'))).toBe(true);
+ });
+ it('should write out ios js to cordova.js', function () {
+ parser.update_www();
+ expect(fs.readFileSync(path.join(ios_project_path, 'www', 'cordova.js'), 'utf-8')).toBe(fs.readFileSync(path.join(util.libDirectory, 'cordova-ios', 'CordovaLib', 'cordova.js'), 'utf-8'));
+ });
+ });
+
+ describe('update_overrides method', function () {
+ var mergesPath = path.join(util.appDir(project_path), 'merges', 'ios');
+ var newFile = path.join(mergesPath, 'merge.js');
+ beforeEach(function() {
+ shell.mkdir('-p', mergesPath);
+ fs.writeFileSync(newFile, 'alert("sup");', 'utf-8');
+ });
+ afterEach(function() {
+ shell.rm('-rf', mergesPath);
+ });
+
+ it('should copy a new file from merges into www', function () {
+ parser.update_overrides();
+ expect(fs.existsSync(path.join(ios_project_path, 'www', 'merge.js'))).toBe(true);
+ });
+
+ it('should copy a file from merges over a file in www', function () {
+ var newFileWWW = path.join(util.projectWww(project_path), 'merge.js');
+ fs.writeFileSync(newFileWWW, 'var foo=1;', 'utf-8');
+ this.after(function () {
+ shell.rm('-rf', newFileWWW);
+ });
+
+ parser.update_overrides();
+ expect(fs.existsSync(path.join(ios_project_path, 'www', 'merge.js'))).toBe(true);
+ expect(fs.readFileSync(path.join(ios_project_path, 'www', 'merge.js'), 'utf-8')).toEqual('alert("sup");');
+ });
+ });
+
+ describe('update_project method', function () {
+ it('should invoke update_www', function (done) {
+ var spyWww = spyOn(parser, 'update_www');
+ parser.update_project(config, function () {
+ expect(spyWww).toHaveBeenCalled();
+ done();
+ });
+ });
+ it('should invoke update_from_config', function (done) {
+ var spyConfig = spyOn(parser, 'update_from_config').andCallThrough();
+ parser.update_project(config, function () {
+ expect(spyConfig).toHaveBeenCalled();
+ done();
+ });
+ });
+ it('should call out to util.deleteSvnFolders', function(done) {
+ var spy = spyOn(util, 'deleteSvnFolders');
+ var spyConfig = spyOn(parser, 'update_from_config').andCallThrough();
+ parser.update_project(config, function () {
+ expect(spy).toHaveBeenCalled();
+ done();
+ });
+ });
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/23b9e798/spec/metadata/wp7/wp7.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/wp7/wp7.spec.js b/spec/metadata/wp7/wp7.spec.js
new file mode 100644
index 0000000..6b7f3b4
--- /dev/null
+++ b/spec/metadata/wp7/wp7.spec.js
@@ -0,0 +1,99 @@
+var cordova = require('../../../cordova'),
+ shell = require('shelljs'),
+ path = require('path'),
+ fs = require('fs'),
+ wp7_parser = require('../../../src/metadata/wp7_parser'),
+ tempDir = path.join(__dirname, '..', '..', '..', 'temp'),
+ fixtures = path.join(__dirname, '..', '..', 'fixtures'),
+ cordova_project = path.join(fixtures, 'projects', 'cordova');
+
+var cwd = process.cwd();
+
+describe('Test:', function() {
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+
+ describe('\'platform add wp7\'', function() {
+ var sh, cr;
+ var fake_reqs_check = function() {
+ expect(cr.mostRecentCall.args).toBeDefined();
+ cr.mostRecentCall.args[0](false);
+ };
+ var fake_create = function(a_path) {
+ shell.mkdir('-p', a_path);
+ fs.writeFileSync(path.join(a_path, 'wp7Project.csproj'), 'hi', 'utf-8');
+ fs.writeFileSync(path.join(a_path, 'wp7Project.sln'), 'hi', 'utf-8');
+ sh.mostRecentCall.args[2](0, '');
+ };
+ beforeEach(function() {
+ sh = spyOn(shell, 'exec');
+ cr = spyOn(wp7_parser, 'check_requirements');
+ shell.rm('-rf', tempDir);
+ cordova.create(tempDir);
+ process.chdir(tempDir);
+ });
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+ it('should shell out to wp7 /bin/create', function() {
+ cordova.platform('add', 'wp7');
+ fake_reqs_check();
+ var shell_cmd = sh.mostRecentCall.args[0];
+ var create_cmd = path.join('wp7', 'bin', 'create');
+ expect(shell_cmd).toContain(create_cmd);
+ });
+ it('should call wp7_parser\'s update_project', function() {
+ spyOn(wp7_parser.prototype, 'update_project');
+ cordova.platform('add', 'wp7');
+ fake_reqs_check();
+ fake_create(path.join(tempDir, 'platforms', 'wp7'));
+ expect(wp7_parser.prototype.update_project).toHaveBeenCalled();
+ });
+ });
+
+ describe('\'emulate wp7\'', function() {
+ beforeEach(function() {
+ process.chdir(tempDir);
+ });
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+ shell.rm('-rf', tempDir);
+ cordova.create(tempDir);
+ shell.cp('-rf', path.join(cordova_project, 'platforms', 'wp7'), path.join(tempDir, 'platforms'));
+ it('should shell out to run command on wp7', function() {
+ var proj_spy = spyOn(wp7_parser.prototype, 'update_project');
+ var s = spyOn(require('shelljs'), 'exec');
+ cordova.emulate('wp7');
+ proj_spy.mostRecentCall.args[1](); // update_project fake
+ expect(s).toHaveBeenCalled();
+ var emulate_cmd = path.join('wp7', 'cordova', 'run');
+ expect(s.mostRecentCall.args[0]).toContain(emulate_cmd);
+ });
+ it('should call wp7_parser\'s update_project', function() {
+ spyOn(require('shelljs'), 'exec');
+ spyOn(wp7_parser.prototype, 'update_project');
+ cordova.emulate('wp7');
+ expect(wp7_parser.prototype.update_project).toHaveBeenCalled();
+ });
+ });
+
+ describe('\'compile wp7\'', function() {
+ beforeEach(function() {
+ process.chdir(tempDir);
+ });
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+ shell.rm('-rf', tempDir);
+ cordova.create(tempDir);
+ shell.cp('-rf', path.join(cordova_project, 'platforms', 'wp7'), path.join(tempDir, 'platforms'));
+ it('should shell out to build command', function() {
+ var build_cmd = path.join('wp7', 'cordova', 'build');
+ var s = spyOn(require('shelljs'), 'exec').andReturn({code:0});
+ cordova.compile('wp7');
+ expect(s.mostRecentCall.args[0]).toContain(build_cmd);
+ });
+ });
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/23b9e798/spec/metadata/wp7/wp7_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/wp7/wp7_parser.spec.js b/spec/metadata/wp7/wp7_parser.spec.js
new file mode 100644
index 0000000..61111a1
--- /dev/null
+++ b/spec/metadata/wp7/wp7_parser.spec.js
@@ -0,0 +1,247 @@
+
+/**
+ 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 wp7_parser = require('../../../src/metadata/wp7_parser'),
+ config_parser = require('../../../src/config_parser'),
+ util = require('../../../src/util'),
+ path = require('path'),
+ shell = require('shelljs'),
+ fs = require('fs'),
+ os = require('os'),
+ et = require('elementtree'),
+ cordova = require('../../../cordova'),
+ projects_path = path.join(__dirname, '..', '..', 'fixtures', 'projects'),
+ wp7_path = path.join(projects_path, 'native', 'wp7_fixture'),
+ project_path = path.join(projects_path, 'cordova'),
+ wp7_project_path = path.join(project_path, 'platforms', 'wp7');
+
+var www_config = util.projectConfig(project_path);
+var original_www_config = fs.readFileSync(www_config, 'utf-8');
+
+describe('wp7 project parser', function() {
+ it('should throw an exception with a path that is not a native wp7 project', function() {
+ expect(function() {
+ var project = new wp7_parser(process.cwd());
+ }).toThrow();
+ });
+ it('should accept a proper native wp7 project path as construction parameter', function() {
+ expect(function() {
+ var project = new wp7_parser(wp7_path);
+ expect(project).toBeDefined();
+ }).not.toThrow();
+ });
+
+ describe('update_from_config method', function() {
+ var config;
+ var project = new wp7_parser(wp7_path);
+
+ var manifest_path = path.join(wp7_path, 'Properties', 'WMAppManifest.xml');
+ var csproj_path = project.csproj_path;
+ var sln_path = project.sln_path;
+ var app_xaml_path = path.join(wp7_path, 'App.xaml');
+ var app_cs_path = path.join(wp7_path, 'App.xaml.cs');
+ var main_xaml_path = path.join(wp7_path, 'MainPage.xaml');
+ var main_cs_path = path.join(wp7_path, 'MainPage.xaml.cs');
+
+
+ var original_manifest = fs.readFileSync(manifest_path, 'utf-8');
+ var original_csproj = fs.readFileSync(csproj_path, 'utf-8');
+ var original_sln = fs.readFileSync(sln_path, 'utf-8');
+ var original_app_xaml = fs.readFileSync(app_xaml_path, 'utf-8');
+ var original_app_cs = fs.readFileSync(app_cs_path, 'utf-8');
+ var original_main_xaml = fs.readFileSync(main_xaml_path, 'utf-8');
+ var original_main_cs = fs.readFileSync(main_cs_path, 'utf-8');
+
+ beforeEach(function() {
+ project = new wp7_parser(wp7_path);
+ config = new config_parser(www_config);
+ });
+ afterEach(function() {
+ fs.writeFileSync(manifest_path, original_manifest, 'utf-8');
+ // csproj file changes name if app changes name
+ fs.unlinkSync(project.csproj_path);
+ fs.unlinkSync(project.sln_path);
+ fs.writeFileSync(csproj_path, original_csproj, 'utf-8');
+ fs.writeFileSync(sln_path, original_sln, 'utf-8');
+ fs.writeFileSync(app_xaml_path, original_app_xaml, 'utf-8');
+ fs.writeFileSync(app_cs_path, original_app_cs, 'utf-8');
+ fs.writeFileSync(main_xaml_path, original_main_xaml, 'utf-8');
+ fs.writeFileSync(main_cs_path, original_main_cs, 'utf-8');
+ });
+ it('should throw an exception if a non config_parser object is passed into it', function() {
+ expect(function() {
+ project.update_from_config({});
+ }).toThrow();
+ });
+ it('should update the application name properly', function() {
+ var test_name = 'bond. james bond.';
+ config.name(test_name);
+ project.update_from_config(config);
+ var raw_manifest = fs.readFileSync(manifest_path, 'utf-8');
+ //Strip three bytes that windows adds (http://www.multiasking.com/2012/11/851)
+ var cleaned_manifest = raw_manifest.replace('\ufeff', '');
+ var manifest = new et.ElementTree(et.XML(cleaned_manifest));
+ var app_name = manifest.find('.//App[@Title]')['attrib']['Title'];
+ expect(app_name).toBe(test_name);
+
+ //check for the proper name of csproj and solution files
+ test_name = test_name.replace(/(\.\s|\s\.|\s+|\.+)/g, '_'); //make it a ligitamate name
+ expect(project.csproj_path).toContain(test_name);
+ expect(project.sln_path).toContain(test_name);
+ });
+ it('should update the application package name properly', function() {
+ var test_package = 'ca.filmaj.dewd'
+ config.packageName(test_package);
+ project.update_from_config(config);
+
+ // check csproj file (use regex instead of elementtree?)
+ var raw_csproj = fs.readFileSync(project.csproj_path, 'utf-8');
+ var cleaned_csproj = raw_csproj.replace(/^\uFEFF/i, '');
+ var csproj = new et.ElementTree(et.XML(cleaned_csproj));
+ expect(csproj.find('.//RootNamespace').text).toEqual(test_package);
+ expect(csproj.find('.//AssemblyName').text).toEqual(test_package);
+ expect(csproj.find('.//XapFilename').text).toEqual(test_package + '.xap');
+ expect(csproj.find('.//SilverlightAppEntry').text).toEqual(test_package + '.App');
+
+ // check app.xaml (use regex instead of elementtree?)
+ var new_app_xaml = fs.readFileSync(app_xaml_path, 'utf-8');
+ var cleaned_app_xaml = new_app_xaml.replace(/^\uFEFF/i, '');
+ var app_xaml = new et.ElementTree(et.XML(cleaned_app_xaml));
+ expect(app_xaml._root.attrib['x:Class']).toEqual(test_package + '.App');
+
+ // check app.xaml.cs
+ var new_app_cs = fs.readFileSync(app_cs_path, 'utf-8');
+ expect(new_app_cs).toContain('namespace ' + test_package);
+
+ // check MainPage.xaml (use regex instead of elementtree?)
+ var new_main_xaml = fs.readFileSync(main_xaml_path, 'utf-8');
+ var cleaned_main_xaml = new_main_xaml.replace(/^\uFEFF/i, '');
+ var main_xaml = new et.ElementTree(et.XML(cleaned_main_xaml));
+ expect(main_xaml._root.attrib['x:Class']).toEqual(test_package + '.MainPage');
+
+ //check MainPage.xaml.cs
+ var new_main_cs = fs.readFileSync(main_cs_path, 'utf-8');
+ expect(new_main_cs).toContain('namespace ' + test_package);
+ });
+ xdescribe('preferences', function() {
+ it('should not change default project preferences and copy over additional project preferences to platform-level config.xml', function() {
+ /*config.preference.add({name:'henrik',value:'sedin'});
+ project.update_from_config(config);
+
+ var native_config = new et.ElementTree(et.XML(fs.readFileSync(android_config, 'utf-8')));
+ var ps = native_config.findall('preference');
+ expect(ps.length).toEqual(7);
+ expect(ps[0].attrib.name).toEqual('useBrowserHistory');
+ expect(ps[0].attrib.value).toEqual('true');
+ expect(ps[6].attrib.name).toEqual('henrik');
+ expect(ps[6].attrib.value).toEqual('sedin');*/
+
+ // TODO : figure out if this is supported
+ //expect(true).toBe(false);
+ });
+ it('should override a default project preference if applicable', function() {
+ /*config.preference.add({name:'useBrowserHistory',value:'false'});
+ project.update_from_config(config);
+
+ var native_config = new et.ElementTree(et.XML(fs.readFileSync(android_config, 'utf-8')));
+ var ps = native_config.findall('preference');
+ expect(ps.length).toEqual(6);
+ expect(ps[0].attrib.name).toEqual('useBrowserHistory');
+ expect(ps[0].attrib.value).toEqual('false');*/
+
+ // TODO : figure out if this is supported
+ //expect(true).toBe(false);
+ });
+ });
+ });
+
+ describe('cross-platform project level methods', function() {
+ var parser, config;
+
+ beforeEach(function() {
+ parser = new wp7_parser(wp7_project_path);
+ config = new config_parser(www_config);
+ });
+ afterEach(function() {
+ });
+ describe('update_www method', function() {
+ it('should update all www assets', function() {
+ var newFile = path.join(util.projectWww(project_path), 'somescript.js');
+ this.after(function() {
+ shell.rm('-f', newFile);
+ });
+ fs.writeFileSync(newFile, 'alert("sup");', 'utf-8');
+ parser.update_www();
+ expect(fs.existsSync(path.join(wp7_project_path, 'www', 'somescript.js'))).toBe(true);
+ });
+ it('should write out windows-phone js to cordova.js', function() {
+ parser.update_www();
+ expect(fs.readFileSync(path.join(wp7_project_path, 'www', 'cordova.js'),'utf-8')).toEqual(fs.readFileSync(path.join(util.libDirectory, 'cordova-wp7', 'templates', 'standalone', 'www', 'cordova.js'), 'utf-8'));
+ });
+ });
+
+ xdescribe('update_overrides method',function() {
+ /*var mergesPath = path.join(util.appDir(project_path), 'merges', 'android');
+ var newFile = path.join(mergesPath, 'merge.js');
+ beforeEach(function() {
+ shell.mkdir('-p', mergesPath);
+ fs.writeFileSync(newFile, 'alert("sup");', 'utf-8');
+ });
+ afterEach(function() {
+ shell.rm('-rf', mergesPath);
+ });
+ it('should copy a new file from merges into www', function() {
+ parser.update_overrides();
+ expect(fs.existsSync(path.join(wp7_project_path, 'assets', 'www', 'merge.js'))).toBe(true);
+ });
+
+ it('should copy a file from merges over a file in www', function() {
+ var newFileWWW = path.join(util.projectWww(project_path), 'merge.js');
+ fs.writeFileSync(newFileWWW, 'var foo=1;', 'utf-8');
+ this.after(function() {
+ shell.rm('-rf', newFileWWW);
+ });
+ parser.update_overrides();
+ expect(fs.existsSync(path.join(wp7_project_path, 'assets', 'www', 'merge.js'))).toBe(true);
+ expect(fs.readFileSync(path.join(wp7_project_path, 'assets', 'www', 'merge.js'),'utf-8')).toEqual('alert("sup");');
+ });*/
+
+ // TODO : figure out if this is supported
+ //expect(true).toBe(false);
+ });
+
+ describe('update_project method', function() {
+ it('should invoke update_www', function() {
+ var spyWww = spyOn(parser, 'update_www');
+ parser.update_project(config);
+ expect(spyWww).toHaveBeenCalled();
+ });
+ it('should invoke update_from_config', function() {
+ var spyConfig = spyOn(parser, 'update_from_config');
+ parser.update_project(config);
+ expect(spyConfig).toHaveBeenCalled();
+ });
+ it('should call out to util.deleteSvnFolders', function() {
+ var spy = spyOn(util, 'deleteSvnFolders');
+ parser.update_project(config);
+ expect(spy).toHaveBeenCalled();
+ });
+ });
+ });
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/23b9e798/spec/metadata/wp8/wp8.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/wp8/wp8.spec.js b/spec/metadata/wp8/wp8.spec.js
new file mode 100644
index 0000000..998094c
--- /dev/null
+++ b/spec/metadata/wp8/wp8.spec.js
@@ -0,0 +1,99 @@
+var cordova = require('../../../cordova'),
+ shell = require('shelljs'),
+ path = require('path'),
+ fs = require('fs'),
+ wp8_parser = require('../../../src/metadata/wp8_parser'),
+ tempDir = path.join(__dirname, '..', '..', '..', 'temp'),
+ fixtures = path.join(__dirname, '..', '..', 'fixtures'),
+ cordova_project = path.join(fixtures, 'projects', 'cordova');
+
+var cwd = process.cwd();
+
+describe('Test:', function() {
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+
+ describe('\'platform add wp8\'', function() {
+ var sh, cr;
+ var fake_reqs_check = function() {
+ expect(cr.mostRecentCall.args).toBeDefined();
+ cr.mostRecentCall.args[0](false);
+ };
+ var fake_create = function(a_path) {
+ shell.mkdir('-p', a_path);
+ fs.writeFileSync(path.join(a_path, 'wp7Project.csproj'), 'hi', 'utf-8');
+ fs.writeFileSync(path.join(a_path, 'wp7Project.sln'), 'hi', 'utf-8');
+ sh.mostRecentCall.args[2](0, '');
+ };
+ beforeEach(function() {
+ sh = spyOn(shell, 'exec');
+ cr = spyOn(wp8_parser, 'check_requirements');
+ shell.rm('-rf', tempDir);
+ cordova.create(tempDir);
+ process.chdir(tempDir);
+ });
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+ it('should shell out to wp8 /bin/create', function() {
+ cordova.platform('add', 'wp8');
+ fake_reqs_check();
+ var shell_cmd = sh.mostRecentCall.args[0];
+ var create_cmd = path.join('wp8', 'bin', 'create');
+ expect(shell_cmd).toContain(create_cmd);
+ });
+ it('should call wp8_parser\'s update_project', function() {
+ spyOn(wp8_parser.prototype, 'update_project');
+ cordova.platform('add', 'wp8');
+ fake_reqs_check();
+ fake_create(path.join(tempDir, 'platforms', 'wp8'));
+ expect(wp8_parser.prototype.update_project).toHaveBeenCalled();
+ });
+ });
+
+ describe('\'emulate wp8\'', function() {
+ beforeEach(function() {
+ process.chdir(tempDir);
+ });
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+ shell.rm('-rf', tempDir);
+ cordova.create(tempDir);
+ shell.cp('-rf', path.join(cordova_project, 'platforms', 'wp8'), path.join(tempDir, 'platforms'));
+ it('should shell out to run command on wp8', function() {
+ var proj_spy = spyOn(wp8_parser.prototype, 'update_project');
+ var s = spyOn(require('shelljs'), 'exec');
+ cordova.emulate('wp8');
+ proj_spy.mostRecentCall.args[1](); // update_project fake
+ expect(s).toHaveBeenCalled();
+ var emulate_cmd = path.join('wp8', 'cordova', 'run');
+ expect(s.mostRecentCall.args[0]).toContain(emulate_cmd);
+ });
+ it('should call wp8_parser\'s update_project', function() {
+ spyOn(require('shelljs'), 'exec');
+ spyOn(wp8_parser.prototype, 'update_project');
+ cordova.emulate('wp8');
+ expect(wp8_parser.prototype.update_project).toHaveBeenCalled();
+ });
+ });
+
+ describe('\'compile wp8\'', function() {
+ beforeEach(function() {
+ process.chdir(tempDir);
+ });
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+ shell.rm('-rf', tempDir);
+ cordova.create(tempDir);
+ shell.cp('-rf', path.join(cordova_project, 'platforms', 'wp8'), path.join(tempDir, 'platforms'));
+ it('should shell out to build command', function() {
+ var build_cmd = path.join('wp8', 'cordova', 'build');
+ var s = spyOn(require('shelljs'), 'exec').andReturn({code:0});
+ cordova.compile('wp8');
+ expect(s.mostRecentCall.args[0]).toContain(build_cmd);
+ });
+ });
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/23b9e798/spec/metadata/wp8/wp8_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/wp8/wp8_parser.spec.js b/spec/metadata/wp8/wp8_parser.spec.js
new file mode 100644
index 0000000..9f1f2d4
--- /dev/null
+++ b/spec/metadata/wp8/wp8_parser.spec.js
@@ -0,0 +1,247 @@
+
+/**
+ 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 wp8_parser = require('../../../src/metadata/wp8_parser'),
+ config_parser = require('../../../src/config_parser'),
+ util = require('../../../src/util'),
+ path = require('path'),
+ shell = require('shelljs'),
+ fs = require('fs'),
+ os = require('os'),
+ et = require('elementtree'),
+ cordova = require('../../../cordova'),
+ projects_path = path.join(__dirname, '..', '..', 'fixtures', 'projects'),
+ wp8_path = path.join(projects_path, 'native', 'wp8_fixture'),
+ project_path = path.join(projects_path, 'cordova'),
+ wp8_project_path = path.join(project_path, 'platforms', 'wp8');
+
+var www_config = util.projectConfig(project_path);
+var original_www_config = fs.readFileSync(www_config, 'utf-8');
+
+describe('wp8 project parser', function() {
+ it('should throw an exception with a path that is not a native wp8 project', function() {
+ expect(function() {
+ var project = new wp8_parser(process.cwd());
+ }).toThrow();
+ });
+ it('should accept a proper native wp8 project path as construction parameter', function() {
+ expect(function() {
+ var project = new wp8_parser(wp8_path);
+ expect(project).toBeDefined();
+ }).not.toThrow();
+ });
+
+ describe('update_from_config method', function() {
+ var config;
+ var project = new wp8_parser(wp8_path);
+
+ var manifest_path = path.join(wp8_path, 'Properties', 'WMAppManifest.xml');
+ var csproj_path = project.csproj_path;
+ var sln_path = project.sln_path;
+ var app_xaml_path = path.join(wp8_path, 'App.xaml');
+ var app_cs_path = path.join(wp8_path, 'App.xaml.cs');
+ var main_xaml_path = path.join(wp8_path, 'MainPage.xaml');
+ var main_cs_path = path.join(wp8_path, 'MainPage.xaml.cs');
+
+
+ var original_manifest = fs.readFileSync(manifest_path, 'utf-8');
+ var original_csproj = fs.readFileSync(csproj_path, 'utf-8');
+ var original_sln = fs.readFileSync(sln_path, 'utf-8');
+ var original_app_xaml = fs.readFileSync(app_xaml_path, 'utf-8');
+ var original_app_cs = fs.readFileSync(app_cs_path, 'utf-8');
+ var original_main_xaml = fs.readFileSync(main_xaml_path, 'utf-8');
+ var original_main_cs = fs.readFileSync(main_cs_path, 'utf-8');
+
+ beforeEach(function() {
+ project = new wp8_parser(wp8_path);
+ config = new config_parser(www_config);
+ });
+ afterEach(function() {
+ fs.writeFileSync(manifest_path, original_manifest, 'utf-8');
+ // csproj file changes name if app changes name
+ fs.unlinkSync(project.csproj_path);
+ fs.unlinkSync(project.sln_path);
+ fs.writeFileSync(csproj_path, original_csproj, 'utf-8');
+ fs.writeFileSync(sln_path, original_sln, 'utf-8');
+ fs.writeFileSync(app_xaml_path, original_app_xaml, 'utf-8');
+ fs.writeFileSync(app_cs_path, original_app_cs, 'utf-8');
+ fs.writeFileSync(main_xaml_path, original_main_xaml, 'utf-8');
+ fs.writeFileSync(main_cs_path, original_main_cs, 'utf-8');
+ });
+ it('should throw an exception if a non config_parser object is passed into it', function() {
+ expect(function() {
+ project.update_from_config({});
+ }).toThrow();
+ });
+ it('should update the application name properly', function() {
+ var test_name = 'bond. james bond.';
+ config.name(test_name);
+ project.update_from_config(config);
+ var raw_manifest = fs.readFileSync(manifest_path, 'utf-8');
+ //Strip three bytes that windows adds (http://www.multiasking.com/2012/11/851)
+ var cleaned_manifest = raw_manifest.replace('\ufeff', '');
+ var manifest = new et.ElementTree(et.XML(cleaned_manifest));
+ var app_name = manifest.find('.//App[@Title]')['attrib']['Title'];
+ expect(app_name).toBe(test_name);
+
+ //check for the proper name of csproj and solution files
+ test_name = test_name.replace(/(\.\s|\s\.|\s+|\.+)/g, '_'); //make it a ligitamate name
+ expect(project.csproj_path).toContain(test_name);
+ expect(project.sln_path).toContain(test_name);
+ });
+ it('should update the application package name properly', function() {
+ var test_package = 'ca.filmaj.dewd'
+ config.packageName(test_package);
+ project.update_from_config(config);
+
+ // check csproj file (use regex instead of elementtree?)
+ var raw_csproj = fs.readFileSync(project.csproj_path, 'utf-8');
+ var cleaned_csproj = raw_csproj.replace(/^\uFEFF/i, '');
+ var csproj = new et.ElementTree(et.XML(cleaned_csproj));
+ expect(csproj.find('.//RootNamespace').text).toEqual(test_package);
+ expect(csproj.find('.//AssemblyName').text).toEqual(test_package);
+ expect(csproj.find('.//XapFilename').text).toEqual(test_package + '.xap');
+ expect(csproj.find('.//SilverlightAppEntry').text).toEqual(test_package + '.App');
+
+ // check app.xaml (use regex instead of elementtree?)
+ var new_app_xaml = fs.readFileSync(app_xaml_path, 'utf-8');
+ var cleaned_app_xaml = new_app_xaml.replace(/^\uFEFF/i, '');
+ var app_xaml = new et.ElementTree(et.XML(cleaned_app_xaml));
+ expect(app_xaml._root.attrib['x:Class']).toEqual(test_package + '.App');
+
+ // check app.xaml.cs
+ var new_app_cs = fs.readFileSync(app_cs_path, 'utf-8');
+ expect(new_app_cs).toContain('namespace ' + test_package);
+
+ // check MainPage.xaml (use regex instead of elementtree?)
+ var new_main_xaml = fs.readFileSync(main_xaml_path, 'utf-8');
+ var cleaned_main_xaml = new_main_xaml.replace(/^\uFEFF/i, '');
+ var main_xaml = new et.ElementTree(et.XML(cleaned_main_xaml));
+ expect(main_xaml._root.attrib['x:Class']).toEqual(test_package + '.MainPage');
+
+ //check MainPage.xaml.cs
+ var new_main_cs = fs.readFileSync(main_cs_path, 'utf-8');
+ expect(new_main_cs).toContain('namespace ' + test_package);
+ });
+ xdescribe('preferences', function() {
+ it('should not change default project preferences and copy over additional project preferences to platform-level config.xml', function() {
+ /*config.preference.add({name:'henrik',value:'sedin'});
+ project.update_from_config(config);
+
+ var native_config = new et.ElementTree(et.XML(fs.readFileSync(android_config, 'utf-8')));
+ var ps = native_config.findall('preference');
+ expect(ps.length).toEqual(7);
+ expect(ps[0].attrib.name).toEqual('useBrowserHistory');
+ expect(ps[0].attrib.value).toEqual('true');
+ expect(ps[6].attrib.name).toEqual('henrik');
+ expect(ps[6].attrib.value).toEqual('sedin');*/
+
+ // TODO : figure out if this is supported
+ //expect(true).toBe(false);
+ });
+ it('should override a default project preference if applicable', function() {
+ /*config.preference.add({name:'useBrowserHistory',value:'false'});
+ project.update_from_config(config);
+
+ var native_config = new et.ElementTree(et.XML(fs.readFileSync(android_config, 'utf-8')));
+ var ps = native_config.findall('preference');
+ expect(ps.length).toEqual(6);
+ expect(ps[0].attrib.name).toEqual('useBrowserHistory');
+ expect(ps[0].attrib.value).toEqual('false');*/
+
+ // TODO : figure out if this is supported
+ //expect(true).toBe(false);
+ });
+ });
+ });
+
+ describe('cross-platform project level methods', function() {
+ var parser, config;
+
+ beforeEach(function() {
+ parser = new wp8_parser(wp8_project_path);
+ config = new config_parser(www_config);
+ });
+ afterEach(function() {
+ });
+ describe('update_www method', function() {
+ it('should update all www assets', function() {
+ var newFile = path.join(util.projectWww(project_path), 'somescript.js');
+ this.after(function() {
+ shell.rm('-f', newFile);
+ });
+ fs.writeFileSync(newFile, 'alert("sup");', 'utf-8');
+ parser.update_www();
+ expect(fs.existsSync(path.join(wp8_project_path, 'www', 'somescript.js'))).toBe(true);
+ });
+ it('should write out windows-phone js to cordova.js', function() {
+ parser.update_www();
+ expect(fs.readFileSync(path.join(wp8_project_path, 'www', 'cordova.js'),'utf-8')).toEqual(fs.readFileSync(path.join(util.libDirectory, 'cordova-wp8', 'templates', 'standalone', 'www', 'cordova.js'), 'utf-8'));
+ });
+ });
+
+ xdescribe('update_overrides method',function() {
+ /*var mergesPath = path.join(util.appDir(project_path), 'merges', 'android');
+ var newFile = path.join(mergesPath, 'merge.js');
+ beforeEach(function() {
+ shell.mkdir('-p', mergesPath);
+ fs.writeFileSync(newFile, 'alert("sup");', 'utf-8');
+ });
+ afterEach(function() {
+ shell.rm('-rf', mergesPath);
+ });
+ it('should copy a new file from merges into www', function() {
+ parser.update_overrides();
+ expect(fs.existsSync(path.join(wp8_project_path, 'assets', 'www', 'merge.js'))).toBe(true);
+ });
+
+ it('should copy a file from merges over a file in www', function() {
+ var newFileWWW = path.join(util.projectWww(project_path), 'merge.js');
+ fs.writeFileSync(newFileWWW, 'var foo=1;', 'utf-8');
+ this.after(function() {
+ shell.rm('-rf', newFileWWW);
+ });
+ parser.update_overrides();
+ expect(fs.existsSync(path.join(wp8_project_path, 'assets', 'www', 'merge.js'))).toBe(true);
+ expect(fs.readFileSync(path.join(wp8_project_path, 'assets', 'www', 'merge.js'),'utf-8')).toEqual('alert("sup");');
+ });*/
+
+ // TODO : figure out if this is supported
+ //expect(true).toBe(false);
+ });
+
+ describe('update_project method', function() {
+ it('should invoke update_www', function() {
+ var spyWww = spyOn(parser, 'update_www');
+ parser.update_project(config);
+ expect(spyWww).toHaveBeenCalled();
+ });
+ it('should invoke update_from_config', function() {
+ var spyConfig = spyOn(parser, 'update_from_config');
+ parser.update_project(config);
+ expect(spyConfig).toHaveBeenCalled();
+ });
+ it('should call out to util.deleteSvnFolders', function() {
+ var spy = spyOn(util, 'deleteSvnFolders');
+ parser.update_project(config);
+ expect(spy).toHaveBeenCalled();
+ });
+ });
+ });
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/23b9e798/spec/platform-script/android/android.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform-script/android/android.spec.js b/spec/platform-script/android/android.spec.js
deleted file mode 100644
index 8890276..0000000
--- a/spec/platform-script/android/android.spec.js
+++ /dev/null
@@ -1,89 +0,0 @@
-var cordova = require('../../../cordova'),
- shell = require('shelljs'),
- path = require('path'),
- fs = require('fs'),
- android_parser = require('../../../src/metadata/android_parser'),
- tempDir = path.join(__dirname, '..', '..', '..', 'temp'),
- fixtures = path.join(__dirname, '..', '..', 'fixtures'),
- cordova_project = path.join(fixtures, 'projects', 'cordova');
-
-var cwd = process.cwd();
-
-describe('Test:', function() {
- afterEach(function() {
- process.chdir(cwd);
- });
-
- describe('\'platform add android\'', function() {
- var sh, cr;
- var fake_reqs_check = function() {
- expect(cr.mostRecentCall.args).toBeDefined();
- cr.mostRecentCall.args[0](false);
- };
- var fake_create = function(a_path) {
- shell.mkdir('-p', a_path);
- fs.writeFileSync(path.join(a_path, 'AndroidManifest.xml'), 'hi', 'utf-8');
- sh.mostRecentCall.args[2](0, '');
- };
- beforeEach(function() {
- sh = spyOn(shell, 'exec');
- cr = spyOn(android_parser, 'check_requirements');
- shell.rm('-rf', tempDir);
- cordova.create(tempDir);
- process.chdir(tempDir);
- });
- afterEach(function() {
- process.chdir(cwd);
- });
- it('should shell out to android /bin/create', function() {
- cordova.platform('add', 'android');
- fake_reqs_check();
- var shell_cmd = sh.mostRecentCall.args[0];
- var create_cmd = path.join('android', 'bin', 'create');
- expect(shell_cmd).toContain(create_cmd);
- });
- it('should call android_parser\'s update_project', function() {
- spyOn(android_parser.prototype, 'update_project');
- cordova.platform('add', 'android');
- fake_reqs_check();
- fake_create(path.join(tempDir, 'platforms', 'android'));
- expect(android_parser.prototype.update_project).toHaveBeenCalled();
- });
- });
-
- describe('\'emulate android\'', function() {
- beforeEach(function() {
- process.chdir(tempDir);
- });
- afterEach(function() {
- process.chdir(cwd);
- });
- shell.rm('-rf', tempDir);
- cordova.create(tempDir);
- shell.cp('-rf', path.join(cordova_project, 'platforms', 'android'), path.join(tempDir, 'platforms'));
- it('should call android_parser\'s update_project', function() {
- spyOn(require('shelljs'), 'exec');
- spyOn(android_parser.prototype, 'update_project');
- cordova.emulate('android');
- expect(android_parser.prototype.update_project).toHaveBeenCalled();
- });
- });
-
- describe('\'compile android\'', function() {
- beforeEach(function() {
- process.chdir(tempDir);
- });
- afterEach(function() {
- process.chdir(cwd);
- });
- shell.rm('-rf', tempDir);
- cordova.create(tempDir);
- shell.cp('-rf', path.join(cordova_project, 'platforms', 'android'), path.join(tempDir, 'platforms'));
- it('should shell out to build command', function() {
- var build_cmd = path.join('android', 'cordova', 'build');
- var s = spyOn(require('shelljs'), 'exec').andReturn({code:0});
- cordova.compile('android');
- expect(s.mostRecentCall.args[0]).toContain(build_cmd);
- });
- });
-});