@@ -10,7 +10,8 @@ import {
10
10
copyAsync ,
11
11
runCmd ,
12
12
assertOnlyFiles ,
13
- getConfig
13
+ readJSON ,
14
+ runGen
14
15
} from './test-helpers' ;
15
16
16
17
const defaultOptions = {
@@ -30,48 +31,6 @@ const defaultOptions = {
30
31
} ;
31
32
const TEST_DIR = __dirname ;
32
33
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
-
75
34
function runEndpointGen ( name , opt = { } ) {
76
35
let prompts = opt . prompts || { } ;
77
36
let options = opt . options || { } ;
@@ -129,7 +88,7 @@ describe('angular-fullstack:app', function() {
129
88
130
89
describe ( 'with a generated endpoint' , function ( ) {
131
90
beforeEach ( function ( ) {
132
- return getConfig ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
91
+ return readJSON ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
133
92
return runEndpointGen ( 'foo' , { config : config [ 'generator-angular-fullstack' ] } ) ;
134
93
} ) ;
135
94
} ) ;
@@ -141,7 +100,7 @@ describe('angular-fullstack:app', function() {
141
100
142
101
describe ( 'with a generated capitalized endpoint' , function ( ) {
143
102
beforeEach ( function ( ) {
144
- return getConfig ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
103
+ return readJSON ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
145
104
return runEndpointGen ( 'Foo' , { config : config [ 'generator-angular-fullstack' ] } ) ;
146
105
} ) ;
147
106
} ) ;
@@ -153,7 +112,7 @@ describe('angular-fullstack:app', function() {
153
112
154
113
describe ( 'with a generated path name endpoint' , function ( ) {
155
114
beforeEach ( function ( ) {
156
- return getConfig ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
115
+ return readJSON ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
157
116
return runEndpointGen ( 'foo/bar' , { config : config [ 'generator-angular-fullstack' ] } ) ;
158
117
} ) ;
159
118
} ) ;
@@ -165,7 +124,7 @@ describe('angular-fullstack:app', function() {
165
124
166
125
describe ( 'with a generated snake-case endpoint' , function ( ) {
167
126
beforeEach ( function ( ) {
168
- return getConfig ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
127
+ return readJSON ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
169
128
return runEndpointGen ( 'foo-bar' , { config : config [ 'generator-angular-fullstack' ] } ) ;
170
129
} ) ;
171
130
} ) ;
@@ -287,7 +246,7 @@ describe('angular-fullstack:app', function() {
287
246
288
247
describe ( 'with a generated endpoint' , function ( ) {
289
248
beforeEach ( function ( ) {
290
- return getConfig ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
249
+ return readJSON ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
291
250
return runEndpointGen ( 'foo' , { config : config [ 'generator-angular-fullstack' ] } ) ;
292
251
} ) ;
293
252
} ) ;
@@ -363,7 +322,7 @@ describe('angular-fullstack:app', function() {
363
322
364
323
describe ( 'with a generated endpoint' , function ( ) {
365
324
beforeEach ( function ( ) {
366
- return getConfig ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
325
+ return readJSON ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
367
326
return runEndpointGen ( 'foo' , { config : config [ 'generator-angular-fullstack' ] } ) ;
368
327
} ) ;
369
328
} ) ;
@@ -440,7 +399,7 @@ describe('angular-fullstack:app', function() {
440
399
441
400
describe ( 'with a generated endpoint' , function ( ) {
442
401
beforeEach ( function ( ) {
443
- return getConfig ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
402
+ return readJSON ( path . join ( dir , '.yo-rc.json' ) ) . then ( config => {
444
403
return runEndpointGen ( 'foo' , { config : config [ 'generator-angular-fullstack' ] } ) ;
445
404
} ) ;
446
405
} ) ;
0 commit comments