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:29 UTC

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

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