mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-09 23:20:04 +00:00
feat: support video file drag-drop and paste (#9154)
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { hasAudioType, hasImageType } from './eventUtils'
|
||||
import {
|
||||
hasAudioType,
|
||||
hasImageType,
|
||||
hasVideoType,
|
||||
isMediaFile
|
||||
} from './eventUtils'
|
||||
|
||||
describe('hasImageType', () => {
|
||||
it('should return true for image types', () => {
|
||||
@@ -24,3 +29,28 @@ describe('hasAudioType', () => {
|
||||
expect(hasAudioType({ type: 'video/mp4' } as File)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('hasVideoType', () => {
|
||||
it('should return true for video types', () => {
|
||||
expect(hasVideoType({ type: 'video/mp4' } as File)).toBe(true)
|
||||
expect(hasVideoType({ type: 'video/webm' } as File)).toBe(true)
|
||||
})
|
||||
|
||||
it('should return false for non-video types', () => {
|
||||
expect(hasVideoType({ type: 'audio/mpeg' } as File)).toBe(false)
|
||||
expect(hasVideoType({ type: 'image/png' } as File)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('isMediaFile', () => {
|
||||
it('should return true for image, audio, and video types', () => {
|
||||
expect(isMediaFile({ type: 'image/png' } as File)).toBe(true)
|
||||
expect(isMediaFile({ type: 'audio/mpeg' } as File)).toBe(true)
|
||||
expect(isMediaFile({ type: 'video/mp4' } as File)).toBe(true)
|
||||
})
|
||||
|
||||
it('should return false for non-media types', () => {
|
||||
expect(isMediaFile({ type: 'text/plain' } as File)).toBe(false)
|
||||
expect(isMediaFile({ type: 'application/json' } as File)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -32,3 +32,11 @@ export function hasImageType({ type }: File): boolean {
|
||||
export function hasAudioType({ type }: File): boolean {
|
||||
return type.startsWith('audio')
|
||||
}
|
||||
|
||||
export function hasVideoType({ type }: File): boolean {
|
||||
return type.startsWith('video')
|
||||
}
|
||||
|
||||
export function isMediaFile(file: File): boolean {
|
||||
return hasImageType(file) || hasAudioType(file) || hasVideoType(file)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user