Skip to content
Permalink
Browse files

fix(tests): stop awaiting mocha and ensure we clean up out dirs

  • Loading branch information
MarshallOfSound committed Mar 25, 2017
1 parent 9369284 commit 2e6dc384aa10cee1592ba3b73bcfa31baaf1622b
Showing with 28 additions and 13 deletions.
  1. +28 −13 test/slow/api_spec_slow.js
@@ -163,10 +163,6 @@ describe(`electron-forge API (with installer=${installer.substr(12)})`, () => {
await fs.writeFile(path.resolve(dir, 'package.json'), JSON.stringify(packageJSON, null, 2));
});

it('can package without errors', async () => {
await forge.package({ dir });
});

it('can package to outDir without errors', async () => {
const outDir = `${dir}/foo`;

@@ -177,9 +173,26 @@ describe(`electron-forge API (with installer=${installer.substr(12)})`, () => {
expect(await fs.exists(outDir)).to.equal(true);
});

it('can make from custom outDir without errors', async () => {
const packageJSON = await readPackageJSON(dir);
packageJSON.config.forge.make_targets[process.platform] = ['zip'];
await fs.writeFile(path.resolve(dir, 'package.json'), JSON.stringify(packageJSON));

await forge.make({ dir, skipPackage: true, outDir: `${dir}/foo` });

// Cleanup here to ensure things dont break in the make tests
await fs.remove(path.resolve(dir, 'foo'));
await fs.remove(path.resolve(dir, 'out'));
});

it('can package without errors with native pre-gyp deps installed', async () => {
await installDeps(dir, ['ref']);
await forge.package({ dir });
await fs.remove(path.resolve(dir, 'node_modules/ref'));
});

it('can package without errors', async () => {
await forge.package({ dir });
});

describe('after package', () => {
@@ -205,25 +218,27 @@ describe(`electron-forge API (with installer=${installer.substr(12)})`, () => {
targets = fs.readdirSync(path.resolve(__dirname, `../../src/makers/${process.platform}`)).map(file => path.parse(file).name);
}
const genericTargets = fs.readdirSync(path.resolve(__dirname, '../../src/makers/generic')).map(file => path.parse(file).name);
const testMakeTarget = async function testMakeTarget(target, options = {}) {
await describe(`make (with target=${target})`, async () => {
await before(async () => {

const testMakeTarget = function testMakeTarget(target, ...options) {
describe(`make (with target=${target})`, async () => {
before(async () => {
const packageJSON = await readPackageJSON(dir);
packageJSON.config.forge.make_targets[process.platform] = [target];
await fs.writeFile(path.resolve(dir, 'package.json'), JSON.stringify(packageJSON));
});

await it(`successfully makes for config: ${JSON.stringify(options, 2)}`, async () => {
await forge.make(options);
options.forEach((optionsFetcher) => {
it(`successfully makes for config: ${JSON.stringify(optionsFetcher(), 2)}`, async () => {
await forge.make(optionsFetcher());
});
});
});
};

[].concat(targets).concat(genericTargets).forEach(async (target) => {
await testMakeTarget(target, { dir, skipPackage: true });
[].concat(targets).concat(genericTargets).forEach((target) => {
const testOptions = [() => ({ dir, skipPackage: true })];
testMakeTarget(target, ...testOptions);
});

testMakeTarget('zip', { dir, skipPackage: true, outDir: `${dir}/foo` });
});

after(() => fs.remove(dir));

0 comments on commit 2e6dc38

Please sign in to comment.
You can’t perform that action at this time.