@@ -10,7 +10,8 @@ import {
1010 copyAsync ,
1111 runCmd ,
1212 assertOnlyFiles ,
13- getConfig
13+ readJSON ,
14+ runGen
1415} from './test-helpers' ;
1516
1617const defaultOptions = {
@@ -30,48 +31,6 @@ const defaultOptions = {
3031} ;
3132const TEST_DIR = __dirname ;
3233
33- function runGen ( prompts , opts = { } ) {
34- let options = opts . options || { skipInstall : true } ;
35-
36- return new Promise ( ( resolve , reject ) => {
37- let dir ;
38- let gen = helpers
39- . run ( require . resolve ( '../generators/app' ) )
40- . inTmpDir ( function ( _dir ) {
41- // this will create a new temporary directory for each new generator run
42- var done = this . async ( ) ;
43- if ( DEBUG ) console . log ( `TEMP DIR: ${ _dir } ` ) ;
44- dir = _dir ;
45-
46- let promises = [
47- fs . mkdirAsync ( dir + '/client' ) . then ( ( ) => {
48- return fs . symlinkAsync ( __dirname + '/fixtures/bower_components' , dir + '/client/bower_components' ) ;
49- } ) ,
50- fs . symlinkAsync ( __dirname + '/fixtures/node_modules' , dir + '/node_modules' )
51- ] ;
52-
53- if ( opts . copyConfigFile ) {
54- promises . push ( copyAsync ( path . join ( TEST_DIR , 'fixtures/.yo-rc.json' ) , path . join ( dir , '.yo-rc.json' ) ) ) ;
55- }
56-
57- // symlink our dependency directories
58- return Promise . all ( promises ) . then ( done ) ;
59- } )
60- . withGenerators ( [
61- require . resolve ( '../generators/endpoint' ) ,
62- // [helpers.createDummyGenerator(), 'ng-component:app']
63- ] )
64- // .withArguments(['upperCaseBug'])
65- . withOptions ( options ) ;
66-
67- if ( prompts ) gen . withPrompts ( prompts ) ;
68-
69- gen
70- . on ( 'error' , reject )
71- . on ( 'end' , ( ) => resolve ( dir ) ) ;
72- } ) ;
73- }
74-
7534function runEndpointGen ( name , opt = { } ) {
7635 let prompts = opt . prompts || { } ;
7736 let options = opt . options || { } ;
@@ -129,7 +88,7 @@ describe('angular-fullstack:app', function() {
12988
13089 describe ( 'with a generated endpoint' , function ( ) {
13190 beforeEach ( function ( ) {
132- return getConfig ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
91+ return readJSON ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
13392 return runEndpointGen ( 'foo' , { config : config [ 'generator-angular-fullstack' ] } ) ;
13493 } ) ;
13594 } ) ;
@@ -141,7 +100,7 @@ describe('angular-fullstack:app', function() {
141100
142101 describe ( 'with a generated capitalized endpoint' , function ( ) {
143102 beforeEach ( function ( ) {
144- return getConfig ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
103+ return readJSON ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
145104 return runEndpointGen ( 'Foo' , { config : config [ 'generator-angular-fullstack' ] } ) ;
146105 } ) ;
147106 } ) ;
@@ -153,7 +112,7 @@ describe('angular-fullstack:app', function() {
153112
154113 describe ( 'with a generated path name endpoint' , function ( ) {
155114 beforeEach ( function ( ) {
156- return getConfig ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
115+ return readJSON ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
157116 return runEndpointGen ( 'foo/bar' , { config : config [ 'generator-angular-fullstack' ] } ) ;
158117 } ) ;
159118 } ) ;
@@ -165,7 +124,7 @@ describe('angular-fullstack:app', function() {
165124
166125 describe ( 'with a generated snake-case endpoint' , function ( ) {
167126 beforeEach ( function ( ) {
168- return getConfig ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
127+ return readJSON ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
169128 return runEndpointGen ( 'foo-bar' , { config : config [ 'generator-angular-fullstack' ] } ) ;
170129 } ) ;
171130 } ) ;
@@ -287,7 +246,7 @@ describe('angular-fullstack:app', function() {
287246
288247 describe ( 'with a generated endpoint' , function ( ) {
289248 beforeEach ( function ( ) {
290- return getConfig ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
249+ return readJSON ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
291250 return runEndpointGen ( 'foo' , { config : config [ 'generator-angular-fullstack' ] } ) ;
292251 } ) ;
293252 } ) ;
@@ -363,7 +322,7 @@ describe('angular-fullstack:app', function() {
363322
364323 describe ( 'with a generated endpoint' , function ( ) {
365324 beforeEach ( function ( ) {
366- return getConfig ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
325+ return readJSON ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
367326 return runEndpointGen ( 'foo' , { config : config [ 'generator-angular-fullstack' ] } ) ;
368327 } ) ;
369328 } ) ;
@@ -440,7 +399,7 @@ describe('angular-fullstack:app', function() {
440399
441400 describe ( 'with a generated endpoint' , function ( ) {
442401 beforeEach ( function ( ) {
443- return getConfig ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
402+ return readJSON ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
444403 return runEndpointGen ( 'foo' , { config : config [ 'generator-angular-fullstack' ] } ) ;
445404 } ) ;
446405 } ) ;
0 commit comments