You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2014/11/01 00:43:23 UTC
[03/50] ios commit: Created jasmine tests, removed old tests.
Created jasmine tests, removed old tests.
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/8d03b08c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/8d03b08c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/8d03b08c
Branch: refs/heads/wkwebview
Commit: 8d03b08c9677b8e59502514187c3544bfb9fc20a
Parents: cad22c3
Author: Shazron Abdullah <sh...@apache.org>
Authored: Fri Oct 10 15:51:25 2014 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Fri Oct 10 15:51:25 2014 -0700
----------------------------------------------------------------------
package.json | 5 +-
tests/README.md | 19 -------
tests/package.json | 14 -----
tests/spec/cordovalib.spec.js | 50 +++++++++++++++++
tests/spec/create.spec.js | 106 +++++++++++++++++++++++++++++++++++++
5 files changed, 160 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8d03b08c/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index f2a2345..bcd6ddd 100644
--- a/package.json
+++ b/package.json
@@ -13,11 +13,14 @@
"apache"
],
"scripts" : {
- "test" : "cd tests && npm test"
+ "test" : "npm run jasmine",
+ "jasmine" : "jasmine-node --captureExceptions --color tests/spec"
+
},
"author": "Apache Software Foundation",
"license": "Apache Version 2.0",
"dependencies": {
+ "jasmine-node": "~1",
"shelljs": "^0.2.6",
"coffee-script": "^1.7.1",
"nodeunit": "^0.8.7"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8d03b08c/tests/README.md
----------------------------------------------------------------------
diff --git a/tests/README.md b/tests/README.md
deleted file mode 100644
index 18018d2..0000000
--- a/tests/README.md
+++ /dev/null
@@ -1,19 +0,0 @@
-# Tests for cordova-ios
-
-You need to install `node.js` to run npm test
-
-
-# Testing from Xcode
-
-1. Launch the `cordova-ios.xcworkspace` file.
-2. Choose "CordovaLibTests" from the scheme drop-down menu
-3. Click and hold on the `Play` button, and choose the `Wrench` icon to run the tests
-
-
-# Testing from the command line
-
- npm test
-
-OR
-
- killall 'iOS Simulator' && xcodebuild test -scheme CordovaLibTests -destination 'platform=iOS Simulator,name=iPhone 5'
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8d03b08c/tests/package.json
----------------------------------------------------------------------
diff --git a/tests/package.json b/tests/package.json
deleted file mode 100644
index e84b485..0000000
--- a/tests/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "name": "cordova-ios-tests",
- "version": "1.0.0",
- "description": "Tests for cordova-ios",
- "author": "Apache Software Foundation",
- "license": "Apache Version 2.0",
- "dependencies": {
- },
- "scripts": {
- "test": "npm run cordovalib-test && npm run create-project-unicode-space-in-path",
- "cordovalib-test" : "killall 'iOS Simulator' && xcodebuild test -scheme CordovaLibTests -destination 'platform=iOS Simulator,name=iPhone 5'",
- "create-project-unicode-space-in-path" : "rm -rf \"testcreate 応用\"; ../bin/create \"testcreate 応用\" com.test.app 応用 && \"./testcreate 応用/cordova/build\" && rm -rf \"testcreate 応用\""
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8d03b08c/tests/spec/cordovalib.spec.js
----------------------------------------------------------------------
diff --git a/tests/spec/cordovalib.spec.js b/tests/spec/cordovalib.spec.js
new file mode 100644
index 0000000..f1236ff
--- /dev/null
+++ b/tests/spec/cordovalib.spec.js
@@ -0,0 +1,50 @@
+/*
+ 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 shell = require('shelljs'),
+ spec = __dirname,
+ path = require('path'),
+ util = require('util');
+
+ var tests_dir = path.join(spec, '..');
+
+describe('cordova-lib', function() {
+
+ it('objective-c unit tests', function() {
+ var return_code = 0;
+ var command;
+
+ // check iOS Simulator if running
+ command = 'pgrep "iOS Simulator"';
+ return_code = shell.exec(command).code;
+
+ // if iOS Simulator is running, kill it
+ if (return_code == 0) { // found
+ shell.echo('iOS Simulator is running, we\'re going to kill it.');
+ return_code = shell.exec('killall "iOS Simulator"').code;
+ expect(return_code).toBe(0);
+ }
+
+ // run the tests
+ command = util.format('xcodebuild test -workspace %s/cordova-ios.xcworkspace -scheme CordovaLibTests -destination "platform=iOS Simulator,name=iPhone 5"', tests_dir);
+ shell.echo(command);
+ return_code = shell.exec(command).code;
+ expect(return_code).toBe(0);
+ });
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8d03b08c/tests/spec/create.spec.js
----------------------------------------------------------------------
diff --git a/tests/spec/create.spec.js b/tests/spec/create.spec.js
new file mode 100644
index 0000000..e25440a
--- /dev/null
+++ b/tests/spec/create.spec.js
@@ -0,0 +1,106 @@
+/*
+ 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 shell = require('shelljs'),
+ spec = __dirname,
+ path = require('path'),
+ util = require('util');
+
+ var cordova_bin = path.join(spec, '../..', 'bin');
+ var tmp = path.join(spec, '..', 'tmp');
+
+function createAndBuild(projectname, projectid) {
+ var return_code = 0;
+ var command;
+
+ // create tmp folder if necessary
+ shell.mkdir('-p', tmp);
+
+ // remove existing folder
+ command = path.join(tmp, projectname);
+ shell.rm('-rf', command);
+
+ // create the project
+ command = util.format('"%s/create" "%s/%s" %s "%s"', cordova_bin, tmp, projectname, projectid, projectname);
+ shell.echo(command);
+ return_code = shell.exec(command).code;
+ expect(return_code).toBe(0);
+
+ // build the project
+ command = util.format('"%s/cordova/build"', path.join(tmp, projectname));
+ shell.echo(command);
+ return_code = shell.exec(command).code;
+ expect(return_code).toBe(0);
+
+ // clean-up
+ command = path.join(tmp, projectname);
+ shell.rm('-rf', command);
+}
+
+
+describe('create', function() {
+
+ it('create project with ascii name, no spaces', function() {
+ var projectname = 'testcreate';
+ var projectid = 'com.test.app1';
+
+ createAndBuild(projectname, projectid);
+ });
+
+ it('create project with ascii name, and spaces', function() {
+ var projectname = 'test create';
+ var projectid = 'com.test.app2';
+
+ createAndBuild(projectname, projectid);
+ });
+
+ it('create project with unicode name, no spaces', function() {
+ var projectname = '応応応応用用用用';
+ var projectid = 'com.test.app3';
+
+ createAndBuild(projectname, projectid);
+ });
+
+ it('create project with unicode name, and spaces', function() {
+ var projectname = '応応応応 用用用用';
+ var projectid = 'com.test.app4';
+
+ createAndBuild(projectname, projectid);
+ });
+
+ it('create project with ascii+unicode name, no spaces', function() {
+ var projectname = '応応応応hello用用用用';
+ var projectid = 'com.test.app5';
+
+ createAndBuild(projectname, projectid);
+ });
+
+ it('create project with ascii+unicode name, and spaces', function() {
+ var projectname = '応応応応 hello 用用用用';
+ var projectid = 'com.test.app6';
+
+ createAndBuild(projectname, projectid);
+ });
+
+ // clean-up last
+ it('cleanup tmp folder', function() {
+ shell.rm('-rf', tmp);
+ });
+
+});
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org