All files / lib feature-access.reducer.ts

100% Statements 5/5
100% Branches 0/0
100% Functions 4/4
100% Lines 5/5

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                  3x   13x   9x 4x               13x    
import { Injectable, Provider } from '@angular/core';
import { createReducer, on } from '@ngrx/store';
 
import { featureAccessAction } from './feature-access.actions';
import { featureAccessReducerConfig } from './feature-access.interface';
 
@Injectable({
  providedIn: 'root',
})
export class AppFeatureAccessReducer {
  public createReducer() {
    return createReducer(
      featureAccessReducerConfig.initialState,
      on(featureAccessAction.setEnvironment, (state, { payload }) => ({ ...state, environment: payload })),
      on(featureAccessAction.setFeatureFlags, (state, { payload }) => ({ ...state, featureFlags: payload })),
    );
  }
}
 
export const featureAccessReducerProvider: Provider = {
  provide: featureAccessReducerConfig.token,
  deps: [AppFeatureAccessReducer],
  useFactory: (reducer: AppFeatureAccessReducer) => reducer.createReducer(),
};