Repository: cordova-lib
Updated Branches:
  refs/heads/master 2632de65b -> 1a834a99d


CB-12361 : updated and added unit tests for add.spec.js

 This closes #595


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/1a834a99
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/1a834a99
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/1a834a99

Branch: refs/heads/master
Commit: 1a834a99dc4880b6a52834e682c7bf3b063b26c9
Parents: 2632de6
Author: Audrey So <[email protected]>
Authored: Mon Sep 18 13:37:45 2017 -0700
Committer: Steve Gill <[email protected]>
Committed: Wed Oct 4 11:46:37 2017 -0700

----------------------------------------------------------------------
 spec/cordova/plugin/add.spec.js | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1a834a99/spec/cordova/plugin/add.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova/plugin/add.spec.js b/spec/cordova/plugin/add.spec.js
index 096ae75..2059ad2 100644
--- a/spec/cordova/plugin/add.spec.js
+++ b/spec/cordova/plugin/add.spec.js
@@ -474,16 +474,17 @@ describe('cordova/plugin/add', function () {
                 pluginInfo.engines = {};
                 pluginInfo.engines.cordovaDependencies = {'^1.0.0': 
{'cordova': '<7.0.0'}};
                 expect(add.determinePluginVersionToFetch(pluginInfo, {}, {}, 
'7.0.0')).toBe(null);
+                expect(events.emit).toHaveBeenCalledWith('verbose', 
jasmine.stringMatching(/Ignoring invalid version/));
                 done();
             });
-
-            xit('', function (done) {
+            it('should return null and fetching latest version of plugin', 
function (done) {
+                add.getFailedRequirements.and.returnValue(['2.0.0']);
                 pluginInfo.engines = {};
                 pluginInfo.engines.cordovaDependencies = {'1.0.0': {'cordova': 
'<7.0.0'}, '<3.0.0': {'cordova': '>=7.0.0'}};
                 expect(add.determinePluginVersionToFetch(pluginInfo, {}, {}, 
'7.0.0')).toBe(null);
+                expect(events.emit).toHaveBeenCalledWith('warn', 
jasmine.stringMatching(/Current project does not satisfy/));
                 done();
             });
-
             it('should return highest version of plugin available based on 
constraints', function (done) {
                 pluginInfo.engines = {};
                 pluginInfo.engines.cordovaDependencies = {'1.0.0': {'cordova': 
'<7.0.0'}, '<3.0.0': {'cordova': '>=7.0.0'}};
@@ -492,6 +493,14 @@ describe('cordova/plugin/add', function () {
             });
         });
         describe('getFailedRequirements helper method', function () {
+            it('should remove prerelease version', function (done) {
+                var semver = require('semver');
+                spyOn(semver, 'prerelease').and.returnValue('7.0.1');
+                spyOn(semver, 'inc').and.callThrough();
+                expect(add.getFailedRequirements({'cordova': '>=7.0.0'}, {}, 
{}, '7.0.0').length).toBe(0);
+                expect(semver.inc).toHaveBeenCalledWith('7.0.0', 'patch');
+                done();
+            });
             it('should return an empty array if no failed requirements', 
function (done) {
                 expect(add.getFailedRequirements({'cordova': '>=7.0.0'}, {}, 
{}, '7.0.0').length).toBe(0);
                 done();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to