import { describe, it, expect } from 'vitest'
import { getMimeType, VIDEO_MIME, AUDIO_MIME } from './mime'

describe('VIDEO_MIME', () => {
  it('has correct MIME types for all video formats', () => {
    expect(VIDEO_MIME.mp4).toBe('video/mp4')
    expect(VIDEO_MIME.webm).toBe('video/webm')
    expect(VIDEO_MIME.mkv).toBe('video/x-matroska')
    expect(VIDEO_MIME.avi).toBe('video/x-msvideo')
  })
})

describe('AUDIO_MIME', () => {
  it('has correct MIME types for all audio formats', () => {
    expect(AUDIO_MIME.mp3).toBe('audio/mpeg')
    expect(AUDIO_MIME.wav).toBe('audio/wav')
    expect(AUDIO_MIME.m4a).toBe('audio/mp4')
    expect(AUDIO_MIME.opus).toBe('audio/ogg')
  })
})

describe('getMimeType', () => {
  it('returns correct MIME type for video formats', () => {
    expect(getMimeType('video', 'mp4')).toBe('video/mp4')
    expect(getMimeType('video', 'webm')).toBe('video/webm')
    expect(getMimeType('video', 'mkv')).toBe('video/x-matroska')
    expect(getMimeType('video', 'avi')).toBe('video/x-msvideo')
  })

  it('returns correct MIME type for audio formats', () => {
    expect(getMimeType('audio', 'mp3')).toBe('audio/mpeg')
    expect(getMimeType('audio', 'wav')).toBe('audio/wav')
    expect(getMimeType('audio', 'm4a')).toBe('audio/mp4')
    expect(getMimeType('audio', 'opus')).toBe('audio/ogg')
  })

  it('returns fallback for unknown video format', () => {
    expect(getMimeType('video', 'unknown' as any)).toBe('application/octet-stream')
  })

  it('returns fallback for unknown audio format', () => {
    expect(getMimeType('audio', 'unknown' as any)).toBe('application/octet-stream')
  })

  it('handles audio format passed with video type gracefully', () => {
    expect(getMimeType('video', 'mp3')).toBe('application/octet-stream')
  })

  it('handles video format passed with audio type gracefully', () => {
    expect(getMimeType('audio', 'mp4')).toBe('application/octet-stream')
  })
})
