import { describe, it, expect } from 'vitest'
import JSZip from 'jszip'
import { buildZip } from '@/lib/exporter/zip'
const textEncoder = new TextEncoder()
describe('ZIP 유틸', () => {
it('index.html / styles.css / app.js 와 assets/* 를 포함한 ZIP을 생성한다', async () => {
const html = '
xhi'
const css = 'body{color:#000}'
const js = 'console.log(1)'
const assets: Record = {
'assets/a1.png': new Uint8Array([1,2,3]),
'assets/b2.svg': textEncoder.encode(''),
}
const zipBytes = await buildZip({ html, css, js, assets })
const zip = await JSZip.loadAsync(zipBytes)
const names = Object.keys(zip.files)
expect(names).toContain('index.html')
expect(names).toContain('styles.css')
expect(names).toContain('app.js')
expect(names).toContain('assets/a1.png')
expect(names).toContain('assets/b2.svg')
const htmlContent = await zip.files['index.html'].async('string')
expect(htmlContent).toContain('x')
})
})