Skip to content

Commit 0445fcc

Browse files
committed
test(gen:main): test using existing config
1 parent c70d35a commit 0445fcc

File tree

3 files changed

+137
-29
lines changed

3 files changed

+137
-29
lines changed

Diff for: src/test/fixtures/.yo-rc.json

+40-7
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,57 @@
1313
"registerModelsFile": "server/sqldb/index.js",
1414
"modelsNeedle": "// Insert models below",
1515
"filters": {
16+
"js": true,
1617
"babel": true,
18+
"flow": false,
1719
"html": true,
18-
"less": true,
20+
"sass": true,
1921
"uirouter": true,
20-
"bootstrap": false,
21-
"uibootstrap": false,
22+
"bootstrap": true,
23+
"uibootstrap": true,
2224
"socketio": true,
2325
"auth": true,
2426
"models": true,
2527
"mongooseModels": true,
2628
"mongoose": true,
27-
"oauth": true,
28-
"googleAuth": true,
2929
"grunt": true,
3030
"mocha": true,
3131
"jasmine": false,
32-
"should": true,
33-
"expect": false
32+
"expect": true
3433
}
34+
},
35+
"generator-ng-component": {
36+
"routeDirectory": "client/app/",
37+
"directiveDirectory": "client/app/",
38+
"componentDirectory": "app/components/",
39+
"filterDirectory": "client/app/",
40+
"serviceDirectory": "client/app/",
41+
"basePath": "client",
42+
"moduleName": "",
43+
"modulePrompt": true,
44+
"filters": [
45+
"uirouter",
46+
"mocha",
47+
"expect",
48+
"should",
49+
"uirouter",
50+
"es6"
51+
],
52+
"extensions": [
53+
"babel",
54+
"js",
55+
"html",
56+
"scss"
57+
],
58+
"directiveSimpleTemplates": "",
59+
"directiveComplexTemplates": "",
60+
"filterTemplates": "",
61+
"serviceTemplates": "",
62+
"factoryTemplates": "",
63+
"controllerTemplates": "",
64+
"componentTemplates": "",
65+
"decoratorTemplates": "",
66+
"providerTemplates": "",
67+
"routeTemplates": ""
3568
}
3669
}

Diff for: src/test/main.test.js

+57-15
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616

1717
const defaultOptions = {
1818
buildtool: 'grunt',
19-
script: 'js',
2019
transpiler: 'babel',
2120
markup: 'html',
2221
stylesheet: 'sass',
@@ -32,34 +31,43 @@ const defaultOptions = {
3231
};
3332
const TEST_DIR = __dirname;
3433

35-
function runGen(prompts) {
34+
function runGen(prompts, opts={}) {
35+
let options = opts.options || {skipInstall: true};
36+
3637
return new Promise((resolve, reject) => {
3738
let dir;
38-
helpers
39+
let gen = helpers
3940
.run(require.resolve('../generators/app'))
4041
.inTmpDir(function(_dir) {
4142
// this will create a new temporary directory for each new generator run
4243
var done = this.async();
4344
if(DEBUG) console.log(`TEMP DIR: ${_dir}`);
4445
dir = _dir;
4546

46-
// symlink our dependency directories
47-
return Promise.all([
47+
let promises = [
4848
fs.mkdirAsync(dir + '/client').then(() => {
4949
return fs.symlinkAsync(__dirname + '/fixtures/bower_components', dir + '/client/bower_components');
5050
}),
5151
fs.symlinkAsync(__dirname + '/fixtures/node_modules', dir + '/node_modules')
52-
]).then(done);
52+
];
53+
54+
if(opts.copyConfigFile) {
55+
promises.push(copyAsync(path.join(TEST_DIR, 'fixtures/.yo-rc.json'), path.join(dir, '.yo-rc.json')));
56+
}
57+
58+
// symlink our dependency directories
59+
return Promise.all(promises).then(done);
5360
})
5461
.withGenerators([
5562
require.resolve('../generators/endpoint'),
5663
// [helpers.createDummyGenerator(), 'ng-component:app']
5764
])
58-
.withOptions({
59-
skipInstall: true
60-
})
6165
// .withArguments(['upperCaseBug'])
62-
.withPrompts(prompts)
66+
.withOptions(options);
67+
68+
if(prompts) gen.withPrompts(prompts);
69+
70+
gen
6371
.on('error', reject)
6472
.on('end', () => resolve(dir));
6573
});
@@ -89,15 +97,11 @@ function runEndpointGen(name, opt={}) {
8997
}
9098

9199
describe('angular-fullstack:app', function() {
92-
beforeEach(function() {
93-
this.gen = runGen(defaultOptions);
94-
});
95-
96100
describe('default settings', function() {
97101
var dir;
98102

99103
beforeEach(function() {
100-
return this.gen.then(_dir => {
104+
return runGen(defaultOptions).then(_dir => {
101105
dir = _dir;
102106
});
103107
});
@@ -202,4 +206,42 @@ describe('angular-fullstack:app', function() {
202206
it('should run e2e tests successfully for production app'); //'grunt test:e2e:prod'
203207
}
204208
});
209+
210+
describe('default settings using existing `.yo-rc.json`', function() {
211+
var dir;
212+
213+
beforeEach(function() {
214+
return runGen(null, {
215+
copyConfigFile: true,
216+
options: {
217+
skipInstall: true,
218+
skipConfig: true
219+
}
220+
}).then(_dir => {
221+
dir = _dir;
222+
});
223+
});
224+
225+
it('generates the proper files', function() {
226+
const expectedFiles = getExpectedFiles.app(defaultOptions);
227+
assert.file(expectedFiles);
228+
return assertOnlyFiles(expectedFiles, path.normalize(dir)).should.be.fulfilled();
229+
});
230+
231+
it('passes JSCS', function() {
232+
return runCmd('grunt jscs').should.be.fulfilled();
233+
});
234+
235+
it('passes JSHint', function() {
236+
return runCmd('grunt jshint').should.be.fulfilled();
237+
});
238+
239+
it('passes client tests', function() {
240+
return runCmd('grunt test:client').should.be.fulfilled();
241+
});
242+
243+
it('passes server tests', function() {
244+
return runCmd('grunt test:server').should.be.fulfilled();
245+
});
246+
});
205247
});

Diff for: test/fixtures/.yo-rc.json

+40-7
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,57 @@
1313
"registerModelsFile": "server/sqldb/index.js",
1414
"modelsNeedle": "// Insert models below",
1515
"filters": {
16+
"js": true,
1617
"babel": true,
18+
"flow": false,
1719
"html": true,
18-
"less": true,
20+
"sass": true,
1921
"uirouter": true,
20-
"bootstrap": false,
21-
"uibootstrap": false,
22+
"bootstrap": true,
23+
"uibootstrap": true,
2224
"socketio": true,
2325
"auth": true,
2426
"models": true,
2527
"mongooseModels": true,
2628
"mongoose": true,
27-
"oauth": true,
28-
"googleAuth": true,
2929
"grunt": true,
3030
"mocha": true,
3131
"jasmine": false,
32-
"should": true,
33-
"expect": false
32+
"expect": true
3433
}
34+
},
35+
"generator-ng-component": {
36+
"routeDirectory": "client/app/",
37+
"directiveDirectory": "client/app/",
38+
"componentDirectory": "app/components/",
39+
"filterDirectory": "client/app/",
40+
"serviceDirectory": "client/app/",
41+
"basePath": "client",
42+
"moduleName": "",
43+
"modulePrompt": true,
44+
"filters": [
45+
"uirouter",
46+
"mocha",
47+
"expect",
48+
"should",
49+
"uirouter",
50+
"es6"
51+
],
52+
"extensions": [
53+
"babel",
54+
"js",
55+
"html",
56+
"scss"
57+
],
58+
"directiveSimpleTemplates": "",
59+
"directiveComplexTemplates": "",
60+
"filterTemplates": "",
61+
"serviceTemplates": "",
62+
"factoryTemplates": "",
63+
"controllerTemplates": "",
64+
"componentTemplates": "",
65+
"decoratorTemplates": "",
66+
"providerTemplates": "",
67+
"routeTemplates": ""
3568
}
3669
}

0 commit comments

Comments
 (0)