import { describe, it, expect } from 'vitest' import { AssetManager } from '@/lib/assets/assetManager' import { buildAssetsIndex } from '@/lib/exporter/assets.index' function u8(n: number): Uint8Array { const a = new Uint8Array(n); for (let i=0;i { it('groups assets by mime into images/fonts/other and lists zipPath', async () => { const am = new AssetManager({ maxBytes: 1024*1024, allowedExts: ['png','woff2','txt'] }) await am.add({ name: 'a.png', type: 'image/png', bytes: u8(4) }) await am.add({ name: 'b.woff2', type: 'font/woff2', bytes: u8(6) }) await am.add({ name: 'c.txt', type: 'text/plain', bytes: u8(2) }) const bytes = buildAssetsIndex(am) const obj = JSON.parse(new TextDecoder().decode(bytes)) as { images: string[]; fonts: string[]; other: string[] } expect(obj.images.length).toBe(1) expect(obj.fonts.length).toBe(1) expect(obj.other.length).toBe(1) expect(obj.images[0]).toMatch(/^assets\/[0-9a-f]{8}\.png$/) expect(obj.fonts[0]).toMatch(/^assets\/[0-9a-f]{8}\.woff2$/) expect(obj.other[0]).toMatch(/^assets\/[0-9a-f]{8}\.txt$/) }) })