mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-09 15:10:17 +00:00
feat: audio drag-drop and paste support (#9152)
This commit is contained in:
26
src/utils/eventUtils.test.ts
Normal file
26
src/utils/eventUtils.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { hasAudioType, hasImageType } from './eventUtils'
|
||||
|
||||
describe('hasImageType', () => {
|
||||
it('should return true for image types', () => {
|
||||
expect(hasImageType({ type: 'image/png' } as File)).toBe(true)
|
||||
expect(hasImageType({ type: 'image/jpeg' } as File)).toBe(true)
|
||||
})
|
||||
|
||||
it('should return false for non-image types', () => {
|
||||
expect(hasImageType({ type: 'audio/mpeg' } as File)).toBe(false)
|
||||
expect(hasImageType({ type: 'video/mp4' } as File)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('hasAudioType', () => {
|
||||
it('should return true for audio types', () => {
|
||||
expect(hasAudioType({ type: 'audio/mpeg' } as File)).toBe(true)
|
||||
expect(hasAudioType({ type: 'audio/wav' } as File)).toBe(true)
|
||||
})
|
||||
|
||||
it('should return false for non-audio types', () => {
|
||||
expect(hasAudioType({ type: 'image/png' } as File)).toBe(false)
|
||||
expect(hasAudioType({ type: 'video/mp4' } as File)).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -28,3 +28,7 @@ export async function extractFilesFromDragEvent(
|
||||
export function hasImageType({ type }: File): boolean {
|
||||
return type.startsWith('image')
|
||||
}
|
||||
|
||||
export function hasAudioType({ type }: File): boolean {
|
||||
return type.startsWith('audio')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user