All files / src/components/UploadFile/Rebranded utils.ts

100% Statements 5/5
100% Branches 9/9
100% Functions 1/1
100% Lines 5/5

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    59x                     168x 168x   168x       168x        
import { bytesToSize } from "@utils/index";
 
export const getCustomUploadFileText = ({
  maxFiles,
  maxSizeInBytes,
  supportedFormatText,
  multiple,
}: {
  maxFiles?: number;
  multiple?: boolean;
  maxSizeInBytes: number;
  supportedFormatText: string;
}): string => {
  const sizeString = bytesToSize(maxSizeInBytes).sizeString;
  const isMultiple = multiple || (maxFiles && maxFiles > 1);
 
  const fileText = maxFiles
    ? `Max. ${maxFiles} file${maxFiles > 1 ? "s" : ""}, `
    : "Up to ";
 
  return `${fileText} ${sizeString} ${
    isMultiple ? "each " : ""
  }(${supportedFormatText})`;
};