You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2017/05/25 20:38:22 UTC

[02/25] cordova-browser git commit: added some basic tests, and updated package with Jasmine@2.5.3

added some basic tests, and updated package with Jasmine@2.5.3


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

Branch: refs/heads/master
Commit: 44578d2f9399dd614b270ce98ce00ed7db4d137c
Parents: f1b136d
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri Apr 7 14:59:52 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri Apr 7 14:59:52 2017 -0700

----------------------------------------------------------------------
 package.json              | 101 +++++++++++++++++-----------------
 spec/create.spec.js       | 119 +++++++++++++++++++++++++++++++++++++++++
 spec/projectApi.spec.js   | 116 +++++++++++++++++++++++++++++++++++++++
 spec/support/jasmine.json |  10 ++++
 4 files changed, 298 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/44578d2f/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 3daf7d4..8a2b4ed 100644
--- a/package.json
+++ b/package.json
@@ -1,51 +1,56 @@
 {
-    "name": "cordova-browser",
-    "version": "4.2.0-dev",
-    "description": "cordova-browser release",
-    "main": "bin/create",
-    "repository": {
-        "type": "git",
-        "url": "https://git-wip-us.apache.org/repos/asf/cordova-browser.git"
+  "name": "cordova-browser",
+  "version": "4.2.0-dev",
+  "description": "cordova-browser release",
+  "main": "bin/create",
+  "repository": {
+    "type": "git",
+    "url": "https://git-wip-us.apache.org/repos/asf/cordova-browser.git"
+  },
+  "keywords": [
+    "cordova",
+    "browser",
+    "apache"
+  ],
+  "scripts": {
+    "jshint": "jshint bin && jshint spec",
+    "jasmine": "jasmine --captureExceptions --color",
+    "test": "npm run jshint && npm run jasmine"
+  },
+  "dependencies": {
+    "adm-zip": "^0.4.7",
+    "cordova-common": "^2.0.1",
+    "cordova-serve": "^1.0.0",
+    "nopt": "^3.0.6",
+    "q": "^1.4.1",
+    "shelljs": "^0.6.0"
+  },
+  "devDependencies": {
+    "jasmine": "^2.5.3",
+    "jshint": "^2.6.0",
+    "tmp": "^0.0.26"
+  },
+  "bundledDependencies": [
+    "adm-zip",
+    "cordova-serve",
+    "nopt",
+    "q",
+    "shelljs"
+  ],
+  "author": "Apache Software Foundation",
+  "contributors": [
+    {
+      "name": "Steve Gill",
+      "email": "steveng@adobe.com"
     },
-    "keywords": [
-        "cordova",
-        "browser",
-        "apache"
-    ],
-    "scripts": {
-        "test": "npm run jshint && npm run test-unit",
-        "test-unit": "node node_modules/jasmine-node/lib/jasmine-node/cli.js --captureExceptions tests/spec/",
-        "jshint": "node node_modules/jshint/bin/jshint bin && node node_modules/jshint/bin/jshint tests"
+    {
+      "name": "Suraj Pindoria",
+      "email": "spindori@adobe.com"
     },
-    "dependencies": {
-        "adm-zip": "^0.4.7",
-        "cordova-serve": "^1.0.0",
-        "nopt": "^3.0.6",
-        "q": "^1.4.1",
-        "shelljs": "^0.6.0"
-    },
-    "devDependencies": {
-        "jasmine-node": "~1",
-        "jshint": "^2.6.0",
-        "tmp": "^0.0.26"
-    },
-    "bundledDependencies": [
-        "adm-zip",
-        "cordova-serve",
-        "nopt",
-        "q",
-        "shelljs"
-    ],
-    "author": "Apache Software Foundation",
-    "contributors": [
-        {
-            "name": "Steve Gill",
-            "email": "steveng@adobe.com"
-        },
-        {
-            "name": "Suraj Pindoria",
-            "email": "spindori@adobe.com"
-        }
-    ],
-    "license": "Apache-2.0"
-}
\ No newline at end of file
+    {
+      "name": "Jesse MacFadyen",
+      "email": "purplecabbage@apache.org"
+    }
+  ],
+  "license": "Apache-2.0"
+}

http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/44578d2f/spec/create.spec.js
----------------------------------------------------------------------
diff --git a/spec/create.spec.js b/spec/create.spec.js
new file mode 100644
index 0000000..b920417
--- /dev/null
+++ b/spec/create.spec.js
@@ -0,0 +1,119 @@
+/*
+ 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');
+var fs = require('fs');
+var path = require('path');
+var util = require('util');
+
+var cordova_bin = path.join(__dirname, '../bin');// is this the same on all platforms?
+var tmpDir = path.join(__dirname, '../temp');
+var createScriptPath = path.join(cordova_bin,'create');
+
+function createAndBuild(projectname, projectid) {
+
+    var return_code = 0;
+    var command;
+
+    // remove existing folder
+    shell.rm('-rf', tmpDir);
+    shell.mkdir(tmpDir);
+
+    // create the project
+    command = util.format('"%s" "%s/%s" "%s" "%s"', createScriptPath, tmpDir, projectname, projectid, projectname);
+    //shell.echo(command);
+    return_code = shell.exec(command).code;
+    expect(return_code).toBe(0);
+
+
+    var tempCordovaScriptsPath = path.join(tmpDir,projectname,"cordova");
+
+    console.log("tempCordovaScriptsPath = " + tempCordovaScriptsPath);
+
+    // created project has scripts in the cordova folder
+    // build, clean, log, run, version
+    expect(fs.existsSync(path.join(tempCordovaScriptsPath,'build'))).toBe(true);
+    expect(fs.existsSync(path.join(tempCordovaScriptsPath,'clean'))).toBe(true);
+    expect(fs.existsSync(path.join(tempCordovaScriptsPath,'log'))).toBe(true);
+    expect(fs.existsSync(path.join(tempCordovaScriptsPath,'run'))).toBe(true);
+    expect(fs.existsSync(path.join(tempCordovaScriptsPath,'version'))).toBe(true);
+
+
+    // // build the project
+    command = util.format('"%s/cordova/build"', path.join(tmpDir, projectname));
+    //shell.echo(command);
+    return_code = shell.exec(command, { silent: true }).code;
+    expect(return_code).toBe(0);
+
+    // clean-up
+    shell.rm('-rf', tmpDir);
+}
+
+
+describe('create', function() {
+
+    it('has a create script in bin/cordova',function(){
+        expect(fs.existsSync(createScriptPath)).toBe(true);
+    });
+
+
+    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);
+    });
+
+});
+

http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/44578d2f/spec/projectApi.spec.js
----------------------------------------------------------------------
diff --git a/spec/projectApi.spec.js b/spec/projectApi.spec.js
new file mode 100644
index 0000000..d71a961
--- /dev/null
+++ b/spec/projectApi.spec.js
@@ -0,0 +1,116 @@
+/*
+ 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 Api = require("../bin/template/cordova/Api");
+
+describe('can get the Api', function() {
+
+    it('should be defined', function() {
+        expect(Api).toBeDefined();
+    });
+
+    it('should export static createPlatform function', function(done) {
+        expect(Api.createPlatform).toBeDefined();
+        expect(typeof Api.createPlatform).toBe('function');
+
+// TODO: make this do something real
+        var promise = Api.createPlatform("../tmp");
+        expect(promise).toBeDefined();
+        expect(promise.then).toBeDefined();
+        promise.then(function(res) {
+            console.log('result = ' + res);
+            console.log("spec-success");
+            done();
+        },
+        function(err) {
+            console.log("spec-error " + err);
+            done();
+        });
+    });
+
+    it('should export static updatePlatform function', function() {
+        expect(Api.updatePlatform).toBeDefined();
+        expect(typeof Api.updatePlatform).toBe('function');
+    });
+
+});
+
+describe('project level Api',function() {
+
+    var testApi = new Api();
+
+    it('can be created', function() {
+        expect(testApi).toBeDefined();
+    });
+
+    it('has a requirements method', function() {
+        expect(testApi.requirements).toBeDefined();
+        expect(typeof testApi.requirements).toBe('function');
+    });
+
+    it('has a clean method', function() {
+        expect(testApi.clean).toBeDefined();
+        expect(typeof testApi.clean).toBe('function');
+    });
+
+    it('has a run method', function() {
+        expect(testApi.run).toBeDefined();
+        expect(typeof testApi.run).toBe('function');
+    });
+
+    it('has a build method', function() {
+        expect(testApi.build).toBeDefined();
+        expect(typeof testApi.build).toBe('function');
+    });
+
+    it('has a removePlugin method', function() {
+        expect(testApi.removePlugin).toBeDefined();
+        expect(typeof testApi.removePlugin).toBe('function');
+    });
+
+    it('has a addPlugin method', function() {
+        expect(testApi.addPlugin).toBeDefined();
+        expect(typeof testApi.addPlugin).toBe('function');
+    });
+
+    it('has a prepare method', function() {
+        expect(testApi.prepare).toBeDefined();
+        expect(typeof testApi.prepare).toBe('function');
+    });
+
+    it('has a getPlatformInfo method', function() {
+        expect(testApi.getPlatformInfo).toBeDefined();
+        expect(typeof testApi.getPlatformInfo).toBe('function');
+    });
+
+});
+
+// Static methods
+// Static method: createPlatform
+    // returns promise fulfilled with Api
+    // emits error using provided emmitter on error
+
+// Static method: updatePlatform
+    // returns a promise fulfilled with an Api
+    // emits error using provided emmitter on error
+    //
+
+// Instance methods
+    // requirements, clean, run, build, removePlugin, addPlugin, prepare, getPlatformInfo
+

http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/44578d2f/spec/support/jasmine.json
----------------------------------------------------------------------
diff --git a/spec/support/jasmine.json b/spec/support/jasmine.json
new file mode 100644
index 0000000..7122dfd
--- /dev/null
+++ b/spec/support/jasmine.json
@@ -0,0 +1,10 @@
+{
+    "spec_dir": "spec",
+    "spec_files": [
+    	"*[sS]pec.js"
+    ],
+    "helpers": [
+    ],
+    "stopSpecOnExpectationFailure": false,
+    "random": false
+}
\ 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