@@ -19,7 +19,7 @@ describe('Application Factory', () => {
1919 . runSchematicAsync ( 'application' , options )
2020 . toPromise ( ) ;
2121 const files : string [ ] = tree . files ;
22- expect ( files ) . toEqual ( [
22+ expect ( files . sort ( ) ) . toEqual ( [
2323 '/project/.eslintrc.js' ,
2424 '/project/.gitignore' ,
2525 '/project/.prettierrc' ,
@@ -35,7 +35,7 @@ describe('Application Factory', () => {
3535 '/project/src/main.ts' ,
3636 '/project/test/app.e2e-spec.ts' ,
3737 '/project/test/jest-e2e.json' ,
38- ] ) ;
38+ ] . sort ( ) ) ;
3939
4040 expect (
4141 JSON . parse ( tree . readContent ( '/project/package.json' ) ) ,
@@ -51,7 +51,7 @@ describe('Application Factory', () => {
5151 . runSchematicAsync ( 'application' , options )
5252 . toPromise ( ) ;
5353 const files : string [ ] = tree . files ;
54- expect ( files ) . toEqual ( [
54+ expect ( files . sort ( ) ) . toEqual ( [
5555 `/project.foo.bar/.eslintrc.js` ,
5656 `/project.foo.bar/.gitignore` ,
5757 `/project.foo.bar/.prettierrc` ,
@@ -67,7 +67,7 @@ describe('Application Factory', () => {
6767 `/project.foo.bar/src/main.ts` ,
6868 `/project.foo.bar/test/app.e2e-spec.ts` ,
6969 `/project.foo.bar/test/jest-e2e.json` ,
70- ] ) ;
70+ ] . sort ( ) ) ;
7171
7272 expect (
7373 JSON . parse ( tree . readContent ( '/project.foo.bar/package.json' ) ) ,
@@ -83,7 +83,7 @@ describe('Application Factory', () => {
8383 . runSchematicAsync ( 'application' , options )
8484 . toPromise ( ) ;
8585 const files : string [ ] = tree . files ;
86- expect ( files ) . toEqual ( [
86+ expect ( files . sort ( ) ) . toEqual ( [
8787 '/awesome-project/.eslintrc.js' ,
8888 '/awesome-project/.gitignore' ,
8989 '/awesome-project/.prettierrc' ,
@@ -99,7 +99,7 @@ describe('Application Factory', () => {
9999 '/awesome-project/src/main.ts' ,
100100 '/awesome-project/test/app.e2e-spec.ts' ,
101101 '/awesome-project/test/jest-e2e.json' ,
102- ] ) ;
102+ ] . sort ( ) ) ;
103103
104104 expect (
105105 JSON . parse ( tree . readContent ( '/awesome-project/package.json' ) ) ,
@@ -115,7 +115,7 @@ describe('Application Factory', () => {
115115 . runSchematicAsync ( 'application' , options )
116116 . toPromise ( ) ;
117117 const files : string [ ] = tree . files ;
118- expect ( files ) . toEqual ( [
118+ expect ( files . sort ( ) ) . toEqual ( [
119119 '/_awesome-project/.eslintrc.js' ,
120120 '/_awesome-project/.gitignore' ,
121121 '/_awesome-project/.prettierrc' ,
@@ -131,7 +131,7 @@ describe('Application Factory', () => {
131131 '/_awesome-project/src/main.ts' ,
132132 '/_awesome-project/test/app.e2e-spec.ts' ,
133133 '/_awesome-project/test/jest-e2e.json' ,
134- ] ) ;
134+ ] . sort ( ) ) ;
135135
136136 expect (
137137 JSON . parse ( tree . readContent ( '/_awesome-project/package.json' ) ) ,
@@ -147,7 +147,7 @@ describe('Application Factory', () => {
147147 . runSchematicAsync ( 'application' , options )
148148 . toPromise ( ) ;
149149 const files : string [ ] = tree . files ;
150- expect ( files ) . toEqual ( [
150+ expect ( files . sort ( ) ) . toEqual ( [
151151 '/@/package/.eslintrc.js' ,
152152 '/@/package/.gitignore' ,
153153 '/@/package/.prettierrc' ,
@@ -163,7 +163,7 @@ describe('Application Factory', () => {
163163 '/@/package/src/main.ts' ,
164164 '/@/package/test/app.e2e-spec.ts' ,
165165 '/@/package/test/jest-e2e.json' ,
166- ] ) ;
166+ ] . sort ( ) ) ;
167167
168168 expect (
169169 JSON . parse ( tree . readContent ( '/@/package/package.json' ) ) ,
@@ -179,7 +179,7 @@ describe('Application Factory', () => {
179179 . runSchematicAsync ( 'application' , options )
180180 . toPromise ( ) ;
181181 const files : string [ ] = tree . files ;
182- expect ( files ) . toEqual ( [
182+ expect ( files . sort ( ) ) . toEqual ( [
183183 '/.eslintrc.js' ,
184184 '/.gitignore' ,
185185 '/.prettierrc' ,
@@ -195,7 +195,7 @@ describe('Application Factory', () => {
195195 '/src/main.ts' ,
196196 '/test/app.e2e-spec.ts' ,
197197 '/test/jest-e2e.json' ,
198- ] ) ;
198+ ] . sort ( ) ) ;
199199
200200 expect ( JSON . parse ( tree . readContent ( '/package.json' ) ) ) . toMatchObject ( {
201201 name : path . basename ( process . cwd ( ) ) ,
@@ -211,7 +211,7 @@ describe('Application Factory', () => {
211211 . runSchematicAsync ( 'application' , options )
212212 . toPromise ( ) ;
213213 const files : string [ ] = tree . files ;
214- expect ( files ) . toEqual ( [
214+ expect ( files . sort ( ) ) . toEqual ( [
215215 '/@scope/package/.eslintrc.js' ,
216216 '/@scope/package/.gitignore' ,
217217 '/@scope/package/.prettierrc' ,
@@ -227,7 +227,7 @@ describe('Application Factory', () => {
227227 '/@scope/package/src/main.ts' ,
228228 '/@scope/package/test/app.e2e-spec.ts' ,
229229 '/@scope/package/test/jest-e2e.json' ,
230- ] ) ;
230+ ] . sort ( ) ) ;
231231
232232 expect (
233233 JSON . parse ( tree . readContent ( '/@scope/package/package.json' ) ) ,
@@ -243,7 +243,7 @@ describe('Application Factory', () => {
243243 . runSchematicAsync ( 'application' , options )
244244 . toPromise ( ) ;
245245 const files : string [ ] = tree . files ;
246- expect ( files ) . toEqual ( [
246+ expect ( files . sort ( ) ) . toEqual ( [
247247 '/@-/package/.eslintrc.js' ,
248248 '/@-/package/.gitignore' ,
249249 '/@-/package/.prettierrc' ,
@@ -259,7 +259,7 @@ describe('Application Factory', () => {
259259 '/@-/package/src/main.ts' ,
260260 '/@-/package/test/app.e2e-spec.ts' ,
261261 '/@-/package/test/jest-e2e.json' ,
262- ] ) ;
262+ ] . sort ( ) ) ;
263263
264264 expect (
265265 JSON . parse ( tree . readContent ( '/@-/package/package.json' ) ) ,
@@ -278,7 +278,7 @@ describe('Application Factory', () => {
278278 . runSchematicAsync ( 'application' , options )
279279 . toPromise ( ) ;
280280 const files : string [ ] = tree . files ;
281- expect ( files ) . toEqual ( [
281+ expect ( files . sort ( ) ) . toEqual ( [
282282 '/123/.eslintrc.js' ,
283283 '/123/.gitignore' ,
284284 '/123/.prettierrc' ,
@@ -294,7 +294,7 @@ describe('Application Factory', () => {
294294 '/123/src/main.ts' ,
295295 '/123/test/app.e2e-spec.ts' ,
296296 '/123/test/jest-e2e.json' ,
297- ] ) ;
297+ ] . sort ( ) ) ;
298298
299299 expect (
300300 JSON . parse ( tree . readContent ( '/123/package.json' ) ) ,
@@ -311,7 +311,7 @@ describe('Application Factory', () => {
311311 . runSchematicAsync ( 'application' , options )
312312 . toPromise ( ) ;
313313 const files : string [ ] = tree . files ;
314- expect ( files ) . toEqual ( [
314+ expect ( files . sort ( ) ) . toEqual ( [
315315 '/project/.babelrc' ,
316316 '/project/.gitignore' ,
317317 '/project/.prettierrc' ,
@@ -328,7 +328,7 @@ describe('Application Factory', () => {
328328 '/project/src/main.js' ,
329329 '/project/test/app.e2e-spec.js' ,
330330 '/project/test/jest-e2e.json' ,
331- ] ) ;
331+ ] . sort ( ) ) ;
332332
333333 expect ( JSON . parse ( tree . readContent ( '/project/package.json' ) ) ) . toMatchObject (
334334 {
@@ -345,7 +345,7 @@ describe('Application Factory', () => {
345345 . runSchematicAsync ( 'application' , options )
346346 . toPromise ( ) ;
347347 const files : string [ ] = tree . files ;
348- expect ( files ) . toEqual ( [
348+ expect ( files . sort ( ) ) . toEqual ( [
349349 '/app/.eslintrc.js' ,
350350 '/app/.gitignore' ,
351351 '/app/.prettierrc' ,
@@ -361,10 +361,94 @@ describe('Application Factory', () => {
361361 '/app/src/main.ts' ,
362362 '/app/test/app.e2e-spec.ts' ,
363363 '/app/test/jest-e2e.json' ,
364- ] ) ;
364+ ] . sort ( ) ) ;
365365
366366 expect ( JSON . parse ( tree . readContent ( '/app/package.json' ) ) ) . toMatchObject ( {
367367 name : 'project' ,
368368 } ) ;
369369 } ) ;
370+ it ( 'should not create a spec file' , async ( ) => {
371+ const options : ApplicationOptions = {
372+ name : 'project' ,
373+ spec : false ,
374+ language : 'js' ,
375+ } ;
376+ const tree : UnitTestTree = await runner
377+ . runSchematicAsync ( 'application' , options )
378+ . toPromise ( ) ;
379+ const files : string [ ] = tree . files ;
380+ expect ( files . sort ( ) ) . toEqual ( [
381+ '/project/.babelrc' ,
382+ '/project/.gitignore' ,
383+ '/project/.prettierrc' ,
384+ '/project/README.md' ,
385+ '/project/index.js' ,
386+ '/project/jsconfig.json' ,
387+ '/project/nest-cli.json' ,
388+ '/project/nodemon.json' ,
389+ '/project/package.json' ,
390+ '/project/src/app.controller.js' ,
391+ '/project/src/app.module.js' ,
392+ '/project/src/app.service.js' ,
393+ '/project/src/main.js' ,
394+ '/project/test/jest-e2e.json' ,
395+ ] . sort ( ) ) ;
396+ } ) ;
397+ it ( 'should create a spec file' , async ( ) => {
398+ const options : ApplicationOptions = {
399+ name : 'project' ,
400+ spec : true ,
401+ language : 'js' ,
402+ } ;
403+ const tree : UnitTestTree = await runner
404+ . runSchematicAsync ( 'application' , options )
405+ . toPromise ( ) ;
406+ const files : string [ ] = tree . files ;
407+ expect ( files . sort ( ) ) . toEqual ( [
408+ '/project/.babelrc' ,
409+ '/project/.gitignore' ,
410+ '/project/.prettierrc' ,
411+ '/project/README.md' ,
412+ '/project/index.js' ,
413+ '/project/jsconfig.json' ,
414+ '/project/nest-cli.json' ,
415+ '/project/nodemon.json' ,
416+ '/project/package.json' ,
417+ '/project/src/app.controller.js' ,
418+ '/project/src/app.controller.spec.js' ,
419+ '/project/src/app.module.js' ,
420+ '/project/src/app.service.js' ,
421+ '/project/src/main.js' ,
422+ '/project/test/app.e2e-spec.js' ,
423+ '/project/test/jest-e2e.json' ,
424+ ] . sort ( ) ) ;
425+ } ) ;
426+ it ( 'should create a spec file with custom file suffix' , async ( ) => {
427+ const options : ApplicationOptions = {
428+ name : 'project' ,
429+ spec : true ,
430+ specFileSuffix : 'test' ,
431+ } ;
432+ const tree : UnitTestTree = await runner
433+ . runSchematicAsync ( 'application' , options )
434+ . toPromise ( ) ;
435+ const files : string [ ] = tree . files ;
436+ expect ( files . sort ( ) ) . toEqual ( [
437+ '/project/.eslintrc.js' ,
438+ '/project/.gitignore' ,
439+ '/project/.prettierrc' ,
440+ '/project/README.md' ,
441+ '/project/nest-cli.json' ,
442+ '/project/package.json' ,
443+ '/project/tsconfig.build.json' ,
444+ '/project/tsconfig.json' ,
445+ '/project/src/app.controller.test.ts' ,
446+ '/project/src/app.controller.ts' ,
447+ '/project/src/app.module.ts' ,
448+ '/project/src/app.service.ts' ,
449+ '/project/src/main.ts' ,
450+ '/project/test/app.e2e-test.ts' ,
451+ '/project/test/jest-e2e.json' ,
452+ ] . sort ( ) ) ;
453+ } ) ;
370454} ) ;
0 commit comments