All files / src/app/core/store/content/includes includes.reducer.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 2/2
100% Lines 9/9

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 2626x 26x       26x   26x 22x         26x   26x     11x   11x          
import { EntityState, createEntityAdapter } from '@ngrx/entity';
import { createReducer, on } from '@ngrx/store';
 
import { ContentPageletEntryPoint } from 'ish-core/models/content-pagelet-entry-point/content-pagelet-entry-point.model';
 
import { loadContentIncludeSuccess } from './includes.actions';
 
export const includesAdapter = createEntityAdapter<ContentPageletEntryPoint>({
  selectId: contentInclude => contentInclude.id,
});
 
export type IncludesState = EntityState<ContentPageletEntryPoint>;
 
const initialState: IncludesState = includesAdapter.getInitialState({});
 
export const includesReducer = createReducer(
  initialState,
  on(loadContentIncludeSuccess, (state, action) => {
    const { include } = action.payload;
 
    return {
      ...includesAdapter.upsertOne(include, state),
    };
  })
);