isPreviewSupported.test.ts 583 B

12345678910111213141516171819202122
  1. import { describe, expect, it } from 'vitest'
  2. import isPreviewSupported from './isPreviewSupported.ts'
  3. describe('isPreviewSupported', () => {
  4. it('should return true for any filetypes that browsers can preview', () => {
  5. const supported = [
  6. 'image/jpeg',
  7. 'image/gif',
  8. 'image/png',
  9. 'image/svg',
  10. 'image/svg+xml',
  11. 'image/bmp',
  12. 'image/jpg',
  13. 'image/webp',
  14. 'image/avif',
  15. ]
  16. supported.forEach((ext) => {
  17. expect(isPreviewSupported(ext)).toEqual(true)
  18. })
  19. expect(isPreviewSupported('foo')).toEqual(false)
  20. })
  21. })