Skip to content

Commit

Permalink
fix(tests): stop awaiting mocha and ensure we clean up out dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed Mar 25, 2017
1 parent 9369284 commit 2e6dc38
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions test/slow/api_spec_slow.js
Expand Up @@ -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`;

Expand All @@ -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', () => {
Expand All @@ -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));
Expand Down

0 comments on commit 2e6dc38

Please sign in to comment.