@@ -39,13 +39,16 @@ describe('angular-fullstack generator', function () {
3939 path = path || './' ;
4040 skip = skip || [ 'e2e' , 'node_modules' , 'client/bower_components' ] ;
4141
42- recursiveReadDir ( path , skip , function ( err , files ) {
42+ recursiveReadDir ( path , skip , function ( err , actualFiles ) {
4343 if ( err ) { return done ( err ) ; }
44+ var files = actualFiles . concat ( ) ;
4445
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+ } ) ;
4952
5053 if ( files . length !== 0 ) {
5154 err = new Error ( 'unexpected files found' ) ;
@@ -58,11 +61,16 @@ describe('angular-fullstack generator', function () {
5861 } ) ;
5962 }
6063
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+
6269 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 ) {
6674 case 'grunt test:client' :
6775 expect ( stdout , 'Client tests failed \n' + stdout ) . to . contain ( 'Executed 1 of 1\u001b[32m SUCCESS\u001b' ) ;
6876 break ;
@@ -78,7 +86,13 @@ describe('angular-fullstack generator', function () {
7886
7987 cb ( ) ;
8088 } ) ;
81- } ) ;
89+ } ;
90+
91+ if ( endpoint ) {
92+ generatorTest ( 'endpoint' , endpoint , { } , execFn ) ;
93+ } else {
94+ gen . run ( { } , execFn ) ;
95+ }
8296 }
8397
8498 function genFiles ( ops ) {
@@ -206,10 +220,9 @@ describe('angular-fullstack generator', function () {
206220 }
207221
208222 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+ } ) ;
213226 }
214227
215228 if ( ops . socketio ) {
@@ -224,11 +237,10 @@ describe('angular-fullstack generator', function () {
224237 return files ;
225238 }
226239
227- function everyFile ( files , ops ) {
228- ops = ops || {
229- skip : [ 'node_modules' , 'client/bower_components' , 'e2e' ]
230- }
231- }
240+
241+ /**
242+ * Generator tests
243+ */
232244
233245 beforeEach ( function ( done ) {
234246 this . timeout ( 10000 ) ;
@@ -269,22 +281,28 @@ describe('angular-fullstack generator', function () {
269281 runTest ( 'grunt test:client' , this , done ) ;
270282 } ) ;
271283
272- it ( 'should pass jshint ' , function ( done ) {
284+ it ( 'should pass lint ' , function ( done ) {
273285 runTest ( 'grunt jshint' , this , done ) ;
274286 } ) ;
275287
276288 it ( 'should run server tests successfully' , function ( done ) {
277289 runTest ( 'grunt test:server' , this , done ) ;
278290 } ) ;
279291
292+ it ( 'should pass lint with generated endpoint' , function ( done ) {
293+ runTest ( 'grunt jshint' , this , done , 'foo' ) ;
294+ } ) ;
295+
280296 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' ) ;
288306 } ) ;
289307
290308 it ( 'should use existing config if available' , function ( done ) {
@@ -358,14 +376,22 @@ describe('angular-fullstack generator', function () {
358376 runTest ( 'grunt test:client' , this , done ) ;
359377 } ) ;
360378
361- it ( 'should pass jshint ' , function ( done ) {
379+ it ( 'should pass lint ' , function ( done ) {
362380 runTest ( 'grunt jshint' , this , done ) ;
363381 } ) ;
364382
365383 it ( 'should run server tests successfully' , function ( done ) {
366384 runTest ( 'grunt test:server' , this , done ) ;
367385 } ) ;
368386
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+
369395 it ( 'should generate expected files' , function ( done ) {
370396 gen . run ( { } , function ( ) {
371397 helpers . assertFile ( genFiles ( testOptions ) ) ;
@@ -403,14 +429,22 @@ describe('angular-fullstack generator', function () {
403429 runTest ( 'grunt test:client' , this , done ) ;
404430 } ) ;
405431
406- it ( 'should pass jshint ' , function ( done ) {
432+ it ( 'should pass lint ' , function ( done ) {
407433 runTest ( 'grunt jshint' , this , done ) ;
408434 } ) ;
409435
410436 it ( 'should run server tests successfully' , function ( done ) {
411437 runTest ( 'grunt test:server' , this , done ) ;
412438 } ) ;
413439
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+
414448 it ( 'should generate expected files' , function ( done ) {
415449 gen . run ( { } , function ( ) {
416450 helpers . assertFile ( genFiles ( testOptions ) ) ;
@@ -448,7 +482,7 @@ describe('angular-fullstack generator', function () {
448482 runTest ( 'grunt test:client' , this , done ) ;
449483 } ) ;
450484
451- it ( 'should pass jshint ' , function ( done ) {
485+ it ( 'should pass lint ' , function ( done ) {
452486 runTest ( 'grunt jshint' , this , done ) ;
453487 } ) ;
454488
0 commit comments