All files / src/app/core/store/content content-store.module.ts

100% Statements 25/25
100% Branches 0/0
100% Functions 2/2
100% Lines 23/23

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 518x 8x 8x 8x   8x     8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x   8x                 8x     8x 2x     8x                 8x   36x      
import { Injectable, InjectionToken, NgModule } from '@angular/core';
import { EffectsModule } from '@ngrx/effects';
import { ActionReducerMap, StoreConfig, StoreModule } from '@ngrx/store';
import { pick } from 'lodash-es';
 
import { resetOnLogoutMeta } from 'ish-core/utils/meta-reducers';
 
import { ContentState } from './content-store';
import { IncludesEffects } from './includes/includes.effects';
import { includesReducer } from './includes/includes.reducer';
import { PageTreeEffects } from './page-tree/page-tree.effects';
import { pageTreeReducer } from './page-tree/page-tree.reducer';
import { pageletsReducer } from './pagelets/pagelets.reducer';
import { PagesEffects } from './pages/pages.effects';
import { pagesReducer } from './pages/pages.reducer';
import { ParametersEffects } from './parameters/parameters.effects';
import { parametersReducer } from './parameters/parameters.reducer';
import { ViewcontextsEffects } from './viewcontexts/viewcontexts.effects';
import { viewcontextsReducer } from './viewcontexts/viewcontexts.reducer';
 
const contentReducers: ActionReducerMap<ContentState> = {
  includes: includesReducer,
  pagelets: pageletsReducer,
  pages: pagesReducer,
  viewcontexts: viewcontextsReducer,
  pagetree: pageTreeReducer,
  parameters: parametersReducer,
};
 
const contentEffects = [IncludesEffects, PagesEffects, ViewcontextsEffects, PageTreeEffects, ParametersEffects];
 
@Injectable()
export class ContentStoreConfig implements StoreConfig<ContentState> {
  metaReducers = [resetOnLogoutMeta];
}
 
export const CONTENT_STORE_CONFIG = new InjectionToken<StoreConfig<ContentState>>('contentStoreConfig');
 
@NgModule({
  imports: [
    EffectsModule.forFeature(contentEffects),
    StoreModule.forFeature('content', contentReducers, CONTENT_STORE_CONFIG),
  ],
  providers: [{ provide: CONTENT_STORE_CONFIG, useClass: ContentStoreConfig }],
})
export class ContentStoreModule {
  static forTesting(...reducers: (keyof ActionReducerMap<ContentState>)[]) {
    return StoreModule.forFeature('content', pick(contentReducers, reducers));
  }
}