/
init-multipleEntries.test.js
40 lines (32 loc) · 1.19 KB
/
init-multipleEntries.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
const fs = require('fs');
const path = require('path');
const rimraf = require('rimraf');
const { runPromptWithAnswers } = require('../../utils/test-utils');
const firstPrompt = 'Will your application have multiple bundles?';
const ENTER = '\x0D';
const genPath = path.join(__dirname, 'test-assets');
describe('init with multiple entries', () => {
beforeAll(() => {
rimraf.sync(genPath);
fs.mkdirSync(genPath);
});
it('should scaffold with multiple entries', async () => {
const { stdout } = await runPromptWithAnswers(
genPath,
['init'],
[`Y${ENTER}`, `a, b${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER],
);
expect(stdout).toBeTruthy();
expect(stdout).toContain(firstPrompt);
// Skip test in case installation fails
if (!fs.existsSync(path.resolve(genPath, './yarn.lock'))) {
return;
}
// Test regressively files are scaffolded
const files = ['./package.json', './src/a.js', './src/b.js', './.yo-rc.json'];
files.forEach((file) => {
expect(fs.existsSync(path.resolve(genPath, file))).toBeTruthy();
});
});
});