You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/12/08 18:47:00 UTC

[jira] [Commented] (CB-12361) Speed up cordova-lib tests

    [ https://issues.apache.org/jira/browse/CB-12361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16284013#comment-16284013 ] 

ASF GitHub Bot commented on CB-12361:
-------------------------------------

stevengill closed pull request #603: CB-12361 : added unit tests for check.js
URL: https://github.com/apache/cordova-lib/pull/603
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/spec/cordova/platform/check.spec.js b/spec/cordova/platform/check.spec.js
new file mode 100644
index 000000000..bb4456d29
--- /dev/null
+++ b/spec/cordova/platform/check.spec.js
@@ -0,0 +1,83 @@
+/**
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+http://www.apache.org/licenses/LICENSE-2.0
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+*/
+
+var Q = require('q');
+var shell = require('shelljs');
+var events = require('cordova-common').events;
+var superspawn = require('cordova-common').superspawn;
+var rewire = require('rewire');
+var platform_check = rewire('../../../src/cordova/platform/check');
+var cordova_util = require('../../../src/cordova/util');
+
+describe('cordova/platform/check', function () {
+    var projectRoot = '/some/path';
+    var hooks_mock;
+
+    beforeEach(function () {
+        spyOn(events, 'emit');
+        spyOn(superspawn, 'spawn').and.callThrough();
+        spyOn(shell, 'rm');
+        spyOn(cordova_util, 'listPlatforms');
+    });
+
+    it('If no results, platforms cannot be updated', function (done) {
+        cordova_util.listPlatforms.and.callThrough();
+        platform_check(hooks_mock, projectRoot).then(function () {
+            expect(events.emit).toHaveBeenCalledWith('results', jasmine.stringMatching(/No platforms can be updated/));
+            expect(superspawn.spawn).toHaveBeenCalledWith('npm', ['--loglevel=silent', '--json', 'outdated', 'cordova-lib'], jasmine.any(Object));
+            expect(shell.rm).toHaveBeenCalledWith('-rf', jasmine.any(String));
+        }).fail(function (err) {
+            fail('unexpected failure handler invoked!');
+            console.error(err);
+        }).done(done);
+    });
+
+    it('Should warn if install failed', function (done) {
+        cordova_util.listPlatforms.and.returnValue(['ios']);
+        platform_check(hooks_mock, projectRoot).then(function () {
+            expect(events.emit).toHaveBeenCalledWith('results', jasmine.stringMatching(/current did not install/));
+        }).fail(function (err) {
+            fail('unexpected failure handler invoked!');
+            console.error(err);
+        }).done(done);
+    });
+
+    it('Should warn if version-empty', function (done) {
+        cordova_util.listPlatforms.and.returnValue(['ios']);
+        spyOn(require('../../../src/cordova/platform/index'), 'add').and.returnValue(Q());
+        superspawn.spawn.and.returnValue(Q());
+        platform_check(hooks_mock, projectRoot).then(function () {
+            expect(events.emit).toHaveBeenCalledWith('results', jasmine.stringMatching(/current version script failed to return a version/));
+        }).fail(function (err) {
+            fail('unexpected failure handler invoked!');
+            console.error(err);
+        }).done(done);
+    });
+
+    it('Should warn if version-failed', function (done) {
+        cordova_util.listPlatforms.and.returnValue(['ios']);
+        spyOn(require('../../../src/cordova/platform/index'), 'add').and.returnValue(Q());
+        spyOn(superspawn, 'maybeSpawn').and.returnValue(Q('version-failed'));
+        spyOn(Q.defer(), 'resolve').and.returnValue('version-failed');
+        platform_check(hooks_mock, projectRoot).then(function () {
+            expect(events.emit).toHaveBeenCalledWith('results', jasmine.stringMatching(/current version script failed, and/));
+        }).fail(function (err) {
+            fail('unexpected failure handler invoked!');
+            console.error(err);
+        }).done(done);
+    });
+});


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Speed up cordova-lib tests
> --------------------------
>
>                 Key: CB-12361
>                 URL: https://issues.apache.org/jira/browse/CB-12361
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: cordova-lib
>            Reporter: Steve Gill
>            Assignee: Steve Gill
>              Labels: cordova-next
>
> * Split out e2e tests into own folder
> * stub i/o and network requests
> * use local fixtures when possible & makes sense



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

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