All files / lib/packages/shared-utils action-type.ts

90% Statements 9/10
90% Branches 9/10
75% Functions 3/4
88.88% Lines 8/9

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 24 25 26 27 28 29 30 31 32 33 34 35 36 37  1068x   59x   674x   180x   46x       109x                                       54x 27x    
export function formatActionType(actionType: string | undefined): string {
  switch (actionType) {
    case undefined:
      return "-- --";
    case "New":
      return "Initial";
    case "Amend":
      return "Amendment";
    case "Renew":
      return "Renewal";
    case "Extend":
      return "Temporary Extension Request";
    default:
      return actionType;
  }
}
 
/**
 * Formats an action type to include the word "waiver" where necessary.
 *
 * This function ensures that the word "waiver" is included in the formatted action type.
 * The placement of "waiver" depends on the specific type:
 * - If the action type is `"Initial"` or `"New"`, it returns `"Initial Waiver"`.
 * - Otherwise, it prepends `"Waiver"` to the formatted action type.
 *
 * This function is designed to work with both unformatted and preformatted action types.
 * `formatActionType` will return the input string if it doesn't match known cases.
 *
 * @param {string} actionType - The action type to format.
 * @returns {string} The formatted action type including "waiver" where applicable.
 */
 
export function formatActionTypeWithWaiver(actionType: string): string {
  if (actionType === "Initial" || actionType === "New") return "Initial Waiver";
  return `Waiver ${formatActionType(actionType)}`;
}