Files
xk-hy-transit-go/internal/hyfile/pdf_test.go
2026-05-22 08:06:07 +08:00

22 lines
486 B
Go

package hyfile
import (
"bytes"
"testing"
)
func TestHtmlToPDF(t *testing.T) {
if testing.Short() {
t.Skip("skipping chromedp integration test in short mode")
}
html := `<!DOCTYPE html><html><head><meta charset="utf-8"></head><body><p>test</p></body></html>`
pdf, err := HtmlToPDF(html)
if err != nil {
t.Skipf("chromedp not available: %v", err)
}
if len(pdf) < 4 || !bytes.HasPrefix(pdf, []byte("%PDF")) {
t.Fatalf("expected PDF header, got %d bytes", len(pdf))
}
}