-
Notifications
You must be signed in to change notification settings - Fork 11
/
test.js
100 lines (89 loc) · 3.08 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
'use strict';
const path = require('path');
const helpers = require('yeoman-test');
const assert = require('yeoman-assert');
const pwd = path.resolve('./');
describe('generator', () => {
let generator;
beforeEach((done) => {
const deps = ['../app'];
helpers.testDirectory(path.join(__dirname, 'temp'), (err) => {
if (err) return done(err);
generator = helpers.createGenerator('redux-app:app', deps, null, { skipInstall: true });
done();
});
});
afterEach(() => {
process.chdir(pwd);
});
it('generates expected files', (done) => {
const expected = [
'.editorconfig',
'.gitignore',
'.eslintrc.json',
'.eslintignore',
'.travis.yml',
'.babelrc',
'CHANGELOG.md',
'LICENSE',
'package.json',
'README.md',
'server.js',
'webpack.config.dev.js',
'webpack.config.prod.js',
path.join('src', 'actions', 'counter.js'),
path.join('src', 'actions', '__tests__', 'counter.spec.js'),
path.join('src', 'components', 'Counter.js'),
path.join('src', 'components', '__tests__', 'Counter.spec.js'),
path.join('src', 'components', 'Main.js'),
path.join('src', 'containers', 'App.js'),
path.join('src', 'containers', 'CounterPage.js'),
path.join('src', 'containers', '__tests__', 'CounterPage.spec.js'),
path.join('src', 'containers', 'AnotherPage.js'),
path.join('src', 'containers', 'NotFoundPage.js'),
path.join('src', 'containers', 'index.js'),
path.join('src', 'containers', 'Root.js'),
path.join('src', 'reducers', 'counter.js'),
path.join('src', 'reducers', '__tests__', 'counter.spec.js'),
path.join('src', 'reducers', 'index.js'),
path.join('src', 'reducers', '__tests__', 'index.spec.js'),
path.join('src', 'store', 'configureStore.js'),
path.join('src', 'store', '__tests__', 'configureStore.spec.js'),
path.join('src', 'store', 'configureStore.dev.js'),
path.join('src', 'store', '__tests__', 'configureStore.dev.spec.js'),
path.join('src', 'store', 'configureStore.prod.js'),
path.join('src', 'store', '__tests__', 'configureStore.prod.spec.js'),
path.join('src', 'utils', 'createReducer.js'),
path.join('src', 'utils', '__tests__', 'createReducer.spec.js'),
path.join('src', 'index.js'),
path.join('src', 'index.css'),
path.join('src', 'index.html'),
path.join('src', 'createRoutes.js'),
path.join('src', '__tests__', 'createRoutes.spec.js'),
path.join('__mocks__', 'styleMock.js'),
];
helpers.mockPrompt(generator, {
moduleName: 'test',
githubUsername: 'test',
website: 'test.com',
flow: false,
});
generator.run(() => {
assert.file(expected);
done();
});
});
it('flow option', (done) => {
helpers.mockPrompt(generator, {
moduleName: 'test',
githubUsername: 'test',
website: 'test.com',
flow: true,
});
generator.run(() => {
assert.file('.flowconfig');
assert.fileContent('package.json', /"check":/);
done();
});
});
});