@@ -92,32 +92,41 @@ describe('find-module', () => {
92
92
options = { name : 'foo' } ;
93
93
} ) ;
94
94
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 ' ) ;
97
97
options . module = 'app.module.ts' ;
98
98
options . path = '/projects/my-proj/src' ;
99
99
const modPath = findModuleFromOptions ( tree , options ) as string ;
100
100
expect ( modPath ) . toEqual ( '/projects/my-proj/src/app.module.ts' ) ;
101
101
} ) ;
102
102
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
+
103
112
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 ' ) ;
105
114
options . path = '/projects/my-proj/src' ;
106
115
options . name = 'feature_module/new_component' ;
107
116
const modPath = findModuleFromOptions ( tree , options ) as string ;
108
117
expect ( modPath ) . toEqual ( '/projects/my-proj/src/feature_module/app_test.module.ts' ) ;
109
118
} ) ;
110
119
111
120
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 ' ) ;
113
122
options . path = '/projects/my-proj/src' ;
114
123
options . name = 'featureModule/newComponent' ;
115
124
const modPath = findModuleFromOptions ( tree , options ) as string ;
116
125
expect ( modPath ) . toEqual ( '/projects/my-proj/src/featureModule/appTest.module.ts' ) ;
117
126
} ) ;
118
127
119
128
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 ' ) ;
121
130
options . path = '/projects/my-proj/src' ;
122
131
options . flat = true ;
123
132
options . name = '/module/directive' ;
@@ -126,7 +135,7 @@ describe('find-module', () => {
126
135
} ) ;
127
136
128
137
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 ' ) ;
130
139
options . name = 'other/test' ;
131
140
options . module = 'admin/foo' ;
132
141
options . path = '/projects/my-proj/src' ;
@@ -135,7 +144,7 @@ describe('find-module', () => {
135
144
} ) ;
136
145
137
146
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 ' ) ;
139
148
options . name = 'admin/hello' ;
140
149
options . module = 'foo' ;
141
150
options . path = '/projects/my-proj/src' ;
@@ -144,7 +153,7 @@ describe('find-module', () => {
144
153
} ) ;
145
154
146
155
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 ' ) ;
148
157
options . module = 'app' ;
149
158
options . path = '/projects/my-proj/src' ;
150
159
options . moduleExt = '_module.ts' ;
@@ -164,7 +173,7 @@ describe('find-module', () => {
164
173
} ) ;
165
174
166
175
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 ' ) ;
168
177
options . path = '/projects/my-proj/src' ;
169
178
options . moduleExt = '_module.ts' ;
170
179
let modPath ;
0 commit comments