cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [24/50] [abbrv] cordova-lib git commit: CB-12018: updated custom jasmine matcher toExist
Date Wed, 18 Jan 2017 01:56:41 GMT
CB-12018: updated custom jasmine matcher toExist


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/1fa012f3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/1fa012f3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/1fa012f3

Branch: refs/heads/fetch-1.0.x
Commit: 1fa012f32c73e75b6de12a2d391326433005287a
Parents: 0e0d7a5
Author: Steve Gill <stevengill97@gmail.com>
Authored: Thu Dec 15 22:52:29 2016 -0800
Committer: audreyso <auso@adobe.com>
Committed: Tue Jan 10 11:14:05 2017 -0800

----------------------------------------------------------------------
 cordova-lib/spec-cordova/HooksRunner.spec.js |  2 +-
 cordova-lib/spec-cordova/helpers.js          | 21 ++++--
 cordova-lib/spec-plugman/install.spec.js     | 69 ++++++++++---------
 cordova-lib/spec-plugman/uninstall.spec.js   | 81 ++++++++++++-----------
 4 files changed, 94 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1fa012f3/cordova-lib/spec-cordova/HooksRunner.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/HooksRunner.spec.js b/cordova-lib/spec-cordova/HooksRunner.spec.js
index 367c436..697787d 100644
--- a/cordova-lib/spec-cordova/HooksRunner.spec.js
+++ b/cordova-lib/spec-cordova/HooksRunner.spec.js
@@ -444,7 +444,7 @@ describe('HooksRunner', function() {
                         // Delete unique ids to allow comparing PluginInfo
                         delete androidPluginOpts.plugin.pluginInfo._et;
 
-                        fire.calls.forEach(function(call) {
+                        fire.calls.all().forEach(function(call) {
                             if(call.args[1] && call.args[1].plugin) {
                                 // Delete unique ids to allow comparing PluginInfo
                                 delete call.args[1].plugin.pluginInfo._et;

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1fa012f3/cordova-lib/spec-cordova/helpers.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/helpers.js b/cordova-lib/spec-cordova/helpers.js
index 257f4bd..e77078a 100644
--- a/cordova-lib/spec-cordova/helpers.js
+++ b/cordova-lib/spec-cordova/helpers.js
@@ -150,14 +150,21 @@ module.exports.writeConfigContent = function (appPath, configContent)
{
 beforeEach(function () {
     jasmine.addMatchers({
         'toExist': function () {
-            var notText = this.isNot ? ' not' : '';
-            var self = this;
+            return {
+                compare: function(actual, expected) {
+                    var result = {};
 
-            this.message = function () {
-                return 'Expected file ' + self.actual + notText + ' to exist.';
-            };
+                    result.pass = fs.existsSync(actual);
 
-            return fs.existsSync(this.actual);
+                    if(result.pass) {
+                        result.message = "expected " + actual + " to not exist";
+                    } else {
+                        result.message = "expected " + actual + " to exist";
+                    }
+
+                    return result;
+                }
+            }
         }
     });
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1fa012f3/cordova-lib/spec-plugman/install.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/install.spec.js b/cordova-lib/spec-plugman/install.spec.js
index 49c09cc..d3af713 100644
--- a/cordova-lib/spec-plugman/install.spec.js
+++ b/cordova-lib/spec-plugman/install.spec.js
@@ -239,7 +239,6 @@ describe('install', function() {
         it('should call fetch if provided plugin cannot be resolved locally', function()
{
             fetchSpy.and.returnValue( Q( plugins['org.test.plugins.dummyplugin'] ) );
             spyOn(fs, 'existsSync').and.callFake( fake['existsSync']['noPlugins'] );
-
             runs(function() {
                 installPromise(install('android', project, 'CLEANYOURSHORTS' ));
             });
@@ -249,7 +248,8 @@ describe('install', function() {
                 expect(fetchSpy).toHaveBeenCalled();
             });
         });
-        it('should call fetch and convert oldID to newID', function() {
+
+        it('should call fetch and convert oldID to newID', function(done) {
             fetchSpy.and.returnValue( Q( plugins['org.test.plugins.dummyplugin'] ) );
             spyOn(fs, 'existsSync').and.callFake( fake['existsSync']['noPlugins'] );
             var emit = spyOn(events, 'emit');
@@ -263,7 +263,6 @@ describe('install', function() {
                 expect(fetchSpy).toHaveBeenCalled();
             });
         });
-
         describe('engine versions', function () {
             var fail, satisfies;
             beforeEach(function () {
@@ -345,13 +344,14 @@ describe('install', function() {
 
         it('should not check custom engine version that is not supported for platform', function()
{
             var spy = spyOn(semver, 'satisfies').and.returnValue(true);
-            runs(function() {
-                installPromise( install('blackberry10', project, plugins['com.cordova.engine'])
);
-            });
-            waitsFor(function() { return done; }, 'install promise never resolved', 200);
-            runs(function() {
+            install('blackberry10', project, plugins['com.cordova.engine']).then(function(done)
{
+                expect(false).toBe(true);
+                done();
+            },
+            function err(errMsg) {
                 expect(spy).not.toHaveBeenCalledWith('','>=3.0.0');
-            });
+                done();
+            }, 6000);
         });
 
         describe('with dependencies', function() {
@@ -479,14 +479,15 @@ describe('install', function() {
     });
 
     describe('failure', function() {
-        it('should throw if platform is unrecognized', function() {
-            runs(function() {
-                installPromise( install('atari', project, 'SomePlugin') );
-            });
-            waitsFor(function() { return done; }, 'install promise never resolved', 200);
-            runs(function() {
-                expect(''+done).toContain('atari not supported.');
-            });
+        it('should throw if platform is unrecognized', function(done) {
+            install('atari', project, 'SomePlugin').then(function() {
+                expect(false).toBe(true);
+                done();
+            },
+            function err(errMsg) {
+                expect(errMsg.toString()).toContain('atari not supported.');
+                done();
+            }, 6000);
         });
         it('should throw if variables are missing', function(done) {
             var success = jasmine.createSpy('success');
@@ -494,38 +495,40 @@ describe('install', function() {
             install('android', project, plugins['com.adobe.vars'])
             .then(success)
             .fail(function (err) {
-                expect(err).toContain('Variable(s) missing: API_KEY');
+                expect(err.toString()).toContain('Variable(s) missing: API_KEY');
             })
             .fin(function () {
                 expect(success).not.toHaveBeenCalled();
                 done();
             });
         });
-        it('should throw if git is not found on the path and a remote url is requested',
function() {
+        it('should throw if git is not found on the path and a remote url is requested',
function(done) {
             spyOn(fs, 'existsSync').and.callFake( fake['existsSync']['noPlugins'] );
             fetchSpy.and.callThrough();
             spyOn(shell, 'which').and.returnValue(null);
-            runs(function() {
-                installPromise( install('android', project, 'https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git')
);
-            });
-            waitsFor(function(){ return done; }, 'install promise never resolved', 200);
-            runs(function() {
-                expect(''+done).toContain('"git" command line tool is not installed: make
sure it is accessible on your PATH.');
+            install('android', project, 'https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git').then(function(result)
{
+                expect(false).toBe(true);
+                done();
+            },
+            function err(errMsg) {
+                expect(errMsg.toString()).toContain('"git" command line tool is not installed:
make sure it is accessible on your PATH.');
+                done();
             });
-        });
+        }, 6000);
+
         it('should not fail when trying to install plugin less than minimum version. Skip
instead  ', function(){
             spyOn(semver, 'satisfies').and.returnValue(false);
             exec.and.callFake(function(cmd, cb) {
                 cb(null, '0.0.1\n');
             });
-            runs(function() {
-                installPromise( install('android', project, plugins['com.cordova.engine'])
);
+            install('android', project, plugins['com.cordova.engine']).then(function(result)
{
+                expect(false).toBe(true);
+            },
+            function err(errMsg) {
+                expect(errMsg.toString()).toMatch(true);
             });
-            waitsFor(function(){ return done; }, 'install promise never resolved', 200);
-            runs(function() {
-                expect(''+done).toMatch(true);
-            });
-        });
+        }, 6000);
+
         it('should throw if the engine scriptSrc escapes out of the plugin dir.', function(done)
{
             var success = jasmine.createSpy('success'),
                 fail = jasmine.createSpy('fail').and.callFake(function(err) {

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1fa012f3/cordova-lib/spec-plugman/uninstall.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/uninstall.spec.js b/cordova-lib/spec-plugman/uninstall.spec.js
index fe1e96c..95e0b2b 100644
--- a/cordova-lib/spec-plugman/uninstall.spec.js
+++ b/cordova-lib/spec-plugman/uninstall.spec.js
@@ -177,12 +177,12 @@ describe('uninstallPlatform', function() {
             .fin(done);
         });
 
-        describe('with dependencies', function() {
+    describe('with dependencies', function() {
             var emit;
             beforeEach(function() {
                 emit = spyOn(events, 'emit');
             });
-            it('should uninstall "dangling" dependencies', function() {
+            it('should uninstall "dangling" dependencies', function(done) {
                 runs(function() {
                     uninstallPromise(uninstall.uninstallPlatform('android', project, 'A'));
                 });
@@ -195,24 +195,27 @@ describe('uninstallPlatform', function() {
     });
 
     describe('failure', function() {
-        it('should throw if platform is unrecognized', function() {
-            runs(function() {
-                uninstallPromise( uninstall.uninstallPlatform('atari', project, 'SomePlugin')
);
-            });
-            waitsFor(function() { return done; }, 'promise never resolved', 200);
-            runs(function() {
-                expect(''+done).toContain('atari not supported.');
-            });
-        });
-        it('should throw if plugin is missing', function() {
-            runs(function() {
-                uninstallPromise( uninstall.uninstallPlatform('android', project, 'SomePluginThatDoesntExist')
);
+        it('should throw if platform is unrecognized', function(done) {
+            uninstall.uninstallPlatform('atari', project, 'SomePlugin').then(function(result){
+                expect(false).toBe(true);
+                done();
+            },
+            function err(errMsg) {
+                expect(errMsg.toString()).toContain('atari not supported.');
+                done();
             });
-            waitsFor(function() { return done; }, 'promise never resolved', 200);
-            runs(function() {
-                expect(''+done).toContain('Plugin "SomePluginThatDoesntExist" not found.
Already uninstalled?');
+        }, 6000);
+
+        it('should throw if plugin is missing', function(done) {
+            uninstall.uninstallPlatform('android', project, 'SomePluginThatDoesntExist').then(function(result){
+                expect(false).toBe(true);
+                done();
+            },
+            function err(errMsg) {
+                expect(errMsg.toString()).toContain('Plugin "SomePluginThatDoesntExist" not
found. Already uninstalled?');
+                done();
             });
-        });
+        }, 6000);
     });
 });
 
@@ -244,7 +247,7 @@ describe('uninstallPlugin', function() {
             });
         });
 
-        it('should fail if plugin is a required dependency', function() {
+        it('should fail if plugin is a required dependency', function(done) {
             runs(function() {
                 uninstallPromise( uninstall.uninstallPlugin('C', plugins_install_dir) );
             });
@@ -281,7 +284,7 @@ describe('uninstallPlugin', function() {
             });
         });
 
-        it('should not remove dependent plugin if it was installed after as top-level', function()
{
+        it('should not remove dependent plugin if it was installed after as top-level', function(done)
{
             runs(function() {
                 uninstallPromise( uninstall.uninstallPlugin('A', plugins_install_dir3) );
             });
@@ -308,31 +311,34 @@ describe('uninstall', function() {
     });
 
     describe('failure', function() {
-        it('should throw if platform is unrecognized', function() {
-            runs(function() {
-                uninstallPromise(uninstall('atari', project, 'SomePlugin'));
+        it('should throw if platform is unrecognized', function(done) {
+            uninstall('atari', project, 'SomePlugin').then(function(result){
+                expect(false).toBe(true);
+                done();
+            },
+            function err(errMsg) {
+                expect(clone).toHaveBeenCalledWith(url, temp, dir, ref, undefined);
+                expect(save_metadata).toHaveBeenCalled();
+                done();
             });
-            waitsFor(function() { return done; }, 'promise never resolved', 200);
-            runs(function() {
-                expect(''+done).toContain('atari not supported.');
-            });
-        });
-        it('should throw if plugin is missing', function() {
-            runs(function() {
-                uninstallPromise(uninstall('android', project, 'SomePluginThatDoesntExist'));
+        }, 6000);
+
+        it('should throw if plugin is missing', function(done) {
+            uninstall('android', project, 'SomePluginThatDoesntExist').then(function(result){
+                expect(false).toBe(true);
+                done();
+            },
+            function err(errMsg) {
+                expect(errMsg.toString()).toContain('Plugin "SomePluginThatDoesntExist" not
found. Already uninstalled?');
+                done();
             });
-            waitsFor(function() { return done; }, 'promise never resolved', 200);
-            runs(function() {
-                expect(''+done).toContain('Plugin "SomePluginThatDoesntExist" not found.
Already uninstalled?');
-            });
-        });
+        }, 6000);
     });
 });
 
 describe('end', function() {
     it('end', function() {
         done = false;
-
         promise.then(function(){
             return uninstall('android', project, plugins['org.test.plugins.dummyplugin']);
         }).then(function(){
@@ -350,7 +356,6 @@ describe('end', function() {
             shell.rm('-rf', project, project2, project3);
             done = true;
         });
-
         waitsFor(function() { return done; }, 'promise never resolved', 500);
     });
 });


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message