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 2018/09/06 15:30:06 UTC

[cordova-lib] branch master updated: Fix tests that are failing with npm config 'save-exact' set (#678)

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 a666451  Fix tests that are failing with npm config 'save-exact' set (#678)
a666451 is described below

commit a666451565530faebfafbbd298ebf445f87b0df1
Author: Oliver Salzburg <ol...@gmail.com>
AuthorDate: Thu Sep 6 17:30:00 2018 +0200

    Fix tests that are failing with npm config 'save-exact' set (#678)
---
 integration-tests/pkgJson.spec.js | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/integration-tests/pkgJson.spec.js b/integration-tests/pkgJson.spec.js
index c92580b..099c982 100644
--- a/integration-tests/pkgJson.spec.js
+++ b/integration-tests/pkgJson.spec.js
@@ -96,6 +96,15 @@ describe('pkgJson', function () {
         };
     }
 
+    function specWithMinSatisfyingVersion (version) {
+        return {
+            asymmetricMatch: spec =>
+                !semver.intersects(spec, `<${version}`) &&
+                semver.intersects(spec, `>=${version}`),
+            jasmineToString: _ => `<specWithMinSatisfyingVersion(${version})>`
+        };
+    }
+
     function stringContaining (substring) {
         return {
             asymmetricMatch: s => typeof s === 'string' && s.includes(substring),
@@ -110,6 +119,13 @@ describe('pkgJson', function () {
             return {
                 pass, message: `expected ${version} ${expectation} ${spec}`
             };
+        }}),
+        tohaveMinSatisfyingVersion: () => ({ compare (spec, version) {
+            const pass = specWithMinSatisfyingVersion(version).asymmetricMatch(spec);
+            const expectation = (pass ? 'not ' : '') + 'to have minimal satisfying version';
+            return {
+                pass, message: `expected ${spec} ${expectation} ${version}`
+            };
         }})
     };
 
@@ -138,10 +154,10 @@ describe('pkgJson', function () {
                 .then(function () {
                     // Check that the plugin and spec add was successful to pkg.json.
                     expect(getPkgJson('cordova.plugins')[pluginId]).toBeDefined();
-                    expect(getPkgJson('dependencies')[pluginId]).toEqual('^1.1.2');
+                    expect(getPkgJson('dependencies')[pluginId]).tohaveMinSatisfyingVersion('1.1.2');
                     // Check that the plugin and spec add was successful to config.xml.
                     expect(getCfg().getPlugins()).toEqual([
-                        { name: pluginId, spec: '^1.1.2', variables: {} }
+                        { name: pluginId, spec: specWithMinSatisfyingVersion('1.1.2'), variables: {} }
                     ]);
                 }).then(function () {
                     // And now remove it with --save.
@@ -389,8 +405,8 @@ describe('pkgJson', function () {
                 // dependencies should have specific version from add.
                 expect(getPkgJson('cordova.platforms')).toEqual(['android', 'browser']);
                 expect(getPkgJson('dependencies')).toEqual({
-                    'cordova-android': '^7.0.0',
-                    'cordova-browser': '^5.0.1'
+                    'cordova-android': specWithMinSatisfyingVersion('7.0.0'),
+                    'cordova-browser': specWithMinSatisfyingVersion('5.0.1')
                 });
 
                 // Check that android and browser were added to config.xml with the correct spec.


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