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/01/03 19:38:43 UTC
git commit: Fix broken tests (whoops)
Updated Branches:
refs/heads/master bdb2a211a -> f8ebf1a9e
Fix broken tests (whoops)
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/f8ebf1a9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/f8ebf1a9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/f8ebf1a9
Branch: refs/heads/master
Commit: f8ebf1a9e427392787a89161af38f5dd5f346ca6
Parents: bdb2a21
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Jan 3 13:38:25 2014 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Jan 3 13:38:25 2014 -0500
----------------------------------------------------------------------
e2e/fixtures/platforms/android-lib/VERSION | 1 +
spec/platform.spec.js | 60 +++++++++++--------------
2 files changed, 28 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f8ebf1a9/e2e/fixtures/platforms/android-lib/VERSION
----------------------------------------------------------------------
diff --git a/e2e/fixtures/platforms/android-lib/VERSION b/e2e/fixtures/platforms/android-lib/VERSION
new file mode 100644
index 0000000..15a2799
--- /dev/null
+++ b/e2e/fixtures/platforms/android-lib/VERSION
@@ -0,0 +1 @@
+3.3.0
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f8ebf1a9/spec/platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform.spec.js b/spec/platform.spec.js
index 5582f39..39a9553 100644
--- a/spec/platform.spec.js
+++ b/spec/platform.spec.js
@@ -34,6 +34,10 @@ var cwd = process.cwd();
var supported_platforms = Object.keys(platforms).filter(function(p) { return p != 'www'; });
var project_dir = path.join('some', 'path');
+function fail(e) {
+ expect('Got Error: ' + e).toBe('');
+}
+
describe('platform command', function() {
var is_cordova,
cd_project_root,
@@ -92,6 +96,13 @@ describe('platform command', function() {
rm = spyOn(shell, 'rm');
mkdir = spyOn(shell, 'mkdir');
existsSync = spyOn(fs, 'existsSync').andReturn(false);
+ var origReadFile = fs.readFileSync;
+ spyOn(fs, 'readFileSync').andCallFake(function(path) {
+ if (/VERSION$/.test(path)) {
+ return '3.3.0';
+ }
+ return origReadFile.apply(this, arguments);
+ });
supports = spyOn(platform, 'supports').andReturn(Q());
exec = spyOn(child_process, 'exec').andCallFake(function(cmd, opts, cb) {
if (!cb) cb = opts;
@@ -132,8 +143,7 @@ describe('platform command', function() {
it('should run inside a Cordova-based project by calling util.isCordova', function(done) {
cordova.raw.platform().then(function() {
expect(is_cordova).toHaveBeenCalled();
- done();
- });
+ }, fail).fin(done);
});
describe('`ls`', function() {
@@ -147,8 +157,8 @@ describe('platform command', function() {
done();
});
cordova.raw.platform('list');
- });
+ });
it('should list out added platforms in a project', function(done) {
cordova.on('results', function(res) {
expect(res).toMatch(/^Installed platforms: ios, android, ubuntu, amazon-fireos, wp7, wp8, blackberry10, firefoxos, windows8\s*Available platforms:\s*$/);
@@ -177,8 +187,7 @@ describe('platform command', function() {
}).then(function(){
expect(exec.mostRecentCall.args[0]).toMatch(/lib.windows8.cordova.\d.\d.\d[\d\w\-]*.windows8.*.bin.create/gi);
expect(exec.mostRecentCall.args[0]).toContain(project_dir);
- done();
- });
+ }, fail).fin(done);
});
it('should call into lazy_load.custom if there is a user-specified configruation for consuming custom libraries', function(done) {
load.andCallThrough();
@@ -195,8 +204,7 @@ describe('platform command', function() {
expect(load_custom).toHaveBeenCalledWith('haha', 'phonegap', 'wp8', 'bleeding edge');
expect(exec.mostRecentCall.args[0]).toMatch(/lib.wp.phonegap.bleeding edge.wp8.*.bin.create/gi);
expect(exec.mostRecentCall.args[0]).toContain(project_dir);
- done();
- });
+ }, fail).fin(done);
});
it('should use a custom template directory if there is one specified in the configuration', function(done) {
var template_dir = "/tmp/custom-template"
@@ -215,8 +223,7 @@ describe('platform command', function() {
expect(exec.mostRecentCall.args[0]).toMatch(/^"[^ ]*" +"[^"]*" +"[^"]*" +"[^"]*" +"[^"]*"$/g);
expect(exec.mostRecentCall.args[0]).toContain(project_dir);
expect(exec.mostRecentCall.args[0]).toContain(template_dir);
- done();
- });
+ }, fail).fin(done);
});
it('should not use a custom template directory if there is not one specified in the configuration', function(done) {
load.andCallThrough();
@@ -232,15 +239,13 @@ describe('platform command', function() {
cordova.raw.platform('add', 'android').then(function() {
expect(exec.mostRecentCall.args[0]).toMatch(/^"[^ ]*" +"[^"]*" +"[^"]*" +"[^"]*"$/g);
expect(exec.mostRecentCall.args[0]).toContain(project_dir);
- done();
- });
+ }, fail).fin(done);
});
it('should not use a custom template directory if there is no user-defined configuration', function(done) {
cordova.raw.platform('add', 'android').then(function() {
expect(exec.mostRecentCall.args[0]).toMatch(/^"[^ ]*" +"[^"]*" +"[^"]*" +"[^"]*"$/g);
expect(exec.mostRecentCall.args[0]).toContain(project_dir);
- done();
- });
+ }, fail).fin(done);
});
});
describe('`remove`',function() {
@@ -248,8 +253,7 @@ describe('platform command', function() {
cordova.raw.platform('remove', 'android').then(function() {
expect(rm).toHaveBeenCalledWith('-rf', path.join(project_dir, 'platforms', 'android'));
expect(rm).toHaveBeenCalledWith('-rf', path.join(project_dir, 'merges', 'android'));
- done();
- });
+ }, fail).fin(done);
});
it('should be able to remove multiple platforms', function(done) {
@@ -258,8 +262,7 @@ describe('platform command', function() {
expect(rm).toHaveBeenCalledWith('-rf', path.join(project_dir, 'merges', 'android'));
expect(rm).toHaveBeenCalledWith('-rf', path.join(project_dir, 'platforms', 'blackberry10'));
expect(rm).toHaveBeenCalledWith('-rf', path.join(project_dir, 'merges', 'blackberry10'));
- done();
- });
+ }, fail).fin(done);
});
});
describe('`update`', function() {
@@ -288,9 +291,7 @@ describe('platform command', function() {
lazyLoadVersion = '1.0.0';
cordova.raw.platform('update', ['ios']).then(function() {
expect(exec).toHaveBeenCalledWith('lib/ios/cordova/1.0.0/bin/update "some/path/platforms/ios"', jasmine.any(Function));
- }, function(err) {
- expect(err).toBeUndefined();
- }).fin(function() {
+ }, fail).fin(function() {
lazyLoadVersion = oldVersion;
done();
});
@@ -304,28 +305,24 @@ describe('platform command', function() {
it('should fire before hooks through the hooker module', function() {
cordova.raw.platform().then(function() {
expect(fire).toHaveBeenCalledWith('before_platform_ls');
- done();
- });
+ }, fail).fin(done);
});
it('should fire after hooks through the hooker module', function(done) {
cordova.raw.platform().then(function() {
expect(fire).toHaveBeenCalledWith('after_platform_ls');
- done();
- });
+ }, fail).fin(done);
});
});
describe('remove (rm) hooks', function() {
it('should fire before hooks through the hooker module', function(done) {
cordova.raw.platform('rm', 'android').then(function() {
expect(fire).toHaveBeenCalledWith('before_platform_rm', {platforms:['android']});
- done();
- });
+ }, fail).fin(done);
});
it('should fire after hooks through the hooker module', function(done) {
cordova.raw.platform('rm', 'android').then(function() {
expect(fire).toHaveBeenCalledWith('after_platform_rm', {platforms:['android']});
- done();
- });
+ }, fail).fin(done);
});
});
describe('add hooks', function() {
@@ -333,8 +330,7 @@ describe('platform command', function() {
cordova.raw.platform('add', 'android').then(function() {
expect(fire).toHaveBeenCalledWith('before_platform_add', {platforms:['android']});
expect(fire).toHaveBeenCalledWith('after_platform_add', {platforms:['android']});
- done();
- });
+ }, fail).fin(done);
});
});
});
@@ -373,9 +369,7 @@ describe('platform.supports(name)', function() {
it('should resolve', function(done) {
cordova.raw.platform.supports(project_dir, 'android').then(function() {
expect(1).toBe(1);
- }, function(err) {
- expect(err).toBeUndefined();
- }).fin(done);
+ }, fail).fin(done);
});
});