Skip to content
Permalink
Browse files
Merge pull request #5 from raphinesse/fix-spec-promise-handling
Fix temp dir & promise handling in specs
  • Loading branch information
raphinesse committed Sep 25, 2018
2 parents 1cce89a + cddc8dc commit 31965d0816f8cf6a4221883204d1df49f497436d
Showing 3 changed files with 41 additions and 13 deletions.
@@ -21,9 +21,10 @@ var shell = require('shelljs');
var fs = require('fs');
var path = require('path');
var util = require('util');
var getTmpDir = require('./support/helpers').getTmpDir;

var cordova_bin = path.join(__dirname, '../src/bin');// is this the same on all platforms?
var tmpDir = path.join(__dirname, '../temp');
var tmpDir = getTmpDir();

function createAndBuild(projectname, projectid) {

@@ -17,34 +17,35 @@
under the License.
*/

var shell = require('shelljs');
var getTmpDir = require('./support/helpers').getTmpDir;
var Api = require("..");
/*
Note: require is expecting the package.json to define "main" with the path to Api.js for the platform.
*/

var tmpDir = getTmpDir();

describe('can get the Api', function() {

afterAll(function() {
process.chdir(__dirname);
shell.rm('-rf', tmpDir);
});

it('should be defined', 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("../tmp");
// 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);
console.log("spec-success");
done();
},
function(err) {
console.log("spec-error " + err);
done();
});
return promise;
});

it('should export static updatePlatform function', function() {
@@ -0,0 +1,26 @@
/*!
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 fs = require('fs');
var os = require('os');
var path = require('path');

module.exports.getTmpDir = function () {
return fs.mkdtempSync(path.join(os.tmpdir(), 'cordova-test-platform-'));
};

0 comments on commit 31965d0

Please sign in to comment.