You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2012/07/27 02:29:15 UTC
[8/78] [abbrv] git commit: helper file makes this a bit more sane.
helper file makes this a bit more sane.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/commit/4681a895
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/tree/4681a895
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/diff/4681a895
Branch: refs/heads/cordova-client
Commit: 4681a89578c0b55286b39c8da091f258bd59f24c
Parents: 4dadcd6
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Jul 25 23:53:28 2012 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Wed Jul 25 23:53:28 2012 -0700
----------------------------------------------------------------------
spec/_platform.spec.js | 135 -------------------------------------------
spec/helper.js | 12 ++++
spec/platform.spec.js | 121 ++++++++++++++++++++++++++++++++++++++
3 files changed, 133 insertions(+), 135 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/4681a895/spec/_platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/_platform.spec.js b/spec/_platform.spec.js
deleted file mode 100644
index 91d7f02..0000000
--- a/spec/_platform.spec.js
+++ /dev/null
@@ -1,135 +0,0 @@
-// Spy on exec so we can mock out certain CLI calls (and speed up
-// testing)
-var _exec = require('child_process').exec;
-require('child_process').exec = function(cmd, cb){
- var space = cmd.indexOf(' ');
- // Just invoke callback for create calls.
- if (Array.prototype.slice.call(cmd, space-6, space).join('') == 'create') {
- cb();
- } else {
- _exec(cmd, cb);
- }
-};
-
-var cordova = require('../cordova'),
- wrench = require('wrench'),
- mkdirp = wrench.mkdirSyncRecursive,
- path = require('path'),
- rmrf = wrench.rmdirSyncRecursive,
- fs = require('fs'),
- tempDir = path.join(__dirname, '..', 'temp');
-
-
-describe('platform command', function() {
- beforeEach(function() {
- // Make a temp directory
- try { rmrf(tempDir); } catch(e) {}
- mkdirp(tempDir);
- });
-
- it('should run inside a Cordova-based project', function() {
- var cwd = process.cwd();
- this.after(function() {
- process.chdir(cwd);
- });
-
- cordova.create(tempDir);
-
- process.chdir(tempDir);
-
- expect(function() {
- cordova.platform();
- }).not.toThrow();
- });
- it('should not run outside of a Cordova-based project', function() {
- var cwd = process.cwd();
- this.after(function() {
- process.chdir(cwd);
- });
-
- process.chdir(tempDir);
-
- expect(function() {
- cordova.platform();
- }).toThrow();
- });
-
- describe('ls', function() {
- var cwd = process.cwd();
-
- beforeEach(function() {
- cordova.create(tempDir);
- });
-
- afterEach(function() {
- process.chdir(cwd);
- });
-
- it('should list out no platforms for a fresh project', function() {
- process.chdir(tempDir);
-
- expect(cordova.platform('ls')).toEqual('No platforms added. Use `cordova platform add <platform>`.');
- });
-
- it('should list out added platforms in a project', function() {
- var cb = jasmine.createSpy().andCallFake(function() {
- expect(cordova.platform('ls')).toEqual('android');
- });
-
- process.chdir(tempDir);
- runs(function() {
- cordova.platform('add', 'android', cb);
- });
- waitsFor(function() { return cb.wasCalled; }, "create callback", 500);
- });
- });
-
- describe('add', function() {
- var cwd = process.cwd();
-
- beforeEach(function() {
- cordova.create(tempDir);
- });
-
- afterEach(function() {
- process.chdir(cwd);
- });
-
- it('should add a supported platform', function() {
- var cb = jasmine.createSpy().andCallFake(function() {
- expect(cordova.platform('ls')).toEqual('android');
- });
-
- process.chdir(tempDir);
- runs(function() {
- cordova.platform('add', 'android', cb);
- });
- waitsFor(function() { return cb.wasCalled; }, "create callback", 500);
- });
- });
-
- describe('remove', function() {
- var cwd = process.cwd();
-
- beforeEach(function() {
- cordova.create(tempDir);
- });
-
- afterEach(function() {
- process.chdir(cwd);
- });
-
- it('should remove a supported and added platform', function() {
- var cb = jasmine.createSpy().andCallFake(function() {
- cordova.platform('remove', 'android');
- expect(cordova.platform('ls')).toEqual('No platforms added. Use `cordova platform add <platform>`.');
- });
-
- process.chdir(tempDir);
- runs(function() {
- cordova.platform('add', 'android', cb);
- });
- waitsFor(function() { return cb.wasCalled; }, "create callback", 500);
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/4681a895/spec/helper.js
----------------------------------------------------------------------
diff --git a/spec/helper.js b/spec/helper.js
new file mode 100644
index 0000000..794eb5d
--- /dev/null
+++ b/spec/helper.js
@@ -0,0 +1,12 @@
+// Override exec for certain commands, to speed execution of tests.
+var _exec = require('child_process').exec;
+
+require('child_process').exec = function(cmd, cb){
+ var space = cmd.indexOf(' ');
+ // Just invoke callback for create calls
+ if (Array.prototype.slice.call(cmd, space-6, space).join('') == 'create') {
+ cb();
+ } else {
+ _exec(cmd, cb);
+ }
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/4681a895/spec/platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform.spec.js b/spec/platform.spec.js
new file mode 100644
index 0000000..2963a70
--- /dev/null
+++ b/spec/platform.spec.js
@@ -0,0 +1,121 @@
+var cordova = require('../cordova'),
+ wrench = require('wrench'),
+ mkdirp = wrench.mkdirSyncRecursive,
+ path = require('path'),
+ rmrf = wrench.rmdirSyncRecursive,
+ fs = require('fs'),
+ tempDir = path.join(__dirname, '..', 'temp');
+
+describe('platform command', function() {
+ beforeEach(function() {
+ // Make a temp directory
+ try { rmrf(tempDir); } catch(e) {}
+ mkdirp(tempDir);
+ });
+
+ it('should run inside a Cordova-based project', function() {
+ var cwd = process.cwd();
+ this.after(function() {
+ process.chdir(cwd);
+ });
+
+ cordova.create(tempDir);
+
+ process.chdir(tempDir);
+
+ expect(function() {
+ cordova.platform();
+ }).not.toThrow();
+ });
+ it('should not run outside of a Cordova-based project', function() {
+ var cwd = process.cwd();
+ this.after(function() {
+ process.chdir(cwd);
+ });
+
+ process.chdir(tempDir);
+
+ expect(function() {
+ cordova.platform();
+ }).toThrow();
+ });
+
+ describe('ls', function() {
+ var cwd = process.cwd();
+
+ beforeEach(function() {
+ cordova.create(tempDir);
+ });
+
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+
+ it('should list out no platforms for a fresh project', function() {
+ process.chdir(tempDir);
+
+ expect(cordova.platform('ls')).toEqual('No platforms added. Use `cordova platform add <platform>`.');
+ });
+
+ it('should list out added platforms in a project', function() {
+ var cb = jasmine.createSpy().andCallFake(function() {
+ expect(cordova.platform('ls')).toEqual('android');
+ });
+
+ process.chdir(tempDir);
+ runs(function() {
+ cordova.platform('add', 'android', cb);
+ });
+ waitsFor(function() { return cb.wasCalled; }, "create callback", 500);
+ });
+ });
+
+ describe('add', function() {
+ var cwd = process.cwd();
+
+ beforeEach(function() {
+ cordova.create(tempDir);
+ });
+
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+
+ it('should add a supported platform', function() {
+ var cb = jasmine.createSpy().andCallFake(function() {
+ expect(cordova.platform('ls')).toEqual('android');
+ });
+
+ process.chdir(tempDir);
+ runs(function() {
+ cordova.platform('add', 'android', cb);
+ });
+ waitsFor(function() { return cb.wasCalled; }, "create callback", 500);
+ });
+ });
+
+ describe('remove', function() {
+ var cwd = process.cwd();
+
+ beforeEach(function() {
+ cordova.create(tempDir);
+ });
+
+ afterEach(function() {
+ process.chdir(cwd);
+ });
+
+ it('should remove a supported and added platform', function() {
+ var cb = jasmine.createSpy().andCallFake(function() {
+ cordova.platform('remove', 'android');
+ expect(cordova.platform('ls')).toEqual('No platforms added. Use `cordova platform add <platform>`.');
+ });
+
+ process.chdir(tempDir);
+ runs(function() {
+ cordova.platform('add', 'android', cb);
+ });
+ waitsFor(function() { return cb.wasCalled; }, "create callback", 500);
+ });
+ });
+});