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

100% Statements 15/15
100% Branches 0/0
100% Functions 5/5
100% Lines 12/12

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  21x 21x     21x 21x   21x   21x   21x   21x 7x   11x     21x 7x  
import { Dictionary } from '@ngrx/entity';
import { createSelector, createSelectorFactory, resultMemoize } from '@ngrx/store';
import { isEqual } from 'lodash-es';
 
import { ContentPageletEntryPoint } from 'ish-core/models/content-pagelet-entry-point/content-pagelet-entry-point.model';
import { createContentPageletEntryPointView } from 'ish-core/models/content-view/content-view.model';
import { getContentState } from 'ish-core/store/content/content-store';
 
import { includesAdapter } from './includes.reducer';
 
const getIncludesState = createSelector(getContentState, state => state.includes);
 
const { selectEntities: getContentIncludeEntities } = includesAdapter.getSelectors(getIncludesState);
 
const getContentIncludeMemoized = (includeId: string) =>
  createSelectorFactory<object, ContentPageletEntryPoint>(projector => resultMemoize(projector, isEqual))(
    getContentIncludeEntities,
    (contentIncludes: Dictionary<ContentPageletEntryPoint>) => contentIncludes[includeId]
  );
 
export const getContentInclude = (includeId: string) =>
  createSelector(getContentIncludeMemoized(includeId), createContentPageletEntryPointView);