All files / src/app/extensions/recently/store recently-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 45 46 471x 1x 1x 1x 1x   1x 1x 1x     1x 1x   1x       1x     1x                     1x                 1x   5x      
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 { RecentlyState } from './recently-store';
import { RecentlyEffects } from './recently/recently.effects';
import { recentlyReducer } from './recently/recently.reducer';
 
const recentlyReducers: ActionReducerMap<RecentlyState> = {
  _recently: recentlyReducer,
};
 
const recentlyEffects = [RecentlyEffects];
 
@Injectable()
export class DefaultRecentlyStoreConfig implements StoreConfig<RecentlyState> {
  metaReducers = [
    dataRetentionMeta<RecentlyState>(this.dataRetention.recently, this.appBaseHref, 'recently', '_recently'),
  ];
 
  constructor(
    @Inject(APP_BASE_HREF) private appBaseHref: string,
    @Inject(DATA_RETENTION_POLICY) private dataRetention: InjectSingle<typeof DATA_RETENTION_POLICY>
  ) {}
}
 
export const RECENTLY_STORE_CONFIG = new InjectionToken<StoreConfig<RecentlyState>>('recentlyStoreConfig');
 
@NgModule({
  imports: [
    EffectsModule.forFeature(recentlyEffects),
    StoreModule.forFeature('recently', recentlyReducers, RECENTLY_STORE_CONFIG),
  ],
  providers: [{ provide: RECENTLY_STORE_CONFIG, useClass: DefaultRecentlyStoreConfig }],
})
export class RecentlyStoreModule {
  static forTesting(...reducers: (keyof ActionReducerMap<RecentlyState>)[]) {
    return StoreModule.forFeature('recently', pick(recentlyReducers, reducers));
  }
}