From 1f784ad44cf13169cc789d46c0836bc0c5656cec Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Fri, 21 Oct 2022 12:10:16 +0200 Subject: [PATCH] chore(chromium): add test without custom header/footer templates --- pkg/modules/chromium/chromium_test.go | 43 ++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/pkg/modules/chromium/chromium_test.go b/pkg/modules/chromium/chromium_test.go index 20394f78..60c38361 100644 --- a/pkg/modules/chromium/chromium_test.go +++ b/pkg/modules/chromium/chromium_test.go @@ -435,7 +435,7 @@ func TestChromium_PDF(t *testing.T) { expectErr: true, }, { - name: "with a lot of options", + name: "with a lot of properties", timeout: time.Duration(60) * time.Second, URL: "file:///tests/test/testdata/chromium/html/sample4/index.html", userAgent: "foo", @@ -487,6 +487,47 @@ func TestChromium_PDF(t *testing.T) { }(), }, }, + { + name: "with custom header template only", + timeout: time.Duration(60) * time.Second, + URL: "file:///tests/test/testdata/chromium/html/sample4/index.html", + options: Options{ + HeaderTemplate: func() string { + b, err := os.ReadFile("/tests/test/testdata/chromium/url/sample2/header.html") + if err != nil { + t.Fatalf("expected no error but got: %v", err) + } + + return string(b) + }(), + FooterTemplate: DefaultOptions().FooterTemplate, + }, + }, + { + name: "with custom footer template only", + timeout: time.Duration(60) * time.Second, + URL: "file:///tests/test/testdata/chromium/html/sample4/index.html", + options: Options{ + HeaderTemplate: DefaultOptions().HeaderTemplate, + FooterTemplate: func() string { + b, err := os.ReadFile("/tests/test/testdata/chromium/url/sample2/footer.html") + if err != nil { + t.Fatalf("expected no error but got: %v", err) + } + + return string(b) + }(), + }, + }, + { + name: "without custom header and footer templates", + timeout: time.Duration(60) * time.Second, + URL: "file:///tests/test/testdata/chromium/html/sample4/index.html", + options: Options{ + HeaderTemplate: DefaultOptions().HeaderTemplate, + FooterTemplate: DefaultOptions().FooterTemplate, + }, + }, { name: "with file using a .gif", timeout: time.Duration(60) * time.Second,