28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { exportPage } from '@/lib/exporter/html'
|
|
import { pageSchema, type Page } from '@/lib/schema/page'
|
|
import { AssetManager } from '@/lib/assets/assetManager'
|
|
|
|
function makePage(): Page {
|
|
return pageSchema.parse({
|
|
title: 'Path Strategy',
|
|
locale: 'en',
|
|
theme: { primaryColor: '#2563eb', fontFamily: 'Inter' },
|
|
sections: [ { type: 'hero', props: { heading: 'Hello', subheading: 'World', imageUrl: 'local:hero.png' } } ],
|
|
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
|
|
seo: { title: 't', description: 'd' },
|
|
})
|
|
}
|
|
|
|
describe('자산 경로 구조 옵션', () => {
|
|
it('grouped 전략일 때 이미지가 assets/images/ 경로로 렌더된다', async () => {
|
|
const page = makePage()
|
|
const am = new AssetManager({ maxBytes: 1024 * 1024, allowedExts: ['png'], pathStrategy: 'grouped' })
|
|
// add hero image asset
|
|
const bytes = new Uint8Array([1,2,3,4,5])
|
|
await am.add({ name: 'hero.png', type: 'image/png', bytes })
|
|
const out = exportPage(page, { assetManager: am })
|
|
expect(out.html).toMatch(/assets\/images\/[a-f0-9]{8}\.png/i)
|
|
})
|
|
})
|