32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
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 = '<!DOCTYPE html><html><head><title>x</title></head><body>hi</body></html>'
|
|
const css = 'body{color:#000}'
|
|
const js = 'console.log(1)'
|
|
const assets: Record<string, Uint8Array> = {
|
|
'assets/a1.png': new Uint8Array([1,2,3]),
|
|
'assets/b2.svg': textEncoder.encode('<svg></svg>'),
|
|
}
|
|
|
|
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('<title>x</title>')
|
|
})
|
|
})
|