import Testing
@testable import IPhotoSync

@Suite("PhotosLibraryReader unit tests")
struct ReaderTests {

    // MARK: mimeType(fromExtension:)

    @Test("mimeType returns correct MIME for common image extensions")
    func mimeTypeImages() {
        #expect(PhotosLibraryReader.mimeType(fromExtension: "jpg") == "image/jpeg")
        #expect(PhotosLibraryReader.mimeType(fromExtension: "jpeg") == "image/jpeg")
        #expect(PhotosLibraryReader.mimeType(fromExtension: "JPEG") == "image/jpeg")
        #expect(PhotosLibraryReader.mimeType(fromExtension: "png") == "image/png")
        #expect(PhotosLibraryReader.mimeType(fromExtension: "heic") == "image/heic")
        #expect(PhotosLibraryReader.mimeType(fromExtension: "heif") == "image/heic")
        #expect(PhotosLibraryReader.mimeType(fromExtension: "gif") == "image/gif")
        #expect(PhotosLibraryReader.mimeType(fromExtension: "tiff") == "image/tiff")
        #expect(PhotosLibraryReader.mimeType(fromExtension: "tif") == "image/tiff")
        #expect(PhotosLibraryReader.mimeType(fromExtension: "dng") == "image/x-adobe-dng")
    }

    @Test("mimeType returns correct MIME for video extensions")
    func mimeTypeVideos() {
        #expect(PhotosLibraryReader.mimeType(fromExtension: "mov") == "video/quicktime")
        #expect(PhotosLibraryReader.mimeType(fromExtension: "mp4") == "video/mp4")
        #expect(PhotosLibraryReader.mimeType(fromExtension: "m4v") == "video/mp4")
        #expect(PhotosLibraryReader.mimeType(fromExtension: "avi") == "video/avi")
    }

    @Test("mimeType falls back to octet-stream for unknown extensions")
    func mimeTypeFallback() {
        #expect(PhotosLibraryReader.mimeType(fromExtension: "xyz") == "application/octet-stream")
        #expect(PhotosLibraryReader.mimeType(fromExtension: "") == "application/octet-stream")
    }
}
