All files / src/app/core/utils/dev test-data-utils.ts

100% Statements 14/14
100% Branches 2/2
100% Functions 4/4
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 2119x   19x     19x 148x 148x 321x   9x     19x 20x 20x 60x   2x    
import { CategoryTree, CategoryTreeHelper } from 'ish-core/models/category-tree/category-tree.model';
import { Category } from 'ish-core/models/category/category.model';
import { ContentPageTreeHelper } from 'ish-core/models/content-page-tree/content-page-tree.helper';
import { ContentPageTree, ContentPageTreeElement } from 'ish-core/models/content-page-tree/content-page-tree.model';
 
export function categoryTree(categories?: Category[]): CategoryTree {
  const tree = CategoryTreeHelper.empty();
  if (categories) {
    return categories.reduce((acc, cat) => CategoryTreeHelper.add(acc, cat), tree);
  }
  return tree;
}
 
export function pageTree(elements?: ContentPageTreeElement[]): ContentPageTree {
  const tree = ContentPageTreeHelper.empty();
  if (elements) {
    return elements.reduce((acc, cat) => ContentPageTreeHelper.add(acc, cat), tree);
  }
  return tree;
}