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/11/23 01:47:04 UTC

[cordova-lib] branch master updated: test: move cordova/platform/{platform => addHelper} (#803)

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-lib.git


The following commit(s) were added to refs/heads/master by this push:
     new 90ed43a  test: move cordova/platform/{platform => addHelper} (#803)
90ed43a is described below

commit 90ed43a0196686f2c425909febc40c1c4d83fb41
Author: Raphael von der GrĂ¼n <ra...@gmail.com>
AuthorDate: Sat Nov 23 02:46:56 2019 +0100

    test: move cordova/platform/{platform => addHelper} (#803)
    
    Following an existing TODO to get rid of an obsolete spec file.
---
 spec/cordova/platform/addHelper.spec.js | 13 ++++---
 spec/cordova/platform/platform.spec.js  | 69 ---------------------------------
 2 files changed, 7 insertions(+), 75 deletions(-)

diff --git a/spec/cordova/platform/addHelper.spec.js b/spec/cordova/platform/addHelper.spec.js
index a81dc32..7a16968 100644
--- a/spec/cordova/platform/addHelper.spec.js
+++ b/spec/cordova/platform/addHelper.spec.js
@@ -17,6 +17,7 @@
 
 var path = require('path');
 var fs = require('fs-extra');
+var util = require('util');
 var events = require('cordova-common').events;
 var rewire = require('rewire');
 var cordova_util = require('../../../src/cordova/util');
@@ -91,12 +92,12 @@ describe('cordova/platform/addHelper', function () {
     });
 
     describe('error/warning conditions', function () {
-        it('should require specifying at least one platform', function () {
-            return platform_addHelper('add', hooks_mock).then(function () {
-                fail('addHelper success handler unexpectedly invoked');
-            }, function (e) {
-                expect(e.message).toContain('No platform specified.');
-            });
+        it('should require specifying at least one platform', async () => {
+            for (const targets of [[], undefined, null]) {
+                await expectAsync(platform_addHelper('add', hooks_mock, projectRoot, targets))
+                    .withContext(`targets = ${util.inspect(targets)}`)
+                    .toBeRejectedWithError(/No platform specified\./);
+            }
         });
 
         it('should log if host OS does not support the specified platform', function () {
diff --git a/spec/cordova/platform/platform.spec.js b/spec/cordova/platform/platform.spec.js
deleted file mode 100644
index 3befafa..0000000
--- a/spec/cordova/platform/platform.spec.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
-    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 os = require('os');
-var platform = require('../../../src/cordova/platform');
-
-describe('cordova.platform', function () {
-    // TODO: all these tests below can be moved to addHelper.spec.js, under the "it should require specifying at least one platform" test.
-    describe('add function', function () {
-        var opts;
-        var hooksRunnerMock;
-        var projectRoot = os.tmpdir();
-
-        const NO_PLATFORMS_MSG = 'No platform specified. Please specify a platform to add. See `cordova platform list`.';
-
-        beforeEach(function () {
-            opts = {};
-            hooksRunnerMock = {
-                fire: function () {
-                    return Promise.resolve();
-                }
-            };
-        });
-
-        it('Test 004 : throws if the target list is empty', function () {
-            var targets = [];
-            return platform.add(hooksRunnerMock, projectRoot, targets, opts).then(function () {
-                fail('Expected promise to be rejected');
-            }, function (err) {
-                expect(err).toEqual(jasmine.any(Error));
-                expect(err.message).toBe(NO_PLATFORMS_MSG);
-            });
-        });
-
-        it('Test 005 : throws if the target list is undefined', function () {
-            var targets; // = undefined;
-            return platform.add(hooksRunnerMock, projectRoot, targets, opts).then(function () {
-                fail('Expected promise to be rejected');
-            }, function (err) {
-                expect(err).toEqual(jasmine.any(Error));
-                expect(err.message).toBe(NO_PLATFORMS_MSG);
-            });
-        });
-
-        it('Test 006 : throws if the target list is null', function () {
-            const targets = null;
-            return platform.add(hooksRunnerMock, projectRoot, targets, opts).then(function () {
-                fail('Expected promise to be rejected');
-            }, function (err) {
-                expect(err).toEqual(jasmine.any(Error));
-                expect(err.message).toBe(NO_PLATFORMS_MSG);
-            });
-        });
-    });
-});


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