All files / src/pipes rides-summary.pipe.js

100% Statements 8/8
100% Branches 6/6
100% Functions 2/2
100% Lines 7/7

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          3x 3x 3x 2x   3x 2x   3x    
/**
 * @param {RideOrder} order
 * @return {string}
 */
export function ridesSummary(order) {
  let shortDescription = '';
  let people = 'people';
  if (order.ride.minHeight) {
    shortDescription = ` (>= ${order.people.reduce((acc, person) => (acc.height < person.height ? acc : person)).height} cm)`;
  }
  if (order.people.length === 1) {
    people = 'person';
  }
  return `${order.people.length} ${people} ${shortDescription} for the ${order.ride.name}, have fun!`;
}