cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [1/7] cordova-cli git commit: CB-11982 : added jasmine tests to test config get, set and delete
Date Thu, 20 Apr 2017 00:21:21 GMT
Repository: cordova-cli
Updated Branches:
  refs/heads/master 72440d140 -> 627c98727


CB-11982 : added jasmine tests to test config get, set and delete


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/8956c759
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/8956c759
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/8956c759

Branch: refs/heads/master
Commit: 8956c75931f742a773c1e78d49c7dac85fdb6747
Parents: dba7c9a
Author: Audrey So <audreyso@apache.org>
Authored: Wed Feb 1 16:00:56 2017 -0800
Committer: Steve Gill <stevengill97@gmail.com>
Committed: Wed Apr 19 14:32:51 2017 -0700

----------------------------------------------------------------------
 spec/cli.spec.js | 153 ++++++++++++++++++++++++++++++++++----------------
 src/cli.js       |   3 +-
 2 files changed, 107 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/8956c759/spec/cli.spec.js
----------------------------------------------------------------------
diff --git a/spec/cli.spec.js b/spec/cli.spec.js
index f79de5f..849f086 100644
--- a/spec/cli.spec.js
+++ b/spec/cli.spec.js
@@ -400,60 +400,117 @@ describe("cordova cli", function () {
     });
 });
 
-    describe("platform", function () {
-        beforeEach(function () {
-            spyOn(cordova.raw, "platform").and.returnValue(Q());
+describe("platform", function () {
+    beforeEach(function () {
+        spyOn(cordova.raw, "platform").and.returnValue(Q());
+    });
+
+    it("Test #030 : autosave is the default setting for platform add", function (done) {
+        cli(["node", "cordova", "platform", "add", "ios"], function () {
+            expect(cordova.raw.platform).toHaveBeenCalledWith(
+                "add",
+                ["ios"],
+                jasmine.any(Object)
+            );
+            var opts = cordova.raw.platform.calls.argsFor(0)[2];
+            expect(opts.save).toBe(true);
+            done();
         });
+    });
 
-        it("Test #030 : autosave is the default setting for platform add", function (done)
{
-            cli(["node", "cordova", "platform", "add", "ios"], function () {
-                expect(cordova.raw.platform).toHaveBeenCalledWith(
-                    "add",
-                    ["ios"],
-                    jasmine.any(Object)
-                );
-                var opts = cordova.raw.platform.calls.argsFor(0)[2];
-                expect(opts.save).toBe(true);
-                done();
-            });
+    it("Test #031 : platform is not saved when --nosave is passed in", function (done) {
+        cli(["node", "cordova", "platform", "add", "ios", "--nosave"], function () {
+            expect(cordova.raw.platform).toHaveBeenCalledWith(
+                "add",
+                ["ios"],
+                jasmine.any(Object)
+            );
+            var opts = cordova.raw.platform.calls.argsFor(0)[2];
+            expect(opts.save).toBe(false);
+            done();
         });
+    });
 
-        it("Test #031 : platform is not saved when --nosave is passed in", function (done)
{
-            cli(["node", "cordova", "platform", "add", "ios", "--nosave"], function () {
-                expect(cordova.raw.platform).toHaveBeenCalledWith(
-                    "add",
-                    ["ios"],
-                    jasmine.any(Object)
-                );
-                var opts = cordova.raw.platform.calls.argsFor(0)[2];
-                expect(opts.save).toBe(false);
-                done();
-            });
+    it("Test #032 : autosave is the default setting for platform remove", function (done)
{
+        cli(["node", "cordova", "platform", "remove", "ios"], function () {
+            expect(cordova.raw.platform).toHaveBeenCalledWith(
+                "remove",
+                ["ios"],
+                jasmine.any(Object)
+            );
+            var opts = cordova.raw.platform.calls.argsFor(0)[2];
+            expect(opts.save).toBe(true);
+            done();
         });
+    });
 
-        it("Test #032 : autosave is the default setting for platform remove", function (done)
{
-            cli(["node", "cordova", "platform", "remove", "ios"], function () {
-                expect(cordova.raw.platform).toHaveBeenCalledWith(
-                    "remove",
-                    ["ios"],
-                    jasmine.any(Object)
-                );
-                var opts = cordova.raw.platform.calls.argsFor(0)[2];
-                expect(opts.save).toBe(true);
-                done();
-            });
+    it("Test #033 : platform is not removed when --nosave is passed in", function (done)
{
+        cli(["node", "cordova", "platform", "remove", "ios", "--nosave"], function () {
+            expect(cordova.raw.platform).toHaveBeenCalledWith(
+                "remove",
+                ["ios"],
+                jasmine.any(Object)
+            );
+            var opts = cordova.raw.platform.calls.argsFor(0)[2];
+            expect(opts.save).toBe(false);
+            done();
         });
+    });
+});
 
-        it("Test #033 : platform is not removed when --nosave is passed in", function (done)
{
-            cli(["node", "cordova", "platform", "remove", "ios", "--nosave"], function ()
{
-                expect(cordova.raw.platform).toHaveBeenCalledWith(
-                    "remove",
-                    ["ios"],
-                    jasmine.any(Object)
-                );
-                var opts = cordova.raw.platform.calls.argsFor(0)[2];
-                expect(opts.save).toBe(false);
-                done();
-            });
+describe("config", function () {
+    beforeEach(function () {
+        spyOn(cordova.raw, "config").and.returnValue(Q());
+    });
+
+    it("Test#040 : config set is called with true and config delete is called", function
(done) {
+        cli(["node", "cordova", "config", "set", "autosave", "true"], function () {
+            expect(cordova.raw.config).toHaveBeenCalledWith(
+                'set', 
+                [ 'autosave', 'true' ],
+                jasmine.any(Object)
+            );
+            done();
         });
-    }); 
\ No newline at end of file
+        cordova.raw.config('delete', 'autosave')
+        .then(function () {
+            expect(cordova.raw.config).toHaveBeenCalledWith(
+                 'delete', 'autosave'
+            );
+            done();
+        });
+    });
+
+    it("Test#041 : config set is called with false", function (done) {
+        cli(["node", "cordova", "config", "set", "autosave", "false"], function () {
+            expect(cordova.raw.config).toHaveBeenCalledWith(
+                'set', 
+                [ 'autosave', 'false' ],
+                jasmine.any(Object)
+            );
+            done();
+        });
+    });
+
+    it("Test#042 : config set is called even without true or false", function (done) {
+        cli(["node", "cordova", "config", "set", "autosave"], function () {
+            expect(cordova.raw.config).toHaveBeenCalledWith(
+                'set', 
+                [ 'autosave' ],
+                jasmine.any(Object)
+            );
+            done();
+        });
+    });
+
+    it("Test #043 : config get is called", function (done) {
+        cli(["node", "cordova", "config", "get", "autosave"], function () {
+            expect(cordova.raw.config).toHaveBeenCalledWith(
+                'get', 
+                [ 'autosave' ],
+                jasmine.any(Object)
+            );
+            done();
+        });
+    });
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/8956c759/src/cli.js
----------------------------------------------------------------------
diff --git a/src/cli.js b/src/cli.js
index f49aa7b..c33c5da 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -129,10 +129,11 @@ module.exports = function (inputArgs, cb) {
     if (isConfigCmd && inputArgs[3] === 'get') {
         conf.get(inputArgs[4]);
     }
+
     // If set is called
     if (isConfigCmd && inputArgs[3] === 'set') {
         if (inputArgs[5] === undefined) {
-            conf.set(inputArgs[4], null);
+            conf.set(inputArgs[4], true);
         }
 
         if(inputArgs[5]) {


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


Mime
View raw message