mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-27 11:29:53 +00:00
36 lines
1012 B
TypeScript
36 lines
1012 B
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
|
|
import { useMediaCache } from '../../../src/services/mediaCacheService'
|
|
|
|
// Mock fetch
|
|
global.fetch = vi.fn()
|
|
global.URL = {
|
|
createObjectURL: vi.fn(() => 'blob:mock-url'),
|
|
revokeObjectURL: vi.fn()
|
|
} as any
|
|
|
|
describe('mediaCacheService', () => {
|
|
describe('URL reference counting', () => {
|
|
it('should handle URL acquisition for non-existent cache entry', () => {
|
|
const { acquireUrl } = useMediaCache()
|
|
|
|
const url = acquireUrl('non-existent.jpg')
|
|
expect(url).toBeUndefined()
|
|
})
|
|
|
|
it('should handle URL release for non-existent cache entry', () => {
|
|
const { releaseUrl } = useMediaCache()
|
|
|
|
// Should not throw error
|
|
expect(() => releaseUrl('non-existent.jpg')).not.toThrow()
|
|
})
|
|
|
|
it('should provide acquireUrl and releaseUrl methods', () => {
|
|
const cache = useMediaCache()
|
|
|
|
expect(typeof cache.acquireUrl).toBe('function')
|
|
expect(typeof cache.releaseUrl).toBe('function')
|
|
})
|
|
})
|
|
})
|