From e0bee65cfc5c22f69b567a416a5f04276b16ba86 Mon Sep 17 00:00:00 2001 From: Jia Hao Date: Thu, 28 Jan 2016 22:39:13 +0800 Subject: [PATCH] Fix problem with async each and creation of temporary directories --- test/module/index-spec.js | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/test/module/index-spec.js b/test/module/index-spec.js index 9642714..47ff5d5 100644 --- a/test/module/index-spec.js +++ b/test/module/index-spec.js @@ -5,6 +5,7 @@ import path from 'path'; import nativefier from './../../lib/index'; import _ from 'lodash'; import async from 'async'; +tmp.setGracefulCleanup(); let assert = chai.assert; @@ -43,31 +44,27 @@ function checkApp(appPath, inputOptions, callback) { describe('Nativefier Module', function() { this.timeout(30000); it('Can build an app from a target url', function(done) { + async.eachSeries(PLATFORMS, (platform, callback) => { - var tmpObj = tmp.dirSync({unsafeCleanup: true}); - after(function() { - tmpObj.removeCallback(); - }); + const tmpObj = tmp.dirSync({unsafeCleanup: true}); - const tmpPath = tmpObj.name; - const options = { - appName: 'google-test-app', - targetUrl: 'http://google.com', - outDir: tmpPath, - overwrite: true, - platform: null - }; + const tmpPath = tmpObj.name; + const options = { + appName: 'google-test-app', + targetUrl: 'http://google.com', + outDir: tmpPath, + overwrite: true, + platform: null + }; - async.each(PLATFORMS, (platform, callback) => { - let platformOptions = _.clone(options); - platformOptions.platform = platform; - nativefier(platformOptions, (error, appPath) => { + options.platform = platform; + nativefier(options, (error, appPath) => { if (error) { callback(error); return; } - checkApp(appPath, platformOptions, error => { + checkApp(appPath, options, error => { callback(error); }); }); @@ -76,3 +73,4 @@ describe('Nativefier Module', function() { }); }); }); +