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 20:22:18 UTC
[55/78] git commit: finished updates to config_parser and util specs
finished updates to config_parser and util specs
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/4b310a71
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/4b310a71
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/4b310a71
Branch: refs/heads/master2
Commit: 4b310a71bbd3ecd9f6de2b8df8ded36eadfba2f9
Parents: f7d66bb
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Jun 12 16:13:35 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 13 11:13:21 2013 -0700
----------------------------------------------------------------------
spec/config_parser.spec.js | 16 ++++----
spec/util.spec.js | 83 +++++++++++++++++++++++++++++++++++++++--
templates/config.xml | 4 +-
3 files changed, 91 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/4b310a71/spec/config_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/config_parser.spec.js b/spec/config_parser.spec.js
index 058d56b..018153a 100644
--- a/spec/config_parser.spec.js
+++ b/spec/config_parser.spec.js
@@ -152,8 +152,8 @@ describe('config.xml parser', function () {
describe('getter', function() {
it('should get all preference elements', function() {
- expect(cfg.preference.get()[0].name).toEqual('phonegap-version');
- expect(cfg.preference.get()[0].value).toEqual('1.9.0');
+ expect(cfg.preference.get()[0].name).toEqual('fullscreen');
+ expect(cfg.preference.get()[0].value).toEqual('true');
});
it('should return an array of all preference name/value pairs', function() {
expect(cfg.preference.get() instanceof Array).toBe(true);
@@ -161,8 +161,8 @@ describe('config.xml parser', function () {
});
describe('setters', function() {
it('should allow removing a preference by name', function() {
- cfg.preference.remove('phonegap-version');
- expect(cfg.preference.get().length).toEqual(3);
+ cfg.preference.remove('fullscreen');
+ expect(cfg.preference.get().length).toEqual(1);
});
it('should write to disk after removing a preference', function() {
cfg.preference.remove('phonegap-version');
@@ -170,16 +170,16 @@ describe('config.xml parser', function () {
});
it('should allow adding a new preference', function() {
cfg.preference.add({name:'UIWebViewBounce',value:'false'});
- expect(cfg.preference.get().length).toEqual(5);
- expect(cfg.preference.get()[4].value).toEqual('false');
+ expect(cfg.preference.get().length).toEqual(3);
+ expect(cfg.preference.get()[2].value).toEqual('false');
});
it('should write to disk after adding a preference', function() {
cfg.preference.add({name:'UIWebViewBounce',value:'false'});
- expect(fs.readFileSync(xml, 'utf-8')).toMatch(/<preference name="UIWebViewBounce" value="false"/);
+ expect(update).toHaveBeenCalled();
});
it('should allow removing all preference elements when no parameter is specified', function() {
cfg.preference.remove();
- expect(fs.readFileSync(xml, 'utf-8')).not.toMatch(/<preference.*\/>/);
+ expect(cfg.preference.get().length).toEqual(0);
});
});
});
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/4b310a71/spec/util.spec.js
----------------------------------------------------------------------
diff --git a/spec/util.spec.js b/spec/util.spec.js
index a57d551..6b52d03 100644
--- a/spec/util.spec.js
+++ b/spec/util.spec.js
@@ -1,13 +1,90 @@
-var cordova = require('../../cordova'),
+var cordova = require('../cordova'),
shell = require('shelljs'),
path = require('path'),
fs = require('fs'),
- cordova_util = require('../../src/util'),
- fixtures = path.join(__dirname, '..', 'fixtures');
+ util = require('../src/util'),
+ temp = path.join(__dirname, '..', 'temp'),
+ fixtures = path.join(__dirname, 'fixtures');
var cwd = process.cwd();
+var home = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
describe('util module', function() {
describe('isCordova method', function() {
+ it('should return false if it hits the home directory', function() {
+ var somedir = path.join(home, 'somedir');
+ this.after(function() {
+ shell.rm('-rf', somedir);
+ });
+ shell.mkdir(somedir);
+ expect(util.isCordova(somedir)).toEqual(false);
+ });
+ it('should return false if it cannot find a .cordova directory up the directory tree', function() {
+ var somedir = path.join(home, '..');
+ expect(util.isCordova(somedir)).toEqual(false);
+ });
+ it('should return the first directory it finds with a .cordova folder in it', function() {
+ var somedir = path.join(home,'somedir');
+ var anotherdir = path.join(somedir, 'anotherdir');
+ this.after(function() {
+ shell.rm('-rf', somedir);
+ });
+ shell.mkdir('-p', anotherdir);
+ shell.mkdir(path.join(somedir, '.cordova'));
+ expect(util.isCordova(somedir)).toEqual(somedir);
+ });
+ });
+ describe('deleteSvnFolders method', function() {
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+ it('should delete .svn folders in any subdirectory of specified dir', function() {
+ var one = path.join(temp, 'one');
+ var two = path.join(temp, 'two');
+ var one_svn = path.join(one, '.svn');
+ var two_svn = path.join(two, '.svn');
+ shell.mkdir('-p', one_svn);
+ shell.mkdir('-p', two_svn);
+ util.deleteSvnFolders(temp);
+ expect(fs.existsSync(one_svn)).toEqual(false);
+ expect(fs.existsSync(two_svn)).toEqual(false);
+ });
+ });
+ describe('listPlatforms method', function() {
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+ it('should only return supported platform directories present in a cordova project dir', function() {
+ var platforms = path.join(temp, 'platforms');
+ var android = path.join(platforms, 'android');
+ var ios = path.join(platforms, 'ios');
+ var wp7 = path.join(platforms, 'wp7');
+ var atari = path.join(platforms, 'atari');
+ shell.mkdir('-p', android);
+ shell.mkdir('-p', ios);
+ shell.mkdir('-p', wp7);
+ shell.mkdir('-p', atari);
+ var res = util.listPlatforms(temp);
+ expect(res.length).toEqual(3);
+ expect(res.indexOf('atari')).toEqual(-1);
+ });
+ });
+ describe('findPlugins method', function() {
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+ it('should only return plugin directories present in a cordova project dir', function() {
+ var plugins = path.join(temp, 'plugins');
+ var android = path.join(plugins, 'android');
+ var ios = path.join(plugins, 'ios');
+ var wp7 = path.join(plugins, 'wp7');
+ var atari = path.join(plugins, 'atari');
+ shell.mkdir('-p', android);
+ shell.mkdir('-p', ios);
+ shell.mkdir('-p', wp7);
+ shell.mkdir('-p', atari);
+ var res = util.findPlugins(plugins);
+ expect(res.length).toEqual(4);
+ });
});
});
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/4b310a71/templates/config.xml
----------------------------------------------------------------------
diff --git a/templates/config.xml b/templates/config.xml
index bf15b68..a66b224 100644
--- a/templates/config.xml
+++ b/templates/config.xml
@@ -9,9 +9,11 @@
A sample Apache Cordova application that responds to the deviceready event.
</description>
- <author href="http://cordova.io" email="callback-dev@incubator.apache.org">
+ <author href="http://cordova.io" email="dev@callback.apache.org">
Apache Cordova Team
</author>
<access origin="*" />
+ <preference name="fullscreen" value="true" />
+ <preference name="webviewbounce" value="true" />
</widget>