File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
modules/schematics/src/container Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -263,4 +263,18 @@ describe('Container Schematic', () => {
263
263
/ i m p o r t { F o o C o m p o n e n t } f r o m ' .\/ f o o \/ f o o .c o m p o n e n t /
264
264
) ;
265
265
} ) ;
266
+
267
+ it ( 'should respect the state option if not provided' , ( ) => {
268
+ const options = { ...defaultOptions , state : undefined } ;
269
+ const tree = schematicRunner . runSchematic ( 'container' , options , appTree ) ;
270
+ const content = getFileContent ( tree , '/src/app/foo/foo.component.ts' ) ;
271
+ expect ( content ) . not . toMatch ( / i m p o r t \* a s f r o m S t o r e / ) ;
272
+ } ) ;
273
+
274
+ it ( 'should import the state path if provided' , ( ) => {
275
+ const options = { ...defaultOptions , state : 'reducers' } ;
276
+ const tree = schematicRunner . runSchematic ( 'container' , options , appTree ) ;
277
+ const content = getFileContent ( tree , '/src/app/foo/foo.component.ts' ) ;
278
+ expect ( content ) . toMatch ( / i m p o r t \* a s f r o m S t o r e f r o m ' ..\/ r e d u c e r s ' ; / ) ;
279
+ } ) ;
266
280
} ) ;
Original file line number Diff line number Diff line change @@ -123,13 +123,18 @@ export default function(options: ContainerOptions): Rule {
123
123
options . path = options . path ? normalize ( options . path ) : options . path ;
124
124
options . module = findModuleFromOptions ( host , options ) ;
125
125
126
- const statePath = `/${ options . sourceDir } /${ options . path } /${ options . state } ` ;
127
126
const componentPath =
128
127
`/${ options . sourceDir } /${ options . path } /` +
129
128
( options . flat ? '' : stringUtils . dasherize ( options . name ) + '/' ) +
130
129
stringUtils . dasherize ( options . name ) +
131
130
'.component' ;
132
- options . state = buildRelativePath ( componentPath , statePath ) ;
131
+
132
+ if ( options . state ) {
133
+ const statePath = `/${ options . sourceDir } /${ options . path } /${
134
+ options . state
135
+ } `;
136
+ options . state = buildRelativePath ( componentPath , statePath ) ;
137
+ }
133
138
134
139
const templateSource = apply ( url ( './files' ) , [
135
140
options . spec ? noop ( ) : filter ( path => ! path . endsWith ( '__spec.ts' ) ) ,
You can’t perform that action at this time.
0 commit comments