Skip to content

Commit

Permalink
test(initializer): add test for custom initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed Dec 30, 2016
1 parent 9e6ddfa commit 0dc6230
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 1 deletion.
36 changes: 35 additions & 1 deletion test/cli_spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spawn } from 'child_process';
import { execSync, spawn } from 'child_process';
import fs from 'fs-promise';
import os from 'os';
import path from 'path';
Expand Down Expand Up @@ -76,6 +76,40 @@ describe(`electron-forge CLI (with installer=${installer.substr(12)})`, () => {
forLintingMethod('airbnb');
forLintingMethod('standard');

describe('init (with custom templater)', () => {
let dir;

before(async () => {
dir = path.resolve(os.tmpdir(), `electron-forge-test-${dirID}`);
dirID += 1;
await fs.remove(dir);
execSync('npm link', {
cwd: path.resolve(__dirname, 'fixture/custom_init'),
});
await pSpawn(['init', dir, '--template=dummy']);
});

it('should create dot files correctly', async () => {
expect(await fs.exists(dir), 'the target dir should have been created').to.equal(true);
expect(await fs.exists(path.resolve(dir, '.bar')), 'the .bar file should exist').to.equal(true);
});

it('should create deep files correctly', async () => {
expect(await fs.exists(path.resolve(dir, 'src/foo.js')), 'the src/foo.js file should exist').to.equal(true);
});

describe('lint', () => {
it('should initially pass the linting process', () => pSpawn(['lint', dir]));
});

after(async () => {
await fs.remove(dir);
execSync('npm unlink', {
cwd: path.resolve(__dirname, 'fixture/custom_init'),
});
});
});

describe('after init', () => {
let dir;

Expand Down
8 changes: 8 additions & 0 deletions test/fixture/custom_init/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const path = require('path');

module.exports = {
dependencies: ['react'],
devDependencies: ['react-dom'],
templateDirectory: path.resolve(__dirname, './tmpl'),
postCopy: (initDir, ora, lintStyle) => {}, // eslint-disable-line
};
12 changes: 12 additions & 0 deletions test/fixture/custom_init/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "electron-forge-template-dummy",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "electron-forge start"
},
"keywords": [],
"author": "",
"license": "MIT"
}
Empty file.
Empty file.

0 comments on commit 0dc6230

Please sign in to comment.