File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
modules/schematics/src/store Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -238,4 +238,14 @@ describe('Store Schematic', () => {
238
238
schematicRunner . runSchematic ( 'store' , options , appTree ) ;
239
239
} ) . not . toThrow ( ) ;
240
240
} ) ;
241
+
242
+ it ( 'should add store runtime checks' , ( ) => {
243
+ const options = { ...defaultOptions , module : 'app.module.ts' } ;
244
+
245
+ const tree = schematicRunner . runSchematic ( 'store' , options , appTree ) ;
246
+ const content = tree . readContent ( `${ projectPath } /src/app/app.module.ts` ) ;
247
+ expect ( content ) . toMatch ( / , r u n t i m e C h e c k s : { / ) ;
248
+ expect ( content ) . toMatch ( / s t r i c t S t a t e I m m u t a b i l i t y : t r u e , / ) ;
249
+ expect ( content ) . toMatch ( / s t r i c t A c t i o n I m m u t a b i l i t y : t r u e / ) ;
250
+ } ) ;
241
251
} ) ;
Original file line number Diff line number Diff line change @@ -61,11 +61,16 @@ function addImportToNgModule(options: StoreOptions): Rule {
61
61
`${ options . path } /environments/environment`
62
62
) ;
63
63
64
+ const runtimeChecks = `runtimeChecks: {
65
+ strictStateImmutability: true,
66
+ strictActionImmutability: true,
67
+ }` ;
68
+
64
69
const storeNgModuleImport = addImportToModule (
65
70
source ,
66
71
modulePath ,
67
72
options . root
68
- ? `StoreModule.forRoot(reducers, { metaReducers })`
73
+ ? `StoreModule.forRoot(reducers, { metaReducers, ${ runtimeChecks } })`
69
74
: `StoreModule.forFeature('${ stringUtils . camelize (
70
75
options . name
71
76
) } ', from${ stringUtils . classify (
You can’t perform that action at this time.
0 commit comments