You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by om...@apache.org on 2016/05/22 17:32:47 UTC

[2/2] cordova-cli git commit: CB-11284: Unit Test

CB-11284: Unit Test

 This closes #253


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

Branch: refs/heads/master
Commit: 6e87c71a1c2cbea285b1a3ec5a123cba58351f47
Parents: 10b08ae
Author: Omar Mefire <om...@gmail.com>
Authored: Fri May 20 09:53:26 2016 -0700
Committer: Omar Mefire <om...@gmail.com>
Committed: Sun May 22 10:30:37 2016 -0700

----------------------------------------------------------------------
 spec/cli.spec.js | 14 ++++++++++++++
 src/cli.js       |  3 +--
 src/telemetry.js |  3 ++-
 3 files changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6e87c71a/spec/cli.spec.js
----------------------------------------------------------------------
diff --git a/spec/cli.spec.js b/spec/cli.spec.js
index 937c20b..50240e7 100644
--- a/spec/cli.spec.js
+++ b/spec/cli.spec.js
@@ -231,6 +231,20 @@ describe("cordova cli", function () {
            });
        });
        
+       it("tracks platforms/plugins subcommands", function(done) {
+           spyOn(telemetry, "isOptedIn").andReturn(true);
+           spyOn(telemetry, "isCI").andReturn(false);
+           spyOn(telemetry, "hasUserOptedInOrOut").andReturn(true);
+           spyOn(cordova.raw, "platform").andReturn(Q());
+           
+           spyOn(telemetry, "track");
+           
+           cli(["node", "cordova", "platform", "add", "ios"], function () {
+               expect(telemetry.track).toHaveBeenCalledWith("platform", "add", "successful");
+               done();
+           });
+       });
+       
        it("shows prompt if user neither opted in or out yet", function(done) {
            spyOn(cordova.raw, "prepare").andReturn(Q());
            spyOn(telemetry, "hasUserOptedInOrOut").andReturn(false);

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6e87c71a/src/cli.js
----------------------------------------------------------------------
diff --git a/src/cli.js b/src/cli.js
index 233691f..8fda3d9 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -161,7 +161,7 @@ function getSubCommand(args, cmd) {
     if(cmd === 'platform' || cmd === 'platforms' || cmd === 'plugin' || cmd === 'plugins' || cmd === 'telemetry') {
         return args[3]; // e.g: args='node cordova platform rm ios', 'node cordova telemetry on'
     }
-    return "";
+    return null;
 }
 
 function handleTelemetryCmd(subcommand, isOptedIn) {
@@ -287,7 +287,6 @@ function cli(inputArgs) {
         }
     }
 
-    // TODO: Example wanted, is this functionality ever used?
     // If there were arguments protected from nopt with a double dash, keep
     // them in unparsedArgs. For example:
     // cordova build ios -- --verbose --whatever

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6e87c71a/src/telemetry.js
----------------------------------------------------------------------
diff --git a/src/telemetry.js b/src/telemetry.js
index e08e6a0..eea939e 100644
--- a/src/telemetry.js
+++ b/src/telemetry.js
@@ -67,7 +67,8 @@ function showPrompt() {
 function track() {
     // Remove empty, null or undefined strings from arguments
     for (var property in arguments) {
-        var val = arguments[property]; if (!val || val.length === 0) {
+        var val = arguments[property]; 
+        if (!val || val.length === 0) {
             delete arguments.property;
         }
     }


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