-
-
Notifications
You must be signed in to change notification settings - Fork 243
/
Copy pathapp.js
106 lines (94 loc) · 3.49 KB
/
app.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
101
102
103
104
105
106
'use strict';
const path = require('path');
const assert = require('yeoman-assert');
const helpers = require('yeoman-test');
const generatorGeneratorPkg = require('../package.json');
jest.mock('superb', () => ({ random: () => "cat's meow" }));
jest.mock('npm-name', () => () => Promise.resolve(true));
describe('generator:app', () => {
describe('defaults', () => {
beforeEach(() => {
return helpers.run(path.join(__dirname, '../app')).withPrompts({
name: 'generator-temp',
description: 'A node generator',
homepage: 'http://yeoman.io',
githubAccount: 'yeoman',
authorName: 'The Yeoman Team',
authorEmail: '[email protected]',
authorUrl: 'http://yeoman.io',
keywords: [],
license: 'MIT'
});
});
it('created and CD into a folder named like the generator', () => {
assert.strictEqual(path.basename(process.cwd()), 'generator-temp');
});
it('creates files', () => {
const expected = [
'.eslintignore',
'README.md',
'package.json',
'generators/app/index.js',
'generators/app/templates/dummyfile.txt',
'__tests__/app.js'
];
assert.file(expected);
});
it('fills package.json with correct information', () => {
// eslint-disable-next-line new-cap
assert.JSONFileContent('package.json', {
name: 'generator-temp',
dependencies: {
'yeoman-generator': generatorGeneratorPkg.dependencies['yeoman-generator'],
chalk: generatorGeneratorPkg.dependencies.chalk,
yosay: generatorGeneratorPkg.dependencies.yosay
},
devDependencies: {
'yeoman-test': generatorGeneratorPkg.devDependencies['yeoman-test'],
'yeoman-assert': generatorGeneratorPkg.devDependencies['yeoman-assert']
},
keywords: ['yeoman-generator']
});
});
it('fills the README with project data', () => {
assert.fileContent('README.md', '# generator-temp');
assert.fileContent('README.md', 'npm install -g yo');
assert.fileContent('README.md', 'npm install -g generator-temp');
assert.fileContent('README.md', 'yo temp');
assert.fileContent('README.md', 'yeoman/generator-temp');
});
it('fills the .eslintignore with correct content', () => {
assert.fileContent('.eslintignore', '**/templates\n');
});
});
describe('scoped name', () => {
beforeEach(() => {
return helpers.run(path.join(__dirname, '../app')).withPrompts({
name: '@yeoman/generator-temp',
description: 'A node generator',
homepage: 'http://yeoman.io',
githubAccount: 'yeoman',
authorName: 'The Yeoman Team',
authorEmail: '[email protected]',
authorUrl: 'http://yeoman.io',
keywords: [],
license: 'MIT'
});
});
it('created and CD into a folder named like the generator', () => {
assert.strictEqual(path.basename(process.cwd()), 'generator-temp');
});
it('fills package.json with correct information', () => {
// eslint-disable-next-line new-cap
assert.JSONFileContent('package.json', {
name: '@yeoman/generator-temp'
});
});
it('fills the README with project data', () => {
assert.fileContent('README.md', '# @yeoman/generator-temp');
assert.fileContent('README.md', 'npm install -g yo');
assert.fileContent('README.md', 'npm install -g @yeoman/generator-temp');
assert.fileContent('README.md', 'yo @yeoman/temp');
});
});
});