cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhigg...@apache.org
Subject webworks commit: Fix unit tests
Date Mon, 11 Nov 2013 19:17:17 GMT
Updated Branches:
  refs/heads/master 0c959f058 -> fb6a59c1b


Fix unit tests


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

Branch: refs/heads/master
Commit: fb6a59c1b077998d6ef0c58960af0b3cde4681a2
Parents: 0c959f0
Author: Bryan Higgins <bhiggins@blackberry.com>
Authored: Mon Nov 11 13:19:04 2013 -0500
Committer: Bryan Higgins <bhiggins@blackberry.com>
Committed: Mon Nov 11 14:17:18 2013 -0500

----------------------------------------------------------------------
 .../bin/test/cordova/integration/create.js      |  7 +++-
 .../bin/test/cordova/unit/spec/lib/logger.js    |  9 +++--
 .../cordova/unit/spec/lib/packager-validator.js | 42 ++++++++++++++------
 .../bin/test/cordova/unit/spec/lib/session.js   | 16 ++++----
 blackberry10/scripts/test.js                    |  1 +
 5 files changed, 49 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fb6a59c1/blackberry10/bin/test/cordova/integration/create.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/integration/create.js b/blackberry10/bin/test/cordova/integration/create.js
index d9c74ad..04aa6d7 100644
--- a/blackberry10/bin/test/cordova/integration/create.js
+++ b/blackberry10/bin/test/cordova/integration/create.js
@@ -91,8 +91,13 @@ describe("create tests", function () {
     });
 
     it("Empty dir error", function () {
-        executeScript(CREATE_COMMAND, ["./"], true);
+        wrench.mkdirSyncRecursive(tempFolder);
+        executeScript(CREATE_COMMAND, [tempFolder], true);
         expect(_output).toContain("The project path must be an empty directory");
+        this.after(function () {
+            wrench.rmdirSyncRecursive(tempFolder);
+        });
+
     });
 
     it("Invalid appId error", function () {

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fb6a59c1/blackberry10/bin/test/cordova/unit/spec/lib/logger.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/unit/spec/lib/logger.js b/blackberry10/bin/test/cordova/unit/spec/lib/logger.js
index c8aadb9..e7070b8 100644
--- a/blackberry10/bin/test/cordova/unit/spec/lib/logger.js
+++ b/blackberry10/bin/test/cordova/unit/spec/lib/logger.js
@@ -21,6 +21,7 @@ describe("logger", function () {
     describe("when the log level is verbose", function () {
         beforeEach(function () {
             spyOn(console, "log");
+            spyOn(console, "error");
             logger.level('verbose');
         });
 
@@ -31,7 +32,7 @@ describe("logger", function () {
 
         it("logs error messages", function () {
             logger.error("PC LOAD LETTER");
-            expect(console.log).toHaveBeenCalledWith("[ERROR]   PC LOAD LETTER");
+            expect(console.error).toHaveBeenCalledWith("[ERROR]   PC LOAD LETTER");
         });
 
         it("logs warning messages", function () {
@@ -48,6 +49,7 @@ describe("logger", function () {
     describe("when the log level is warn", function () {
         beforeEach(function () {
             spyOn(console, "log");
+            spyOn(console, "error");
             logger.level('warn');
         });
 
@@ -58,7 +60,7 @@ describe("logger", function () {
 
         it("logs error messages", function () {
             logger.error("PC LOAD LETTER");
-            expect(console.log).toHaveBeenCalledWith("[ERROR]   PC LOAD LETTER");
+            expect(console.error).toHaveBeenCalledWith("[ERROR]   PC LOAD LETTER");
         });
 
         it("logs warning messages", function () {
@@ -75,6 +77,7 @@ describe("logger", function () {
     describe("when the log level is error", function () {
         beforeEach(function () {
             spyOn(console, "log");
+            spyOn(console, "error");
             logger.level('error');
         });
 
@@ -85,7 +88,7 @@ describe("logger", function () {
 
         it("logs error messages", function () {
             logger.error("PC LOAD LETTER");
-            expect(console.log).toHaveBeenCalledWith("[ERROR]   PC LOAD LETTER");
+            expect(console.error).toHaveBeenCalledWith("[ERROR]   PC LOAD LETTER");
         });
 
         it("doesn't log warning messages", function () {

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fb6a59c1/blackberry10/bin/test/cordova/unit/spec/lib/packager-validator.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/unit/spec/lib/packager-validator.js b/blackberry10/bin/test/cordova/unit/spec/lib/packager-validator.js
index a2c55c8..40e3b3c 100644
--- a/blackberry10/bin/test/cordova/unit/spec/lib/packager-validator.js
+++ b/blackberry10/bin/test/cordova/unit/spec/lib/packager-validator.js
@@ -25,6 +25,7 @@ var srcPath = __dirname + "/../../../../../templates/project/cordova/lib/",
     localize = require(srcPath + "localize"),
     logger = require(srcPath + "logger"),
     packagerValidator = require(srcPath + "packager-validator"),
+    signingUtils = require(srcPath + "signing-utils"),
     fs = require("fs"),
     cmd,
     extManager = {
@@ -64,32 +65,47 @@ describe("Packager Validator", function () {
         }).toThrow(localize.translate("EXCEPTION_MISSING_SIGNING_KEY_FILE", "author.p12"));
     });
 
-    it("throws an exception when -g set and barsigner.csk was not found", function () {
+    it("throws an exception when -g set and bbidtoken.csk or barsigner.csk was not found",
function () {
         var session = testUtilities.cloneObj(testData.session),
             configObj = testUtilities.cloneObj(testData.config);
 
         //setup signing parameters
-        session.keystore = "c:/author.p12";
+        session.keystore = signingUtils.getDefaultPath("author.p12");
         session.keystoreCsk = undefined;
         session.storepass = "myPassword";
 
         expect(function () {
             packagerValidator.validateSession(session, configObj);
-        }).toThrow(localize.translate("EXCEPTION_MISSING_SIGNING_KEY_FILE", "barsigner.csk"));
+        }).toThrow(localize.translate("EXCEPTION_MISSING_SIGNING_KEY_FILE", "bbidtoken.csk"));
     });
 
-    it("throws an exception when --buildId set and barsigner.csk was not found", function
() {
+    it("does not throw an exception when -g set and barsigner.csk was found", function ()
{
         var session = testUtilities.cloneObj(testData.session),
             configObj = testUtilities.cloneObj(testData.config);
 
         //setup signing parameters
-        session.keystore = "c:/author.p12";
+        session.keystore = signingUtils.getDefaultPath("author.p12");
+        session.keystoreCsk = "barsigner.csk";
+        session.keystoreDb = "barsigner.db";
+        session.storepass = "myPassword";
+
+        expect(function () {
+            packagerValidator.validateSession(session, configObj);
+        }).not.toThrow();
+    });
+
+    it("throws an exception when --buildId set and bbbidtoken.csk was not found", function
() {
+        var session = testUtilities.cloneObj(testData.session),
+            configObj = testUtilities.cloneObj(testData.config);
+
+        //setup signing parameters
+        session.keystore = signingUtils.getDefaultPath("author.p12");
         session.keystoreCsk = undefined;
         session.buildId = "100";
 
         expect(function () {
             packagerValidator.validateSession(session, configObj);
-        }).toThrow(localize.translate("EXCEPTION_MISSING_SIGNING_KEY_FILE", "barsigner.csk"));
+        }).toThrow(localize.translate("EXCEPTION_MISSING_SIGNING_KEY_FILE", "bbidtoken.csk"));
     });
 
     it("throws an exception when -g set and barsigner.db was not found", function () {
@@ -97,7 +113,7 @@ describe("Packager Validator", function () {
             configObj = testUtilities.cloneObj(testData.config);
 
         //setup signing parameters
-        session.keystore = "c:/author.p12";
+        session.keystore = signingUtils.getDefaultPath("author.p12");
         session.keystoreCsk = "c:/barsigner.csk";
         session.keystoreDb = undefined;
         session.storepass = "myPassword";
@@ -112,7 +128,7 @@ describe("Packager Validator", function () {
             configObj = testUtilities.cloneObj(testData.config);
 
         //setup signing parameters
-        session.keystore = "c:/author.p12";
+        session.keystore = signingUtils.getDefaultPath("author.p12");
         session.keystoreCsk = "c:/barsigner.csk";
         session.keystoreDb = undefined;
         session.buildId = "100";
@@ -138,7 +154,7 @@ describe("Packager Validator", function () {
         expect(logger.warn).toHaveBeenCalledWith(localize.translate("WARNING_MISSING_SIGNING_KEY_FILE",
"author.p12"));
     });
 
-    it("generated a warning when Build ID is set in config and barsigner.csk was not found",
function () {
+    it("generated a warning when Build ID is set in config and bbidtoken.csk was not found",
function () {
         var session = testUtilities.cloneObj(testData.session),
             configObj = testUtilities.cloneObj(testData.config);
 
@@ -146,13 +162,13 @@ describe("Packager Validator", function () {
         spyOn(logger, "warn");
 
         //setup signing parameters
-        session.keystore = "c:/author.p12";
+        session.keystore = signingUtils.getDefaultPath("author.p12");
         session.keystoreCsk = undefined;
         session.buildId = undefined;
         configObj.buildId = "100";
 
         packagerValidator.validateSession(session, configObj);
-        expect(logger.warn).toHaveBeenCalledWith(localize.translate("WARNING_MISSING_SIGNING_KEY_FILE",
"barsigner.csk"));
+        expect(logger.warn).toHaveBeenCalledWith(localize.translate("WARNING_MISSING_SIGNING_KEY_FILE",
"bbidtoken.csk"));
     });
 
     it("generated a warning when Build ID is set in config and barsigner.db was not found",
function () {
@@ -163,7 +179,7 @@ describe("Packager Validator", function () {
         spyOn(logger, "warn");
 
         //setup signing parameters
-        session.keystore = "c:/author.p12";
+        session.keystore = signingUtils.getDefaultPath("author.p12");
         session.keystoreCsk = "c:/barsigner.csk";
         session.keystoreDb = undefined;
         session.buildId = undefined;
@@ -192,7 +208,7 @@ describe("Packager Validator", function () {
             configObj = testUtilities.cloneObj(testData.config);
 
         //setup signing parameters
-        session.keystore = "c:/author.p12";
+        session.keystore = signingUtils.getDefaultPath("author.p12");
         session.keystoreCsk = "c:/barsigner.csk";
         session.keystoreDb = "c:/barsigner.db";
         session.storepass = undefined;

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fb6a59c1/blackberry10/bin/test/cordova/unit/spec/lib/session.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/unit/spec/lib/session.js b/blackberry10/bin/test/cordova/unit/spec/lib/session.js
index 8a18704..524b040 100644
--- a/blackberry10/bin/test/cordova/unit/spec/lib/session.js
+++ b/blackberry10/bin/test/cordova/unit/spec/lib/session.js
@@ -22,6 +22,7 @@
 var session = require(__dirname + "/../../../../../templates/project/cordova/lib/session"),
     localize = require(__dirname + "/../../../../../templates/project/cordova/lib/localize"),
     testUtils = require("./test-utilities"),
+    utils = require(__dirname + "/../../../../../templates/project/cordova/lib/utils"),
     path = require("path"),
     fs = require("fs"),
     wrench = require("wrench"),
@@ -31,6 +32,7 @@ describe("Session", function () {
     beforeEach(function () {
         //Do not create the source folder
         spyOn(wrench, "mkdirSyncRecursive");
+        spyOn(utils, "getProperties").andReturn({});
     });
 
     it("sets the source directory correctly when specified [-s C:/sampleApp/mySource]", function
() {
@@ -169,16 +171,14 @@ describe("Session", function () {
         it("get params from non-existent file should throw error", function () {
             var data = {
                     args: [ 'C:/sampleApp/sample.zip' ],
-                    params: "blah.json"
-                },
-                result;
+                    params: "blah.json",
+                    keystorepass: "test"
+                };
 
             spyOn(fs, "existsSync").andReturn(false);
 
-            result = session.initialize(data);
-
             expect(function () {
-                result.getParams("blackberry-signer");
+                session.initialize(data);
             }).toThrow(localize.translate("EXCEPTION_PARAMS_FILE_NOT_FOUND", path.resolve("blah.json")));
         });
 
@@ -192,10 +192,8 @@ describe("Session", function () {
             spyOn(path, "resolve").andReturn("test/params-bad.json");
             spyOn(fs, "existsSync").andReturn(true);
 
-            result = session.initialize(data);
-
             expect(function () {
-                result.getParams("blackberry-signer");
+                session.initialize(data);
             }).toThrow(localize.translate("EXCEPTION_PARAMS_FILE_ERROR", path.resolve("blah.json")));
         });
     });

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fb6a59c1/blackberry10/scripts/test.js
----------------------------------------------------------------------
diff --git a/blackberry10/scripts/test.js b/blackberry10/scripts/test.js
index 537652c..e501aad 100644
--- a/blackberry10/scripts/test.js
+++ b/blackberry10/scripts/test.js
@@ -25,6 +25,7 @@ module.exports = function (done, custom) {
                 "bin/test/cordova/unit"
             ];
     utils.copyFile('bin/lib/utils.js', 'bin/templates/project/cordova/lib/', '../');
+    utils.copyFile('bin/lib/signing-utils.js', 'bin/templates/project/cordova/lib/', '../');
     jasmine.executeSpecsInFolder({
         'specFolders': specs,
         'onComplete': function (runner) {


Mime
View raw message