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 09:04:41 UTC

[cordova-common] branch master updated: Update to jasmine 3.4 & fix resulting spec failures (#80)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 5a35287  Update to jasmine 3.4 & fix resulting spec failures (#80)
5a35287 is described below

commit 5a35287a197f8db5ccd6451457312a69f8d20ba0
Author: Raphael von der GrĂ¼n <ra...@gmail.com>
AuthorDate: Tue Jun 18 11:04:37 2019 +0200

    Update to jasmine 3.4 & fix resulting spec failures (#80)
---
 package.json               |  2 +-
 spec/.eslintrc.yml         |  4 ++++
 spec/PluginManager.spec.js | 12 ++++++------
 spec/superspawn.spec.js    | 12 +++++++-----
 4 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/package.json b/package.json
index bcd43eb..b3e84ae 100644
--- a/package.json
+++ b/package.json
@@ -46,7 +46,7 @@
     "eslint-plugin-promise": "^4.0.0",
     "eslint-plugin-standard": "^4.0.0",
     "istanbul": "^0.4.5",
-    "jasmine": "~3.1.0",
+    "jasmine": "^3.4.0",
     "jasmine-spec-reporter": "^4.2.1",
     "osenv": "^0.1.3",
     "promise-matchers": "^0.9.6",
diff --git a/spec/.eslintrc.yml b/spec/.eslintrc.yml
index 043fd14..0b295ed 100644
--- a/spec/.eslintrc.yml
+++ b/spec/.eslintrc.yml
@@ -1,2 +1,6 @@
 env:
     jasmine: true
+
+# Not covered by jasmine env as of writing
+globals:
+    expectAsync: false
diff --git a/spec/PluginManager.spec.js b/spec/PluginManager.spec.js
index 9c54277..8ae74fe 100644
--- a/spec/PluginManager.spec.js
+++ b/spec/PluginManager.spec.js
@@ -74,13 +74,13 @@ describe('PluginManager class', function () {
 
         describe('addPlugin method', function () {
             it('should return a promise', function () {
-                expect(Q.isPromise(manager.addPlugin(null, {}))).toBe(true);
+                return expectAsync(manager.addPlugin(new PluginInfo(DUMMY_PLUGIN), {})).toBeResolved();
             });
-            // Promise-matchers do not work with jasmine 2.0.
-            xit('Test 003 : should reject if "plugin" parameter is not specified or not a PluginInfo instance', function (done) {
-                expect(manager.addPlugin(null, {})).toHaveBeenRejected(done);
-                expect(manager.addPlugin({}, {})).toHaveBeenRejected(done);
-                expect(manager.addPlugin(new PluginInfo(DUMMY_PLUGIN), {})).not.toHaveBeenRejected(done);
+
+            it('Test 003 : should reject if "plugin" parameter is not specified or not a PluginInfo instance', () => {
+                return Promise.resolve()
+                    .then(() => expectAsync(manager.addPlugin(null, {})).toBeRejected())
+                    .then(() => expectAsync(manager.addPlugin({}, {})).toBeRejected());
             });
 
             it('Test 004 : should iterate through all plugin\'s files and frameworks', () => {
diff --git a/spec/superspawn.spec.js b/spec/superspawn.spec.js
index ddd3b50..255b238 100644
--- a/spec/superspawn.spec.js
+++ b/spec/superspawn.spec.js
@@ -17,7 +17,6 @@
     under the License.
 */
 
-var Q = require('q');
 var path = require('path');
 var superspawn = require('../src/superspawn');
 
@@ -31,9 +30,12 @@ describe('spawn method', function () {
         failSpy = jasmine.createSpy('fail'); /* eslint no-unused-vars : 0 */
     });
 
-    it('Test 001 : should return a promise', function () {
-        expect(Q.isPromise(superspawn.spawn(LS))).toBe(true);
-        expect(Q.isPromise(superspawn.spawn('invalid_command'))).toBe(true);
+    it('should resolve on success', () => {
+        return expectAsync(superspawn.spawn(LS)).toBeResolved();
+    });
+
+    it('should reject on failure', () => {
+        return expectAsync(superspawn.spawn('invalid_command')).toBeRejected();
     });
 
     it('Test 002 : should notify about stdout "data" events', () => {
@@ -101,7 +103,7 @@ describe('spawn method', function () {
         let promise;
         expect(() => { promise = superspawn.spawn(TEST_SCRIPT, []); }).not.toThrow();
 
-        return Promise.resolve(promise).then(_ => {
+        return promise.then(() => {
             fail('Expected promise to be rejected');
         }, err => {
             expect(err).toEqual(jasmine.any(Error));


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