You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by er...@apache.org on 2019/02/28 05:59:38 UTC

[cordova-electron] branch master updated: Improve Temp Folder Cleanup in Api.spec.js (#32)

This is an automated email from the ASF dual-hosted git repository.

erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-electron.git


The following commit(s) were added to refs/heads/master by this push:
     new 017727a  Improve Temp Folder Cleanup in Api.spec.js (#32)
017727a is described below

commit 017727a673d293b2a4ca66a9104ca84e432c364f
Author: Gedas Gardauskas <ge...@gmail.com>
AuthorDate: Thu Feb 28 14:59:33 2019 +0900

    Improve Temp Folder Cleanup in Api.spec.js (#32)
    
    - Remove temp folder after tests
    - Add temp folder to .npmignore
---
 .npmignore                  |  3 ++-
 tests/spec/unit/Api.spec.js | 19 ++++++-------------
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/.npmignore b/.npmignore
index a1e2f4d..ad2eb52 100644
--- a/.npmignore
+++ b/.npmignore
@@ -4,6 +4,7 @@
 .nyc_output
 coverage
 tests
+temp
 
 # CI service configurations
 .travis.yml
@@ -18,4 +19,4 @@ npm-debug.log*
 .git
 .gitattributes
 .github
-.gitignore
+.gitignore
\ No newline at end of file
diff --git a/tests/spec/unit/Api.spec.js b/tests/spec/unit/Api.spec.js
index a8e3c3f..98f9ee3 100644
--- a/tests/spec/unit/Api.spec.js
+++ b/tests/spec/unit/Api.spec.js
@@ -23,17 +23,11 @@ const rewire = require('rewire');
 const templateDir = path.resolve(__dirname, '..', '..', '..', 'bin', 'templates');
 const Api = rewire(path.join(templateDir, 'cordova', 'Api'));
 const tmpDir = path.join(__dirname, '../../../temp');
-const tmpWorkDir = path.join(tmpDir, 'work');
 const apiRequire = Api.__get__('require');
 const FIXTURES = path.join(__dirname, '..', 'fixtures');
 const pluginFixture = path.join(FIXTURES, 'testplugin');
 const testProjectDir = path.join(tmpDir, 'testapp');
 
-function copyTestProject () {
-    fs.ensureDirSync(tmpDir);
-    fs.copySync(path.resolve(FIXTURES, 'testapp'), path.resolve(tmpDir, 'testapp'));
-}
-
 function dirExists (dir) {
     return fs.existsSync(dir) && fs.statSync(dir).isDirectory();
 }
@@ -59,9 +53,8 @@ function writeJson (file, json) {
 }
 
 describe('Api class', () => {
-    fs.removeSync(tmpDir);
-    fs.ensureDirSync(tmpWorkDir);
-    copyTestProject();
+    fs.ensureDirSync(tmpDir);
+    fs.copySync(path.resolve(FIXTURES, 'testapp'), path.resolve(tmpDir, 'testapp'));
 
     const api = new Api(null, testProjectDir);
     const apiEvents = Api.__get__('selfEvents');
@@ -508,18 +501,18 @@ describe('Api class', () => {
 
     describe('createPlatform method', () => {
         beforeEach(() => {
-            fs.removeSync(tmpWorkDir);
+            fs.removeSync(tmpDir);
         });
 
         afterEach(() => {
-            fs.removeSync(tmpWorkDir);
+            fs.removeSync(tmpDir);
         });
 
         /**
          * @todo improve createPlatform to test actual created platforms.
          */
         it('should export static createPlatform function', () => {
-            return Api.createPlatform(tmpWorkDir).then(
+            return Api.createPlatform(tmpDir).then(
                 (results) => {
                     expect(results.constructor.name).toBe(api.constructor.name);
                 }
@@ -533,7 +526,7 @@ describe('Api class', () => {
                 };
             });
 
-            expect(() => Api.createPlatform(tmpWorkDir)).toThrowError(/createPlatform is not callable from the electron project API/);
+            expect(() => Api.createPlatform(tmpDir)).toThrowError(/createPlatform is not callable from the electron project API/);
 
             Api.__set__('require', apiRequire);
         });


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org