All files / utils file-type.ts

100% Statements 4/4
50% Branches 1/2
100% Functions 1/1
100% Lines 4/4

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    3x           14x 14x 14x    
export type FilePreviewType = "pdf" | "image" | "video" | "audio";
 
const MIME_CATEGORY_MAP: Partial<Record<string, FilePreviewType>> = {
  image: "image",
  video: "video",
  audio: "audio",
};
 
export function getFilePreviewType(file: File): FilePreviewType {
  const category = file.type.split("/")[0];
  return MIME_CATEGORY_MAP[category] ?? "pdf";
}