32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { exportPage, type ExportOptions } from '@/lib/exporter/html'
|
|
import { pageSchema, type Page } from '@/lib/schema/page'
|
|
|
|
function makePage(): Page {
|
|
return pageSchema.parse({
|
|
title: 'Img Perf',
|
|
locale: 'en',
|
|
theme: { primaryColor: '#2563eb', fontFamily: 'Inter' },
|
|
sections: [ { type: 'hero', props: { heading: 'Hello', subheading: 'World', imageUrl: 'https://img/h.png' } } ],
|
|
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
|
|
seo: { title: 't', description: 'd' },
|
|
})
|
|
}
|
|
|
|
describe('이미지 loading/decoding 토글', () => {
|
|
it('기본은 loading="lazy", decoding="async"', () => {
|
|
const page = makePage()
|
|
const out = exportPage(page)
|
|
expect(out.html).toContain('loading="lazy"')
|
|
expect(out.html).toContain('decoding="async"')
|
|
})
|
|
|
|
it('옵션으로 eager/sync로 바꿀 수 있다', () => {
|
|
const page = makePage()
|
|
const opts: ExportOptions = { imageLoading: 'eager', imageDecoding: 'sync' }
|
|
const out = exportPage(page, opts)
|
|
expect(out.html).toContain('loading="eager"')
|
|
expect(out.html).toContain('decoding="sync"')
|
|
})
|
|
})
|