Skip to content
Permalink
Browse files

test(generic): increase test coverage of the init API

  • Loading branch information
MarshallOfSound authored and malept committed Jan 15, 2017
1 parent 0d2f571 commit 2c9caddf9ae54e53237e438cedbaf4f6e01d4d63
Showing with 16 additions and 30 deletions.
  1. +4 −0 src/makers/generic/zip.js
  2. +12 −30 test/slow/api_spec_slow.js
@@ -24,12 +24,16 @@ export default async (dir, appName, targetArch, forgeConfig, packageJSON) => { /
const zipPath = path.resolve(dir, '../make', `${path.basename(dir)}.zip`);
await ensureFile(zipPath);
switch (process.platform) {
// This case is tested but not on the coverage reporting platform
/* istanbul ignore next */
case 'win32':
await pify(zipFolder)(dir, zipPath);
break;
case 'darwin':
await zipPromise(path.resolve(dir, `${appName}.app`), zipPath);
break;
// This case is tested but not on the coverage reporting platform
/* istanbul ignore next */
case 'linux':
await zipPromise(dir, zipPath);
break;
@@ -4,42 +4,17 @@ import os from 'os';
import path from 'path';

import { expect } from 'chai';
import proxyquire from 'proxyquire';

import forge from '../../src/api';
import installDeps from '../../src/util/install-dependencies';
import readPackageJSON from '../../src/util/read-package-json';

// const pSpawn = async (args = [], opts = {
// stdio: process.platform === 'win32' ? 'inherit' : 'pipe',
// }) => {
// const child = spawn(process.execPath, [path.resolve(__dirname, '../../dist/electron-forge.js')].concat(args), opts);
// let stdout = '';
// let stderr = '';
// if (process.platform !== 'win32') {
// child.stdout.on('data', (data) => { stdout += data; });
// child.stderr.on('data', (data) => { stderr += data; });
// }
// return new Promise((resolve, reject) => {
// child.on('exit', (code) => {
// if (code === 0) {
// return resolve(stdout);
// }
// reject(new Error(stderr));
// });
// });
// };

const installer = process.argv.find(arg => arg.startsWith('--installer=')) || '--installer=system default';
const forge = proxyquire.noCallThru().load('../../src/api', {
'./install': async () => {},
});

describe(`electron-forge CLI (with installer=${installer.substr(12)})`, () => {
// it('should output help', async function helpSpec() {
// if (process.platform === 'win32') {
// this.skip();
// } else {
// expect(await pSpawn(['--help'])).to.contain('Usage: electron-forge [options] [command]');
// }
// });

describe(`electron-forge API (with installer=${installer.substr(12)})`, () => {
let dirID = Date.now();
const forLintingMethod = (lintStyle) => {
describe(`init (with lintStyle=${lintStyle})`, () => {
@@ -133,6 +108,13 @@ describe(`electron-forge CLI (with installer=${installer.substr(12)})`, () => {
});
});

it('should succeed in initializing an already initialized directory', async () => {
await forge.init({
dir,
template: 'react-typescript',
});
});

it('should add a dependency on react', async () => {
expect(Object.keys(require(path.resolve(dir, 'package.json')).dependencies)).to.contain('react');
});

0 comments on commit 2c9cadd

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