All files / src/app/extensions/compare/store compare-store.module.ts

85% Statements 17/20
50% Branches 2/4
50% Functions 1/2
84.21% Lines 16/19

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 453x 3x 3x 3x 3x   3x 3x 3x     3x 3x   3x       3x     3x                 3x                 3x   10x      
import { APP_BASE_HREF } from '@angular/common';
import { Inject, Injectable, InjectionToken, NgModule } from '@angular/core';
import { EffectsModule } from '@ngrx/effects';
import { ActionReducerMap, StoreConfig, StoreModule } from '@ngrx/store';
import { pick } from 'lodash-es';
 
import { DATA_RETENTION_POLICY } from 'ish-core/configurations/injection-keys';
import { InjectSingle } from 'ish-core/utils/injection';
import { dataRetentionMeta } from 'ish-core/utils/meta-reducers';
 
import { CompareState } from './compare-store';
import { CompareEffects } from './compare/compare.effects';
import { compareReducer } from './compare/compare.reducer';
 
const compareReducers: ActionReducerMap<CompareState> = {
  _compare: compareReducer,
};
 
const compareEffects = [CompareEffects];
 
@Injectable()
export class DefaultCompareStoreConfig implements StoreConfig<CompareState> {
  metaReducers = [dataRetentionMeta<CompareState>(this.dataRetention.compare, this.appBaseHref, 'compare', '_compare')];
 
  constructor(
    @Inject(APP_BASE_HREF) private appBaseHref: string,
    @Inject(DATA_RETENTION_POLICY) private dataRetention: InjectSingle<typeof DATA_RETENTION_POLICY>
  ) {}
}
 
export const COMPARE_STORE_CONFIG = new InjectionToken<StoreConfig<CompareState>>('compareStoreConfig');
 
@NgModule({
  imports: [
    EffectsModule.forFeature(compareEffects),
    StoreModule.forFeature('compare', compareReducers, COMPARE_STORE_CONFIG),
  ],
  providers: [{ provide: COMPARE_STORE_CONFIG, useClass: DefaultCompareStoreConfig }],
})
export class CompareStoreModule {
  static forTesting(...reducers: (keyof ActionReducerMap<CompareState>)[]) {
    return StoreModule.forFeature('compare', pick(compareReducers, reducers));
  }
}