Skip to content
Permalink
Browse files
Fix unit tests when running node v0.11
  • Loading branch information
agrieve committed Apr 25, 2014
1 parent 0a0d384 commit 21ae0e4994183ce0e8e09839cdf770b4e7e12948
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 21 deletions.
@@ -35,7 +35,7 @@
},
"devDependencies": {
"temp": "0.6.x",
"jasmine-node": "1.7.0",
"jasmine-node": "~1",
"osenv": "0.0.x"
},
"bin" : { "plugman" : "./main.js" },
@@ -34,7 +34,7 @@ describe( 'platform add', function() {
});
waitsFor(function() { return done; }, 'platform promise never resolved', 500);
runs(function() {
expect( done ).toEqual( new Error( "can't find a plugin.xml. Are you in the plugin?" ) );
expect(''+ done ).toContain( "can't find a plugin.xml. Are you in the plugin?" );
});
});
});
@@ -58,7 +58,7 @@ describe( 'platform remove', function() {
});
waitsFor(function() { return done; }, 'platform promise never resolved', 500);
runs(function() {
expect( done ).toEqual( new Error( "can't find a plugin.xml. Are you in the plugin?" ) );
expect(''+ done ).toContain( "can't find a plugin.xml. Are you in the plugin?" );
});
});
});
@@ -56,7 +56,7 @@ describe( 'create plugin in existing plugin', function() {
});
waitsFor(function() { return done; }, 'create promise never resolved', 500);
runs(function() {
expect( done ).toEqual( new Error( 'Error: plugin.xml already exists. Are you already in a plugin?' ) );
expect(''+ done ).toContain( 'Error: plugin.xml already exists. Are you already in a plugin?' );
});
});
});
@@ -54,7 +54,7 @@ describe('fetch', function() {
.then(function() {
expect('this call').toBe('fail');
}, function(err) {
expect(err).toEqual(new Error('Expected fetched plugin to have ID "wrongID" but got "id".'));
expect(''+err).toContain('Expected fetched plugin to have ID "wrongID" but got "id".');
}).fin(done);
});
it('should succeed when the expected ID is correct', function(done) {
@@ -157,15 +157,15 @@ describe('fetch', function() {
});
waitsFor(function() { return done; }, 'fetch promise never resolved', 250);
runs(function() {
expect(done).toEqual(new Error('--link is not supported for git URLs'));
expect(''+done).toContain('--link is not supported for git URLs');
});
});
it('should fail when the expected ID doesn\'t match', function(done) {
fetch('https://github.com/bobeast/GAPlugin.git', temp, { expected_id: 'wrongID' })
.then(function() {
expect('this call').toBe('fail');
}, function(err) {
expect(err).toEqual(new Error('Expected fetched plugin to have ID "wrongID" but got "id".'));
expect(''+err).toContain('Expected fetched plugin to have ID "wrongID" but got "id".');
}).fin(done);
});
it('should succeed when the expected ID is correct', function(done) {
@@ -199,7 +199,7 @@ describe('fetch', function() {
.then(function() {
expect('this call').toBe('fail');
}, function(err) {
expect(err).toEqual(new Error('Expected fetched plugin to have ID "wrongID" but got "id".'));
expect(''+err).toContain('Expected fetched plugin to have ID "wrongID" but got "id".');
}).fin(done);
});
it('should succeed when the expected ID is correct', function(done) {
@@ -413,7 +413,7 @@ describe('install', function() {
});
waitsFor(function() { return done; }, 'install promise never resolved', 200);
runs(function() {
expect(done).toEqual(new Error('atari not supported.'));
expect(''+done).toContain('atari not supported.');
});
});
it('should throw if variables are missing', function() {
@@ -422,7 +422,7 @@ describe('install', function() {
});
waitsFor(function(){ return done; }, 'install promise never resolved', 200);
runs(function() {
expect(done).toEqual(new Error('Variable(s) missing: API_KEY'));
expect(''+done).toContain('Variable(s) missing: API_KEY');
});
});
it('should throw if git is not found on the path and a remote url is requested', function() {
@@ -433,7 +433,7 @@ describe('install', function() {
});
waitsFor(function(){ return done; }, 'install promise never resolved', 200);
runs(function() {
expect(done).toEqual(new Error('"git" command line tool is not installed: make sure it is accessible on your PATH.'));
expect(''+done).toContain('"git" command line tool is not installed: make sure it is accessible on your PATH.');
});
});
it('should throw if plugin version is less than the minimum requirement', function(){
@@ -446,7 +446,7 @@ describe('install', function() {
});
waitsFor(function(){ return done; }, 'install promise never resolved', 200);
runs(function() {
expect(done).toEqual(new Error('Plugin doesn\'t support this project\'s cordova version. cordova: 0.0.1, failed version requirement: >=2.3.0'));
expect(''+done).toContain('Plugin doesn\'t support this project\'s cordova version. cordova: 0.0.1, failed version requirement: >=2.3.0');
});
});
});
@@ -127,7 +127,7 @@ describe('uninstallPlatform', function() {
});
waitsFor(function() { return done; }, 'promise never resolved', 200);
runs(function() {
expect(done).toEqual(new Error('atari not supported.'));
expect(''+done).toContain('atari not supported.');
});
});
it('should throw if plugin is missing', function() {
@@ -136,7 +136,7 @@ describe('uninstallPlatform', function() {
});
waitsFor(function() { return done; }, 'promise never resolved', 200);
runs(function() {
expect(done).toEqual(new Error('Plugin "SomePluginThatDoesntExist" not found. Already uninstalled?'));
expect(''+done).toContain('Plugin "SomePluginThatDoesntExist" not found. Already uninstalled?');
});
});
});
@@ -237,7 +237,7 @@ describe('uninstall', function() {
});
waitsFor(function() { return done; }, 'promise never resolved', 200);
runs(function() {
expect(done).toEqual(new Error('atari not supported.'));
expect(''+done).toContain('atari not supported.');
});
});
it('should throw if plugin is missing', function() {
@@ -246,7 +246,7 @@ describe('uninstall', function() {
});
waitsFor(function() { return done; }, 'promise never resolved', 200);
runs(function() {
expect(done).toEqual(new Error('Plugin "SomePluginThatDoesntExist" not found. Already uninstalled?'));
expect(''+done).toContain('Plugin "SomePluginThatDoesntExist" not found. Already uninstalled?');
});
});
});
@@ -28,9 +28,9 @@ describe('action-stack', function() {
var first_args = [1];
var first_reverter = jasmine.createSpy();
var first_reverter_args = [true];
var process_err = 'quit peein\' on my rug, man.';
var process_err = new Error('process_err');
var second_spy = jasmine.createSpy().andCallFake(function() {
throw new Error(process_err);
throw process_err;
});
var second_args = [2];
var third_spy = jasmine.createSpy();
@@ -45,7 +45,7 @@ describe('action-stack', function() {
});
waitsFor(function(){ return error; }, 'process promise never resolved', 500);
runs(function() {
expect(error).toEqual(new Error('Uh oh!\n' + process_err));
expect(error).toEqual(process_err);
// first two actions should have been called, but not the third
expect(first_spy).toHaveBeenCalledWith(first_args[0]);
expect(second_spy).toHaveBeenCalledWith(second_args[0]);
@@ -27,9 +27,10 @@ describe('callback wrapper', function() {
});

it('should call the callback with the error on failure', function(done) {
raw.andCallFake(function() { return Q.reject(new Error('junk'))});
var err = new Error('junk');
raw.andCallFake(function() { return Q.reject(err)});
plugman[call](function(err) {
expect(err).toEqual(new Error('junk'));
expect(err).toEqual(err);
done();
});
});

0 comments on commit 21ae0e4

Please sign in to comment.