All files order-items.js

90.91% Statements 10/11
87.5% Branches 7/8
100% Functions 1/1
90.91% Lines 10/11
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    1x               1x 12x 2x     10x 10x   10x       10x 2x     8x      
 
export default function (items) {
  const sortMap = {
    template: 0,
    page: 1,
    container: 2,
    feature: 3,
    widget: 4,
  };
 
  return items.sort((itemA, itemB) => {
    if (itemA.type === itemB.type) {
      return 0;
    }
 
    const sortA = sortMap[itemA.type];
    const sortB = sortMap[itemB.type];
 
    Iif (typeof sortA === 'undefined') {
      return -1;
    }
 
    if (typeof sortB === 'undefined') {
      return 1;
    }
 
    return (sortA < sortB) ? -1 : 1;
  });
}