import { pickAttachmentPreviewKind } from '../attachment_kind' describe('pickAttachmentPreviewKind', () => { describe('with a usable MIME type', () => { it.each([ ['image/png', 'image'], ['image/jpeg', 'image'], ['video/mp4', 'video'], ['video/quicktime', 'video'], ['application/pdf', 'file'], ['text/plain', 'file'], ['application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'file'], ['', 'file'], [undefined, 'file'], ])('classifies %p as %p', (input, expected) => { expect(pickAttachmentPreviewKind(input)).toBe(expected) }) }) // Document picker providers sometimes drop the MIME type. Without an // extension-based fallback, octet-stream-typed images and videos would // render as generic file tiles even though the bytes are decodable. describe('with an unhelpful MIME type', () => { it.each([ ['application/octet-stream', 'IMG_1234.HEIC', 'image'], ['application/octet-stream', 'photo.jpg', 'image'], ['application/octet-stream', 'clip.mov', 'video'], ['application/octet-stream', 'movie.MP4', 'video'], ['application/octet-stream', 'spreadsheet.xlsx', 'file'], [undefined, 'photo.png', 'image'], ['application/octet-stream', undefined, 'file'], ['application/octet-stream', 'no_extension', 'file'], ])('with type %p and name %p classifies as %p', (type, name, expected) => { expect(pickAttachmentPreviewKind(type, name)).toBe(expected) }) }) })