File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
modules/schematics/src/store Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -215,4 +215,27 @@ describe('Store Schematic', () => {
215
215
) ;
216
216
expect ( content ) . toMatch ( / e x p o r t i n t e r f a c e F e a t u r e S t a t e { / ) ;
217
217
} ) ;
218
+
219
+ it ( 'should fail if a feature state name is not specified' , ( ) => {
220
+ const options = {
221
+ ...defaultOptions ,
222
+ name : undefined ,
223
+ root : false ,
224
+ } ;
225
+
226
+ expect ( ( ) => {
227
+ schematicRunner . runSchematic ( 'store' , options , appTree ) ;
228
+ } ) . toThrowError ( 'Please provide a name for the feature state' ) ;
229
+ } ) ;
230
+
231
+ it ( 'should pass if a root state name is not specified' , ( ) => {
232
+ const options = {
233
+ ...defaultOptions ,
234
+ name : undefined ,
235
+ } ;
236
+
237
+ expect ( ( ) => {
238
+ schematicRunner . runSchematic ( 'store' , options , appTree ) ;
239
+ } ) . not . toThrow ( ) ;
240
+ } ) ;
218
241
} ) ;
Original file line number Diff line number Diff line change @@ -131,9 +131,13 @@ function addImportToNgModule(options: StoreOptions): Rule {
131
131
132
132
export default function ( options : StoreOptions ) : Rule {
133
133
return ( host : Tree , context : SchematicContext ) => {
134
+ if ( ! options . name && ! options . root ) {
135
+ throw new Error ( `Please provide a name for the feature state` ) ;
136
+ }
137
+
134
138
options . path = getProjectPath ( host , options ) ;
135
139
136
- const parsedPath = parseName ( options . path , options . name ) ;
140
+ const parsedPath = parseName ( options . path , options . name || '' ) ;
137
141
options . name = parsedPath . name ;
138
142
options . path = parsedPath . path ;
139
143
You can’t perform that action at this time.
0 commit comments