import { downscaleImage } from './image-downscale' function file(name: string, type: string, bytes = 100) { return new File([new Uint8Array(bytes)], name, { type }) } describe('downscaleImage (best-effort, jsdom has no canvas/createImageBitmap)', () => { it('returns non-image files untouched', async () => { const f = file('deck.pdf', 'application/pdf') expect(await downscaleImage(f)).toBe(f) }) it('returns GIFs untouched (may be animated)', async () => { const f = file('anim.gif', 'image/gif') expect(await downscaleImage(f)).toBe(f) }) it('returns SVGs untouched (vector)', async () => { const f = file('logo.svg', 'image/svg+xml') expect(await downscaleImage(f)).toBe(f) }) it('falls back to the original image when the environment cannot rasterize', async () => { // In jsdom createImageBitmap is undefined → best-effort returns original. const f = file('photo.png', 'image/png', 5_000_000) expect(await downscaleImage(f)).toBe(f) }) })