You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ra...@apache.org on 2019/10/30 15:04:41 UTC
[cordova-browser] branch master updated: Replace test stub for
Api.createPlatform (#85)
This is an automated email from the ASF dual-hosted git repository.
raphinesse pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-browser.git
The following commit(s) were added to refs/heads/master by this push:
new 10852c1 Replace test stub for Api.createPlatform (#85)
10852c1 is described below
commit 10852c1b7e4a79f16ca60c7dcf6164eccac5d05b
Author: Raphael von der GrĂ¼n <ra...@gmail.com>
AuthorDate: Wed Oct 30 16:04:32 2019 +0100
Replace test stub for Api.createPlatform (#85)
---
spec/projectApi.spec.js | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/spec/projectApi.spec.js b/spec/projectApi.spec.js
index 072a1d8..21d6988 100644
--- a/spec/projectApi.spec.js
+++ b/spec/projectApi.spec.js
@@ -17,10 +17,11 @@
under the License.
*/
-var Api = require('../bin/template/cordova/Api');
-var shell = require('shelljs');
-var path = require('path');
-var tmpDir = path.join(__dirname, './temp');
+const path = require('path');
+const EventEmitter = require('events');
+
+const Api = require('../bin/template/cordova/Api');
+const create = require('../bin/lib/create');
describe('can get the Api', function () {
@@ -28,24 +29,9 @@ describe('can get the Api', function () {
expect(Api).toBeDefined();
});
- it('should export static createPlatform function', function (done) {
+ it('should export static createPlatform function', function () {
expect(Api.createPlatform).toBeDefined();
expect(typeof Api.createPlatform).toBe('function');
-
- // TODO: make this do something real
- var promise = Api.createPlatform(tmpDir);
- expect(promise).toBeDefined();
- expect(promise.then).toBeDefined();
- promise.then(function (res) {
- console.log('result = ' + res);
- shell.rm('-rf', tmpDir);
- done();
- },
- function (err) {
- console.log('spec-error ' + err);
- shell.rm('-rf', tmpDir);
- done();
- });
});
it('should export static updatePlatform function', function () {
@@ -53,6 +39,21 @@ describe('can get the Api', function () {
expect(typeof Api.updatePlatform).toBe('function');
});
+ describe('static createPlatform method', () => {
+ it('should create a platform app and return the Api', () => {
+ // Trick function under test to load our Api after calling createProject
+ const testDir = path.join(__dirname, '../bin/template');
+ const testOpts = {};
+ spyOn(create, 'createProject').and.returnValue(Promise.resolve());
+
+ return Api.createPlatform(testDir, null, testOpts, new EventEmitter()).then(api => {
+ expect(api).toBeInstanceOf(Api);
+ expect(create.createProject).toHaveBeenCalledWith(
+ testDir, jasmine.any(String), jasmine.any(String), testOpts
+ );
+ });
+ });
+ });
});
describe('project level Api', function () {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org