@@ -92,32 +92,41 @@ describe('find-module', () => {
9292 options = { name : 'foo' } ;
9393 } ) ;
9494
95- it ( 'should find a module' , ( ) => {
96- tree . create ( '/projects/my-proj/src/app.module.ts' , '' ) ;
95+ it ( 'should find a module with a decorator ' , ( ) => {
96+ tree . create ( '/projects/my-proj/src/app.module.ts' , '@NgModule ' ) ;
9797 options . module = 'app.module.ts' ;
9898 options . path = '/projects/my-proj/src' ;
9999 const modPath = findModuleFromOptions ( tree , options ) as string ;
100100 expect ( modPath ) . toEqual ( '/projects/my-proj/src/app.module.ts' ) ;
101101 } ) ;
102102
103+ it ( 'should not find module-like file without a decorator' , ( ) => {
104+ tree . create ( '/projects/my-proj/src/app.module.ts' , '' ) ;
105+ options . module = 'app.module.ts' ;
106+ options . path = '/projects/my-proj/src' ;
107+ expect ( ( ) => findModuleFromOptions ( tree , options ) as string ) . toThrowError (
108+ / S p e c i f i e d m o d u l e ' a p p .m o d u l e .t s ' d o e s n o t e x i s t / ,
109+ ) ;
110+ } ) ;
111+
103112 it ( 'should find a module when name has underscore' , ( ) => {
104- tree . create ( '/projects/my-proj/src/feature_module/app_test.module.ts' , '' ) ;
113+ tree . create ( '/projects/my-proj/src/feature_module/app_test.module.ts' , '@NgModule ' ) ;
105114 options . path = '/projects/my-proj/src' ;
106115 options . name = 'feature_module/new_component' ;
107116 const modPath = findModuleFromOptions ( tree , options ) as string ;
108117 expect ( modPath ) . toEqual ( '/projects/my-proj/src/feature_module/app_test.module.ts' ) ;
109118 } ) ;
110119
111120 it ( 'should find a module when name has uppercase' , ( ) => {
112- tree . create ( '/projects/my-proj/src/featureModule/appTest.module.ts' , '' ) ;
121+ tree . create ( '/projects/my-proj/src/featureModule/appTest.module.ts' , '@NgModule ' ) ;
113122 options . path = '/projects/my-proj/src' ;
114123 options . name = 'featureModule/newComponent' ;
115124 const modPath = findModuleFromOptions ( tree , options ) as string ;
116125 expect ( modPath ) . toEqual ( '/projects/my-proj/src/featureModule/appTest.module.ts' ) ;
117126 } ) ;
118127
119128 it ( 'should find a module if flat is true' , ( ) => {
120- tree . create ( '/projects/my-proj/src/module/app_test.module.ts' , '' ) ;
129+ tree . create ( '/projects/my-proj/src/module/app_test.module.ts' , '@NgModule ' ) ;
121130 options . path = '/projects/my-proj/src' ;
122131 options . flat = true ;
123132 options . name = '/module/directive' ;
@@ -126,7 +135,7 @@ describe('find-module', () => {
126135 } ) ;
127136
128137 it ( 'should find a module in a sub dir' , ( ) => {
129- tree . create ( '/projects/my-proj/src/admin/foo.module.ts' , '' ) ;
138+ tree . create ( '/projects/my-proj/src/admin/foo.module.ts' , '@NgModule ' ) ;
130139 options . name = 'other/test' ;
131140 options . module = 'admin/foo' ;
132141 options . path = '/projects/my-proj/src' ;
@@ -135,7 +144,7 @@ describe('find-module', () => {
135144 } ) ;
136145
137146 it ( 'should find a module in a sub dir (2)' , ( ) => {
138- tree . create ( '/projects/my-proj/src/admin/foo.module.ts' , '' ) ;
147+ tree . create ( '/projects/my-proj/src/admin/foo.module.ts' , '@NgModule ' ) ;
139148 options . name = 'admin/hello' ;
140149 options . module = 'foo' ;
141150 options . path = '/projects/my-proj/src' ;
@@ -144,7 +153,7 @@ describe('find-module', () => {
144153 } ) ;
145154
146155 it ( 'should find a module using custom ext' , ( ) => {
147- tree . create ( '/projects/my-proj/src/app_module.ts' , '' ) ;
156+ tree . create ( '/projects/my-proj/src/app_module.ts' , '@NgModule ' ) ;
148157 options . module = 'app' ;
149158 options . path = '/projects/my-proj/src' ;
150159 options . moduleExt = '_module.ts' ;
@@ -164,7 +173,7 @@ describe('find-module', () => {
164173 } ) ;
165174
166175 it ( 'should ignore custom ext if module or ${module}.ts exists' , ( ) => {
167- tree . create ( '/projects/my-proj/src/app.module.ts' , '' ) ;
176+ tree . create ( '/projects/my-proj/src/app.module.ts' , '@NgModule ' ) ;
168177 options . path = '/projects/my-proj/src' ;
169178 options . moduleExt = '_module.ts' ;
170179 let modPath ;
0 commit comments