@@ -39,13 +39,16 @@ describe('angular-fullstack generator', function () {
39
39
path = path || './' ;
40
40
skip = skip || [ 'e2e' , 'node_modules' , 'client/bower_components' ] ;
41
41
42
- recursiveReadDir ( path , skip , function ( err , files ) {
42
+ recursiveReadDir ( path , skip , function ( err , actualFiles ) {
43
43
if ( err ) { return done ( err ) ; }
44
+ var files = actualFiles . concat ( ) ;
44
45
45
- for ( var i = 0 , expectedFilesLength = expectedFiles . length ; i < expectedFilesLength ; i ++ ) {
46
- var index = files . indexOf ( expectedFiles [ i ] ) ;
47
- files . splice ( index , 1 ) ;
48
- }
46
+ expectedFiles . forEach ( function ( file , i ) {
47
+ var index = files . indexOf ( file ) ;
48
+ if ( index >= 0 ) {
49
+ files . splice ( index , 1 ) ;
50
+ }
51
+ } ) ;
49
52
50
53
if ( files . length !== 0 ) {
51
54
err = new Error ( 'unexpected files found' ) ;
@@ -58,11 +61,16 @@ describe('angular-fullstack generator', function () {
58
61
} ) ;
59
62
}
60
63
61
- function runTest ( type , self , cb , timeout ) {
64
+ function runTest ( cmd , self , cb ) {
65
+ var args = Array . prototype . slice . call ( arguments ) ,
66
+ endpoint = ( args [ 3 ] && typeof args [ 3 ] === 'string' ) ? args . splice ( 3 , 1 ) [ 0 ] : null ,
67
+ timeout = ( args [ 3 ] && typeof args [ 3 ] === 'number' ) ? args . splice ( 3 , 1 ) [ 0 ] : null ;
68
+
62
69
self . timeout ( timeout || 60000 ) ;
63
- gen . run ( { } , function ( ) {
64
- exec ( type , function ( error , stdout , stderr ) {
65
- switch ( type ) {
70
+
71
+ var execFn = function ( ) {
72
+ exec ( cmd , function ( error , stdout , stderr ) {
73
+ switch ( cmd ) {
66
74
case 'grunt test:client' :
67
75
expect ( stdout , 'Client tests failed \n' + stdout ) . to . contain ( 'Executed 1 of 1\u001b[32m SUCCESS\u001b' ) ;
68
76
break ;
@@ -78,7 +86,13 @@ describe('angular-fullstack generator', function () {
78
86
79
87
cb ( ) ;
80
88
} ) ;
81
- } ) ;
89
+ } ;
90
+
91
+ if ( endpoint ) {
92
+ generatorTest ( 'endpoint' , endpoint , { } , execFn ) ;
93
+ } else {
94
+ gen . run ( { } , execFn ) ;
95
+ }
82
96
}
83
97
84
98
function genFiles ( ops ) {
@@ -206,10 +220,9 @@ describe('angular-fullstack generator', function () {
206
220
}
207
221
208
222
if ( ops . oauth ) {
209
- var oauth = ops . oauth ;
210
- for ( var i = 0 , oauthLength = oauth . length ; i < oauthLength ; i ++ ) {
211
- files = files . concat ( oauthFiles ( oauth [ i ] . replace ( 'Auth' , '' ) ) ) ;
212
- }
223
+ ops . oauth . forEach ( function ( type , i ) {
224
+ files = files . concat ( oauthFiles ( type . replace ( 'Auth' , '' ) ) ) ;
225
+ } ) ;
213
226
}
214
227
215
228
if ( ops . socketio ) {
@@ -224,11 +237,10 @@ describe('angular-fullstack generator', function () {
224
237
return files ;
225
238
}
226
239
227
- function everyFile ( files , ops ) {
228
- ops = ops || {
229
- skip : [ 'node_modules' , 'client/bower_components' , 'e2e' ]
230
- }
231
- }
240
+
241
+ /**
242
+ * Generator tests
243
+ */
232
244
233
245
beforeEach ( function ( done ) {
234
246
this . timeout ( 10000 ) ;
@@ -269,22 +281,28 @@ describe('angular-fullstack generator', function () {
269
281
runTest ( 'grunt test:client' , this , done ) ;
270
282
} ) ;
271
283
272
- it ( 'should pass jshint ' , function ( done ) {
284
+ it ( 'should pass lint ' , function ( done ) {
273
285
runTest ( 'grunt jshint' , this , done ) ;
274
286
} ) ;
275
287
276
288
it ( 'should run server tests successfully' , function ( done ) {
277
289
runTest ( 'grunt test:server' , this , done ) ;
278
290
} ) ;
279
291
292
+ it ( 'should pass lint with generated endpoint' , function ( done ) {
293
+ runTest ( 'grunt jshint' , this , done , 'foo' ) ;
294
+ } ) ;
295
+
280
296
it ( 'should run server tests successfully with generated endpoint' , function ( done ) {
281
- this . timeout ( 60000 ) ;
282
- generatorTest ( 'endpoint' , 'foo' , { } , function ( ) {
283
- exec ( 'grunt test:server' , function ( error , stdout , stderr ) {
284
- expect ( stdout , 'Server tests failed (do you have mongoDB running?) \n' + stdout ) . to . contain ( 'Done, without errors.' ) ;
285
- done ( ) ;
286
- } ) ;
287
- } ) ;
297
+ runTest ( 'grunt test:server' , this , done , 'foo' ) ;
298
+ } ) ;
299
+
300
+ it ( 'should pass lint with generated capitalized endpoint' , function ( done ) {
301
+ runTest ( 'grunt jshint' , this , done , 'Foo' ) ;
302
+ } ) ;
303
+
304
+ it ( 'should run server tests successfully with generated capitalized endpoint' , function ( done ) {
305
+ runTest ( 'grunt test:server' , this , done , 'Foo' ) ;
288
306
} ) ;
289
307
290
308
it ( 'should use existing config if available' , function ( done ) {
@@ -358,14 +376,22 @@ describe('angular-fullstack generator', function () {
358
376
runTest ( 'grunt test:client' , this , done ) ;
359
377
} ) ;
360
378
361
- it ( 'should pass jshint ' , function ( done ) {
379
+ it ( 'should pass lint ' , function ( done ) {
362
380
runTest ( 'grunt jshint' , this , done ) ;
363
381
} ) ;
364
382
365
383
it ( 'should run server tests successfully' , function ( done ) {
366
384
runTest ( 'grunt test:server' , this , done ) ;
367
385
} ) ;
368
386
387
+ it ( 'should pass lint with generated snake-case endpoint' , function ( done ) {
388
+ runTest ( 'grunt jshint' , this , done , 'foo-bar' ) ;
389
+ } ) ;
390
+
391
+ it ( 'should run server tests successfully with generated snake-case endpoint' , function ( done ) {
392
+ runTest ( 'grunt test:server' , this , done , 'foo-bar' ) ;
393
+ } ) ;
394
+
369
395
it ( 'should generate expected files' , function ( done ) {
370
396
gen . run ( { } , function ( ) {
371
397
helpers . assertFile ( genFiles ( testOptions ) ) ;
@@ -403,14 +429,22 @@ describe('angular-fullstack generator', function () {
403
429
runTest ( 'grunt test:client' , this , done ) ;
404
430
} ) ;
405
431
406
- it ( 'should pass jshint ' , function ( done ) {
432
+ it ( 'should pass lint ' , function ( done ) {
407
433
runTest ( 'grunt jshint' , this , done ) ;
408
434
} ) ;
409
435
410
436
it ( 'should run server tests successfully' , function ( done ) {
411
437
runTest ( 'grunt test:server' , this , done ) ;
412
438
} ) ;
413
439
440
+ it ( 'should pass lint with generated endpoint' , function ( done ) {
441
+ runTest ( 'grunt jshint' , this , done , 'foo' ) ;
442
+ } ) ;
443
+
444
+ it ( 'should run server tests successfully with generated endpoint' , function ( done ) {
445
+ runTest ( 'grunt test:server' , this , done , 'foo' ) ;
446
+ } ) ;
447
+
414
448
it ( 'should generate expected files' , function ( done ) {
415
449
gen . run ( { } , function ( ) {
416
450
helpers . assertFile ( genFiles ( testOptions ) ) ;
@@ -448,7 +482,7 @@ describe('angular-fullstack generator', function () {
448
482
runTest ( 'grunt test:client' , this , done ) ;
449
483
} ) ;
450
484
451
- it ( 'should pass jshint ' , function ( done ) {
485
+ it ( 'should pass lint ' , function ( done ) {
452
486
runTest ( 'grunt jshint' , this , done ) ;
453
487
} ) ;
454
488
0 commit comments