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

100% Statements 37/37
100% Branches 0/0
100% Functions 3/3
100% Lines 35/35

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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 8823x 23x 23x 23x   23x   23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x   23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x   23x                   23x                                     23x 15x     23x                 23x   401x                 12x      
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 { AddressesEffects } from './addresses/addresses.effects';
import { addressesReducer } from './addresses/addresses.reducer';
import { AuthorizationEffects } from './authorization/authorization.effects';
import { authorizationReducer } from './authorization/authorization.reducer';
import { BasketAddressesEffects } from './basket/basket-addresses.effects';
import { BasketItemsEffects } from './basket/basket-items.effects';
import { BasketPaymentEffects } from './basket/basket-payment.effects';
import { BasketPromotionCodeEffects } from './basket/basket-promotion-code.effects';
import { BasketValidationEffects } from './basket/basket-validation.effects';
import { BasketEffects } from './basket/basket.effects';
import { basketReducer } from './basket/basket.reducer';
import { CustomerState } from './customer-store';
import { DataRequestsEffects } from './data-requests/data-requests.effects';
import { dataRequestsReducer } from './data-requests/data-requests.reducer';
import { OrdersEffects } from './orders/orders.effects';
import { ordersReducer } from './orders/orders.reducer';
import { OrganizationManagementEffects } from './organization-management/organization-management.effects';
import { RequisitionManagementEffects } from './requisition-management/requisition-management.effects';
import { SsoRegistrationEffects } from './sso-registration/sso-registration.effects';
import { ssoRegistrationReducer } from './sso-registration/sso-registration.reducer';
import { UserNewsletterEffects } from './user/user-newsletter.effects';
import { UserEffects } from './user/user.effects';
import { userReducer } from './user/user.reducer';
 
const customerReducers: ActionReducerMap<CustomerState> = {
  user: userReducer,
  addresses: addressesReducer,
  orders: ordersReducer,
  basket: basketReducer,
  authorization: authorizationReducer,
  ssoRegistration: ssoRegistrationReducer,
  dataRequests: dataRequestsReducer,
};
 
const customerEffects = [
  AddressesEffects,
  BasketAddressesEffects,
  BasketEffects,
  BasketItemsEffects,
  BasketPaymentEffects,
  BasketPromotionCodeEffects,
  BasketValidationEffects,
  OrdersEffects,
  UserEffects,
  AuthorizationEffects,
  OrganizationManagementEffects,
  RequisitionManagementEffects,
  SsoRegistrationEffects,
  DataRequestsEffects,
  UserNewsletterEffects,
];
 
@Injectable()
export class CustomerStoreConfig implements StoreConfig<CustomerState> {
  metaReducers = [resetOnLogoutMeta];
}
 
export const CUSTOMER_STORE_CONFIG = new InjectionToken<StoreConfig<CustomerState>>('customerStoreConfig');
 
@NgModule({
  imports: [
    EffectsModule.forFeature(customerEffects),
    StoreModule.forFeature('_customer', customerReducers, CUSTOMER_STORE_CONFIG),
  ],
  providers: [{ provide: CUSTOMER_STORE_CONFIG, useClass: CustomerStoreConfig }],
})
export class CustomerStoreModule {
  static forTesting(...reducers: (keyof ActionReducerMap<CustomerState>)[]) {
    return StoreModule.forFeature('_customer', pick(customerReducers, reducers));
  }
 
  /**
   * Customer_STORE_CONFIG needs to be provided in test
   * @example
   * { provide: CUSTOMER_STORE_CONFIG, useClass: CustomerStoreConfig }
   */
  static forTestingWithMetaReducer(...reducers: (keyof ActionReducerMap<CustomerState>)[]) {
    return StoreModule.forFeature('_customer', pick(customerReducers, reducers), CUSTOMER_STORE_CONFIG);
  }
}