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

81.81% Statements 9/11
100% Branches 0/0
33.33% Functions 1/3
81.81% Lines 9/11

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 2126x 26x     26x 26x 26x       26x   26x   26x   5x        
import { EntityState, createEntityAdapter } from '@ngrx/entity';
import { createReducer, on } from '@ngrx/store';
 
import { ContentPagelet } from 'ish-core/models/content-pagelet/content-pagelet.model';
import { loadContentIncludeSuccess } from 'ish-core/store/content/includes/includes.actions';
import { loadContentPageSuccess } from 'ish-core/store/content/pages/pages.actions';
import { loadViewContextEntrypointSuccess } from 'ish-core/store/content/viewcontexts/viewcontexts.actions';
 
export type PageletsState = EntityState<ContentPagelet>;
 
export const pageletsAdapter = createEntityAdapter<ContentPagelet>();
 
const initialState = pageletsAdapter.getInitialState();
 
export const pageletsReducer = createReducer(
  initialState,
  on(loadContentIncludeSuccess, (state, action) => pageletsAdapter.upsertMany(action.payload.pagelets, state)),
  on(loadContentPageSuccess, (state, action) => pageletsAdapter.upsertMany(action.payload.pagelets, state)),
  on(loadViewContextEntrypointSuccess, (state, action) => pageletsAdapter.upsertMany(action.payload.pagelets, state))
);