You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/04/24 21:34:21 UTC
git commit: Fix CLI tests to work with node v0.11
Repository: cordova-cli
Updated Branches:
refs/heads/master ff6dd488e -> 3b6d2bd09
Fix CLI tests to work with node v0.11
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/3b6d2bd0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/3b6d2bd0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/3b6d2bd0
Branch: refs/heads/master
Commit: 3b6d2bd09698f86283b70e4779eb5dd562a00292
Parents: ff6dd48
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Apr 24 15:34:05 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Apr 24 15:34:05 2014 -0400
----------------------------------------------------------------------
spec/compile.spec.js | 6 ++---
spec/emulate.spec.js | 8 +++---
spec/info.spec.js | 66 ---------------------------------------------
spec/lazy_load.spec.js | 2 +-
spec/prepare.spec.js | 4 +--
spec/wrappers.spec.js | 7 ++---
6 files changed, 13 insertions(+), 80 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3b6d2bd0/spec/compile.spec.js
----------------------------------------------------------------------
diff --git a/spec/compile.spec.js b/spec/compile.spec.js
index ddccdf1..c1fc8b9 100644
--- a/spec/compile.spec.js
+++ b/spec/compile.spec.js
@@ -52,13 +52,13 @@ describe('compile command', function() {
it('should not run inside a Cordova-based project with no added platforms by calling util.listPlatforms', function() {
list_platforms.andReturn([]);
wrapper(cordova.raw.compile, function() {
- expect(result).toEqual(new Error('No platforms added to this project. Please use `cordova platform add <platform>`.'));
+ expect('' + result).toContain('No platforms added to this project. Please use `cordova platform add <platform>`.');
});
});
it('should not run outside of a Cordova-based project', function() {
is_cordova.andReturn(false);
wrapper(cordova.raw.compile, function() {
- expect(result).toEqual(new Error('Current working directory is not a Cordova-based project.'));
+ expect(result instanceof Error).toBe(true);
});
});
});
@@ -103,7 +103,7 @@ describe('compile command', function() {
expect('this call').toBe('fail');
}, function(err) {
expect(fire).not.toHaveBeenCalled();
- expect(err.message).toEqual(
+ expect(err.message).toContain(
'No platforms added to this project. Please use `cordova platform add <platform>`.'
)
}).fin(done);
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3b6d2bd0/spec/emulate.spec.js
----------------------------------------------------------------------
diff --git a/spec/emulate.spec.js b/spec/emulate.spec.js
index 853e5a3..8435535 100644
--- a/spec/emulate.spec.js
+++ b/spec/emulate.spec.js
@@ -53,13 +53,13 @@ describe('emulate command', function() {
it('should not run inside a Cordova-based project with no added platforms by calling util.listPlatforms', function() {
list_platforms.andReturn([]);
wrapper(cordova.raw.emulate, function() {
- expect(result).toEqual(new Error('No platforms added to this project. Please use `cordova platform add <platform>`.'));
+ expect(''+ result).toContain('No platforms added to this project. Please use `cordova platform add <platform>`.');
});
});
it('should not run outside of a Cordova-based project', function() {
is_cordova.andReturn(false);
wrapper(cordova.raw.emulate, function() {
- expect(result).toEqual(new Error('Current working directory is not a Cordova-based project.'));
+ expect(result instanceof Error).toBe(true);
});
});
});
@@ -107,9 +107,7 @@ describe('emulate command', function() {
expect('this call').toBe('fail');
}, function(err) {
expect(fire).not.toHaveBeenCalled();
- expect(err.message).toEqual(
- 'No platforms added to this project. Please use `cordova platform add <platform>`.'
- )
+ expect(''+err).toContain('No platforms added to this project. Please use `cordova platform add <platform>`.')
}).fin(done);
});
});
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3b6d2bd0/spec/info.spec.js
----------------------------------------------------------------------
diff --git a/spec/info.spec.js b/spec/info.spec.js
deleted file mode 100644
index 3685b40..0000000
--- a/spec/info.spec.js
+++ /dev/null
@@ -1,66 +0,0 @@
-var cordova = require('../cordova'),
- path = require('path'),
- shell = require('shelljs'),
- fs = require('fs'),
- Q = require('q'),
- cordova_util = require('../src/util');
-
-var cwd = process.cwd();
-var project_dir = path.join('spec', 'fixtures', 'templates');
-
-describe('info flag', function(){
- var is_cordova,
- cd_project_root,
- writeFileSync,
- cordova_utilSpy,
- readFileSync,
- shellSpy,
- exec = {},
- done = false;
-
- function infoPromise( f ) {
- f.then( function() { done = true; }, function(err) { done = err; } );
- }
-
- beforeEach(function() {
- is_cordova = spyOn(cordova_util, 'isCordova').andReturn(project_dir);
- cd_project_root = spyOn(cordova_util, 'cdProjectRoot').andReturn(project_dir);
- writeFileSync = spyOn( fs, 'writeFileSync' );
- shellSpy = spyOn( shell, 'exec' ).andReturn( "" );
- cordova_utilSpy = spyOn( cordova_util, 'projectConfig').andReturn(project_dir + '/no_content_config.xml' );
- done = false;
- });
-
- it('should not run outside of a Cordova-based project by calling util.isCordova', function() {
- var msg = 'Dummy message about not being in a cordova dir.';
- cd_project_root.andThrow(new Error(msg));
- is_cordova.andReturn(false);
- runs(function() {
- infoPromise( Q().then(cordova.raw.info) );
- });
- waitsFor(function() { return done; }, 'platform promise never resolved', 500);
- runs(function() {
- expect( done.message ).toEqual( msg );
- });
- });
-
- it('should run inside a Cordova-based project by calling util.isCordova', function() {
- readFileSync = spyOn( fs, 'readFileSync' ).andReturn( "" );
- cordova.raw.info().then(function() {
- expect(cd_cordova_root).toHaveBeenCalled();
- done();
- });
- });
-
- it('should emit a results event with info contents', function(done) {
- readFileSync = spyOn( fs, 'readFileSync' ).andReturn( "info" );
- this.after(function() {
- cordova.removeAllListeners('results');
- });
- cordova.on('results', function(h) {
- expect(h).toMatch(/info/gi);
- done();
- });
- cordova.info();
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3b6d2bd0/spec/lazy_load.spec.js
----------------------------------------------------------------------
diff --git a/spec/lazy_load.spec.js b/spec/lazy_load.spec.js
index 61b857a..1a92ee9 100644
--- a/spec/lazy_load.spec.js
+++ b/spec/lazy_load.spec.js
@@ -42,7 +42,7 @@ describe('lazy_load module', function() {
lazy_load.cordova('atari').then(function() {
expect('this call').toEqual('to fail');
}, function(err) {
- expect(err).toEqual(new Error('Cordova library "atari" not recognized.'));
+ expect('' + err).toContain('Cordova library "atari" not recognized.');
}).fin(done);
});
it('should invoke lazy_load.custom with appropriate url, platform, and version as specified in platforms manifest', function(done) {
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3b6d2bd0/spec/prepare.spec.js
----------------------------------------------------------------------
diff --git a/spec/prepare.spec.js b/spec/prepare.spec.js
index 204e548..eac225d 100644
--- a/spec/prepare.spec.js
+++ b/spec/prepare.spec.js
@@ -106,7 +106,7 @@ describe('prepare command', function() {
Q().then(prepare).then(function() {
expect('this call').toBe('fail');
}, function(err) {
- expect(err).toEqual(new Error('Current working directory is not a Cordova-based project.'));
+ expect('' + err).toContain('Current working directory is not a Cordova-based project.');
}).fin(done);
});
it('should not run inside a cordova-based project with no platforms', function(done) {
@@ -114,7 +114,7 @@ describe('prepare command', function() {
Q().then(prepare).then(function() {
expect('this call').toBe('fail');
}, function(err) {
- expect(err).toEqual(new Error('No platforms added to this project. Please use `cordova platform add <platform>`.'));
+ expect('' + err).toContain('No platforms added to this project. Please use `cordova platform add <platform>`.');
}).fin(done);
});
});
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3b6d2bd0/spec/wrappers.spec.js
----------------------------------------------------------------------
diff --git a/spec/wrappers.spec.js b/spec/wrappers.spec.js
index c002856..2afbe9b 100644
--- a/spec/wrappers.spec.js
+++ b/spec/wrappers.spec.js
@@ -27,9 +27,10 @@ describe('callback wrapper', function() {
});
it('should call the callback with the error on failure', function(done) {
- raw.andReturn(Q.reject(new Error('junk')));
- cordova[call](function(err) {
- expect(err).toEqual(new Error('junk'));
+ var err = new Error('junk');
+ raw.andReturn(Q.reject(err));
+ cordova[call](function(e) {
+ expect(e).toEqual(err);
done();
});
});