You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ra...@apache.org on 2019/06/18 01:20:25 UTC

[cordova-common] branch clean-spec-promises created (now f926cbb)

This is an automated email from the ASF dual-hosted git repository.

raphinesse pushed a change to branch clean-spec-promises
in repository https://gitbox.apache.org/repos/asf/cordova-common.git.


      at f926cbb  Clean up Promise handling in superspawn spec

This branch includes the following new commits:

     new 0c121bb  Proper expected rejection check in ActionStack spec
     new 4ade321  Clean up Promise handling in PluginManager spec
     new a5c411b  Remove usage of jasmine's done in sync specs
     new f926cbb  Clean up Promise handling in superspawn spec

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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


[cordova-common] 01/04: Proper expected rejection check in ActionStack spec

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

raphinesse pushed a commit to branch clean-spec-promises
in repository https://gitbox.apache.org/repos/asf/cordova-common.git

commit 0c121bb651f1c464568d9c0f8ca049996539664b
Author: Raphael von der Grün <ra...@gmail.com>
AuthorDate: Tue Jun 18 01:55:52 2019 +0200

    Proper expected rejection check in ActionStack spec
---
 spec/ActionStack.spec.js | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/spec/ActionStack.spec.js b/spec/ActionStack.spec.js
index 44df820..496d73b 100644
--- a/spec/ActionStack.spec.js
+++ b/spec/ActionStack.spec.js
@@ -41,7 +41,7 @@ describe('action-stack', function () {
             expect(second_spy).toHaveBeenCalledWith(second_args[0]);
             expect(third_spy).toHaveBeenCalledWith(third_args[0]);
         });
-        it('Test 002 : should revert processed actions if an exception occurs', function (done) {
+        it('Test 002 : should revert processed actions if an exception occurs', function () {
             spyOn(console, 'log');
             var first_spy = jasmine.createSpy();
             var first_args = [1];
@@ -57,13 +57,12 @@ describe('action-stack', function () {
             stack.push(stack.createAction(first_spy, first_args, first_reverter, first_reverter_args));
             stack.push(stack.createAction(second_spy, second_args, function () {}, []));
             stack.push(stack.createAction(third_spy, third_args, function () {}, []));
+
             // process should throw
-            var error;
-            stack.process('android', android_one_project)
-                .then(function () {
-                    expect(false).toBe(true);
-                }).fail(function (err) {
-                    error = err;
+            return stack.process('android', android_one_project)
+                .then(() => {
+                    fail('Expected promise to be rejected');
+                }, error => {
                     expect(error).toEqual(process_err);
                     // first two actions should have been called, but not the third
                     expect(first_spy).toHaveBeenCalledWith(first_args[0]);
@@ -71,7 +70,7 @@ describe('action-stack', function () {
                     expect(third_spy).not.toHaveBeenCalledWith(third_args[0]);
                     // first reverter should have been called after second action exploded
                     expect(first_reverter).toHaveBeenCalledWith(first_reverter_args[0]);
-                }).fin(done);
+                });
         });
     });
 });


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


[cordova-common] 04/04: Clean up Promise handling in superspawn spec

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

raphinesse pushed a commit to branch clean-spec-promises
in repository https://gitbox.apache.org/repos/asf/cordova-common.git

commit f926cbbb7baf514bec97758f0efce8a634284d83
Author: Raphael von der Grün <ra...@gmail.com>
AuthorDate: Tue Jun 18 02:26:08 2019 +0200

    Clean up Promise handling in superspawn spec
---
 spec/superspawn.spec.js | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/spec/superspawn.spec.js b/spec/superspawn.spec.js
index 9c05129..ddd3b50 100644
--- a/spec/superspawn.spec.js
+++ b/spec/superspawn.spec.js
@@ -36,25 +36,25 @@ describe('spawn method', function () {
         expect(Q.isPromise(superspawn.spawn('invalid_command'))).toBe(true);
     });
 
-    it('Test 002 : should notify about stdout "data" events', function (done) {
-        superspawn.spawn(LS, [], { stdio: 'pipe' })
+    it('Test 002 : should notify about stdout "data" events', () => {
+        return superspawn.spawn(LS, [], { stdio: 'pipe' })
             .progress(progressSpy)
-            .fin(function () {
+            .then(function () {
                 expect(progressSpy).toHaveBeenCalledWith({ 'stdout': jasmine.any(String) });
-                done();
             });
     });
 
-    it('Test 003 : should notify about stderr "data" events', function (done) {
-        superspawn.spawn(LS, ['doesnt-exist'], { stdio: 'pipe' })
+    it('Test 003 : should notify about stderr "data" events', () => {
+        return superspawn.spawn(LS, ['doesnt-exist'], { stdio: 'pipe' })
             .progress(progressSpy)
-            .fin(function () {
+            .then(() => {
+                fail('Expected promise to be rejected');
+            }, () => {
                 expect(progressSpy).toHaveBeenCalledWith({ 'stderr': jasmine.any(String) });
-                done();
             });
     });
 
-    it('Test 004 : reject handler should pass in Error object with stdout and stderr properties', function (done) {
+    it('Test 004 : reject handler should pass in Error object with stdout and stderr properties', () => {
         var cp = require('child_process');
         spyOn(cp, 'spawn').and.callFake(function (cmd, args, opts) {
             return {
@@ -80,12 +80,13 @@ describe('spawn method', function () {
                 removeListener: function () {}
             };
         });
-        superspawn.spawn('this aggression', ['will', 'not', 'stand', 'man'], {})
-            .catch(function (err) {
+        return superspawn.spawn('this aggression', ['will', 'not', 'stand', 'man'], {})
+            .then(() => {
+                fail('Expected promise to be rejected');
+            }, err => {
                 expect(err).toBeDefined();
                 expect(err.stdout).toContain('usual');
                 expect(err.stderr).toContain('mayday');
-                done();
             });
     });
 


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


[cordova-common] 02/04: Clean up Promise handling in PluginManager spec

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

raphinesse pushed a commit to branch clean-spec-promises
in repository https://gitbox.apache.org/repos/asf/cordova-common.git

commit 4ade321929af5ed78ee1d0b666a9e65868309091
Author: Raphael von der Grün <ra...@gmail.com>
AuthorDate: Tue Jun 18 02:14:10 2019 +0200

    Clean up Promise handling in PluginManager spec
---
 spec/PluginManager.spec.js | 28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)

diff --git a/spec/PluginManager.spec.js b/spec/PluginManager.spec.js
index b54133a..9c54277 100644
--- a/spec/PluginManager.spec.js
+++ b/spec/PluginManager.spec.js
@@ -58,7 +58,6 @@ describe('PluginManager class', function () {
     describe('instance', function () {
         var actions, manager;
         var FAKE_PROJECT;
-        var fail = jasmine.createSpy('fail');
         var ActionStackOrig = PluginManager.__get__('ActionStack');
 
         beforeEach(function () {
@@ -84,8 +83,8 @@ describe('PluginManager class', function () {
                 expect(manager.addPlugin(new PluginInfo(DUMMY_PLUGIN), {})).not.toHaveBeenRejected(done);
             });
 
-            it('Test 004 : should iterate through all plugin\'s files and frameworks', function (done) {
-                manager.addPlugin(new PluginInfo(DUMMY_PLUGIN), {})
+            it('Test 004 : should iterate through all plugin\'s files and frameworks', () => {
+                return manager.addPlugin(new PluginInfo(DUMMY_PLUGIN), {})
                     .then(function () {
                         expect(FAKE_PROJECT.getInstaller.calls.count()).toBe(16);
                         expect(FAKE_PROJECT.getUninstaller.calls.count()).toBe(16);
@@ -93,43 +92,28 @@ describe('PluginManager class', function () {
                         expect(actions.push.calls.count()).toBe(16);
                         expect(actions.process).toHaveBeenCalled();
                         expect(FAKE_PROJECT.write).toHaveBeenCalled();
-                    })
-                    .fail(fail)
-                    .done(function () {
-                        expect(fail).not.toHaveBeenCalled();
-                        done();
                     });
             });
 
-            it('Test 005 : should save plugin metadata to www directory', function (done) {
+            it('Test 005 : should save plugin metadata to www directory', () => {
                 var metadataPath = path.join(manager.locations.www, 'cordova_plugins.js');
                 var platformWwwMetadataPath = path.join(manager.locations.platformWww, 'cordova_plugins.js');
 
-                manager.addPlugin(new PluginInfo(DUMMY_PLUGIN), {})
+                return manager.addPlugin(new PluginInfo(DUMMY_PLUGIN), {})
                     .then(function () {
                         expect(fs.writeFileSync).toHaveBeenCalledWith(metadataPath, jasmine.any(String), 'utf-8');
                         expect(fs.writeFileSync).not.toHaveBeenCalledWith(platformWwwMetadataPath, jasmine.any(String), 'utf-8');
-                    })
-                    .fail(fail)
-                    .done(function () {
-                        expect(fail).not.toHaveBeenCalled();
-                        done();
                     });
             });
 
-            it('Test 006 : should save plugin metadata to both www ans platform_www directories when options.usePlatformWww is specified', function (done) {
+            it('Test 006 : should save plugin metadata to both www ans platform_www directories when options.usePlatformWww is specified', () => {
                 var metadataPath = path.join(manager.locations.www, 'cordova_plugins.js');
                 var platformWwwMetadataPath = path.join(manager.locations.platformWww, 'cordova_plugins.js');
 
-                manager.addPlugin(new PluginInfo(DUMMY_PLUGIN), { usePlatformWww: true })
+                return manager.addPlugin(new PluginInfo(DUMMY_PLUGIN), { usePlatformWww: true })
                     .then(function () {
                         expect(fs.writeFileSync).toHaveBeenCalledWith(metadataPath, jasmine.any(String), 'utf-8');
                         expect(fs.writeFileSync).toHaveBeenCalledWith(platformWwwMetadataPath, jasmine.any(String), 'utf-8');
-                    })
-                    .fail(fail)
-                    .done(function () {
-                        expect(fail).not.toHaveBeenCalled();
-                        done();
                     });
             });
         });


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


[cordova-common] 03/04: Remove usage of jasmine's done in sync specs

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

raphinesse pushed a commit to branch clean-spec-promises
in repository https://gitbox.apache.org/repos/asf/cordova-common.git

commit a5c411b9369aa8bd772148796fc9ae341bea41ec
Author: Raphael von der Grün <ra...@gmail.com>
AuthorDate: Tue Jun 18 02:18:27 2019 +0200

    Remove usage of jasmine's done in sync specs
---
 spec/plist-helpers.spec.js | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/spec/plist-helpers.spec.js b/spec/plist-helpers.spec.js
index fc4c923..031216f 100644
--- a/spec/plist-helpers.spec.js
+++ b/spec/plist-helpers.spec.js
@@ -43,7 +43,7 @@ describe('prunePLIST', function () {
 
     var selector = 'FirstConfigKey';
 
-    it('Test 01: should remove property from plist file using provided selector', function (done) {
+    it('Test 01: should remove property from plist file using provided selector', () => {
         var pruneStatus = plistHelpers.prunePLIST(doc, xml, selector);
 
         expect(pruneStatus).toBeTruthy();
@@ -54,8 +54,6 @@ describe('prunePLIST', function () {
                 }
             }
         );
-
-        done();
     });
 });
 
@@ -74,7 +72,7 @@ describe('plistGraft', function () {
 
     let selector = 'keychain-access-groups';
 
-    it('Test 01: should not mangle existing plist entries', function (done) {
+    it('Test 01: should not mangle existing plist entries', () => {
         var graftStatus = plistHelpers.graftPLIST(doc, xml, selector);
 
         expect(graftStatus).toBeTruthy();
@@ -86,7 +84,5 @@ describe('plistGraft', function () {
                 ]
             }
         );
-
-        done();
     });
 });


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