You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by lo...@apache.org on 2013/05/14 06:15:18 UTC
[11/50] [abbrv] webworks commit: create integration tests
create integration tests
Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>
Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/34ff4f18
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/34ff4f18
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/34ff4f18
Branch: refs/heads/master
Commit: 34ff4f18c86a8c3700199f65dd5a63c6d81d38a6
Parents: b4ee225
Author: Hasan Ahmad <ha...@blackberry.com>
Authored: Fri Mar 22 11:30:55 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:29 2013 -0400
----------------------------------------------------------------------
blackberry10/bin/create.js | 4 +-
.../bin/test/cordova/integration/create.js | 158 +++++++++++++++
.../bin/test/cordova/integration/target.js | 3 -
3 files changed, 160 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/34ff4f18/blackberry10/bin/create.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/create.js b/blackberry10/bin/create.js
index 7a0950b..9b99435 100644
--- a/blackberry10/bin/create.js
+++ b/blackberry10/bin/create.js
@@ -141,7 +141,6 @@ var build,
process.exit(1);
}
else {
- console.log("Project creation complete!");
process.exit();
}
}
@@ -156,7 +155,8 @@ var build,
.andThen(clean)
.andThen(copyJavascript)
.andThen(copyFilesToProject)
- .andThen(updateProject);
+ .andThen(updateProject)
+ .andThen(clean);
build.start(function (error) {
done(error);
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/34ff4f18/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
new file mode 100644
index 0000000..d193580
--- /dev/null
+++ b/blackberry10/bin/test/cordova/integration/create.js
@@ -0,0 +1,158 @@
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+var childProcess = require('child_process'),
+ tempFolder = '.tmp/',
+ appFolder = tempFolder + 'tempCordovaApp/',
+ projectFile = 'project.json',
+ wrench = require('wrench'),
+ fs = require('fs'),
+ flag = false,
+ _stdout = "",
+ _stderr = "";
+
+function executeScript(shellCommand) {
+ childProcess.exec(shellCommand, function (error, stdout, stderr) {
+ if (error) {
+ console.log("Error executing command: " + error);
+ }
+ _stdout = stdout.toString().trim();
+ _stderr = stderr.toString().trim();
+ flag = true;
+ });
+}
+
+describe("create tests", function () {
+ it("creates project", function () {
+ var project,
+ appIdRegExp = /id="default\.app\.id"/g;
+ executeScript("bin/create " + appFolder);
+ waitsFor(function () {
+ return flag;
+ });
+ runs(function () {
+ flag = false;
+ project = JSON.parse(fs.readFileSync(appFolder + projectFile, "utf-8"));
+ expect(appIdRegExp.test(fs.readFileSync(appFolder + "www/config.xml", "utf-8"))).toEqual(true);
+ expect(fs.existsSync(appFolder)).toEqual(true);
+ expect(fs.existsSync(appFolder + "/plugins")).toEqual(true);
+ expect(fs.existsSync(appFolder + "/cordova")).toEqual(true);
+ expect(fs.existsSync(appFolder + "/cordova/node_modules")).toEqual(true);
+ expect(fs.existsSync(appFolder + "/cordova/lib")).toEqual(true);
+ expect(fs.existsSync(appFolder + "/cordova/third_party")).toEqual(true);
+ expect(fs.existsSync(appFolder + "/www")).toEqual(true);
+ expect(project.barName).toEqual("cordova-BB10-app");
+ expect(project.keystorepass).toEqual("password");
+ expect(project.defaultTarget).toEqual("");
+ expect(project.targets).toEqual({});
+ expect(fs.existsSync("./build")).toEqual(false);
+ expect(_stdout).toEqual("");
+ expect(_stderr).toEqual("");
+ });
+ this.after(function () {
+ wrench.rmdirSyncRecursive(tempFolder);
+ });
+ });
+
+ it("sets appId", function () {
+ var configEt,
+ appIdRegExp = /id="com\.example\.bb10app"/g;
+ executeScript("bin/create " + appFolder + " com.example.bb10app");
+ waitsFor(function () {
+ return flag;
+ });
+ runs(function () {
+ flag = false;
+ expect(appIdRegExp.test(fs.readFileSync(appFolder + "www/config.xml", "utf-8"))).toEqual(true);
+ expect(_stdout).toEqual("");
+ expect(_stderr).toEqual("");
+ });
+ this.after(function () {
+ wrench.rmdirSyncRecursive(tempFolder);
+ });
+ });
+
+ it("sets appId and barName", function () {
+ var project,
+ appIdRegExp = /id="com\.example\.bb10app"/g;
+ executeScript("bin/create " + appFolder + " com.example.bb10app bb10appV1");
+ waitsFor(function () {
+ return flag;
+ });
+ runs(function () {
+ flag = false;
+ project = JSON.parse(fs.readFileSync(appFolder + projectFile, "utf-8"));
+ expect(appIdRegExp.test(fs.readFileSync(appFolder + "www/config.xml", "utf-8"))).toEqual(true);
+ expect(project.barName).toEqual("bb10appV1");
+ expect(_stdout).toEqual("");
+ expect(_stderr).toEqual("");
+ });
+ this.after(function () {
+ wrench.rmdirSyncRecursive(tempFolder);
+ });
+ });
+
+ it("No args", function () {
+ executeScript("bin/create");
+ waitsFor(function () {
+ return flag;
+ });
+ runs(function () {
+ flag = false;
+ expect(_stdout).toEqual("You must give a project PATH");
+ expect(_stderr).toEqual("");
+ });
+ });
+
+ it("Empty dir error", function () {
+ executeScript("bin/create ./");
+ waitsFor(function () {
+ return flag;
+ });
+ runs(function () {
+ flag = false;
+ expect(_stdout).toEqual("The project path must be an empty directory");
+ expect(_stderr).toEqual("");
+ });
+ });
+
+ it("Invalid appId error", function () {
+ executeScript("bin/create " + appFolder + " 23.21#$");
+ waitsFor(function () {
+ return flag;
+ });
+ runs(function () {
+ flag = false;
+ expect(_stdout).toEqual("App ID must be sequence of alpha-numeric (optionally seperated by '.') characters, no longer than 50 characters");
+ expect(_stderr).toEqual("");
+ });
+ });
+
+ it("Invalid barName error", function () {
+ executeScript("bin/create " + appFolder + " com.example.app %bad@bar^name");
+ waitsFor(function () {
+ return flag;
+ });
+ runs(function () {
+ flag = false;
+ expect(_stdout).toEqual("BAR filename can only contain alpha-numeric, '.', '-' and '_' characters");
+ expect(_stderr).toEqual("");
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/34ff4f18/blackberry10/bin/test/cordova/integration/target.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/integration/target.js b/blackberry10/bin/test/cordova/integration/target.js
index 62eab37..e948a87 100644
--- a/blackberry10/bin/test/cordova/integration/target.js
+++ b/blackberry10/bin/test/cordova/integration/target.js
@@ -46,9 +46,6 @@ describe("cordova/target tests", function () {
});
runs(function () {
flag = false;
- expect(fs.existsSync(appFolder)).toEqual(true);
- expect(_stdout).toEqual("Project creation complete!");
- expect(_stderr).toEqual("");
});
});