Skip to content

Commit

Permalink
test(generic): increase test coverage of the init API
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound authored and malept committed Jan 30, 2017
1 parent 0d2f571 commit 2c9cadd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 30 deletions.
4 changes: 4 additions & 0 deletions src/makers/generic/zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
42 changes: 12 additions & 30 deletions test/slow/api_spec_slow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})`, () => {
Expand Down Expand Up @@ -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');
});
Expand Down

0 comments on commit 2c9cadd

Please sign in to comment.