@@ -16,7 +16,6 @@ import {
1616
1717const defaultOptions = {
1818 buildtool : 'grunt' ,
19- script : 'js' ,
2019 transpiler : 'babel' ,
2120 markup : 'html' ,
2221 stylesheet : 'sass' ,
@@ -32,34 +31,43 @@ const defaultOptions = {
3231} ;
3332const 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
9199describe ( '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} ) ;
0 commit comments