summaryrefslogtreecommitdiff
path: root/internal/export/export_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-24 16:50:45 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-24 16:50:45 +0200
commit29e244c48222278c2f255ff2adf45e3af7c9f895 (patch)
treeafa11818de1d8115eee1777f7bfc70757f218ac7 /internal/export/export_test.go
parent102bf0c522c94d36f8363c38711621fe5ad18555 (diff)
downloadlectio-29e244c48222278c2f255ff2adf45e3af7c9f895.tar.gz
lectio-29e244c48222278c2f255ff2adf45e3af7c9f895.zip
export: internal/export (Markdown/Text/ReadingsPDF via pure-Go go-pdf/fpdf + embedded DejaVu Sans, covers pl/la/gr); cli --md/--pdf/--out; web /export + download links; v0.22.0
Diffstat (limited to 'internal/export/export_test.go')
-rw-r--r--internal/export/export_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/internal/export/export_test.go b/internal/export/export_test.go
new file mode 100644
index 0000000..7f1c68d
--- /dev/null
+++ b/internal/export/export_test.go
@@ -0,0 +1,41 @@
+package export
+
+import (
+ "bytes"
+ "strings"
+ "testing"
+
+ "github.com/lukaszkasprzak/lectio/internal/liturgy"
+)
+
+func sampleSecs() []liturgy.Section {
+ return []liturgy.Section{{
+ Heading: "Ewangelia (Mt 13, 1-9)",
+ Citation: "Mt 13, 1-9",
+ PartID: "ewangelia",
+ Paragraphs: [][]string{{"Owego dnia Jezus wyszedł z domu i usiadł nad jeziorem."}},
+ }}
+}
+
+func TestMarkdownAndText(t *testing.T) {
+ info := liturgy.DayInfo{Name: "Środa XV tygodnia", Colour: "green"}
+ md := Markdown("2026-07-22", info, sampleSecs(), "bt", "new", "en")
+ if !strings.Contains(md, "# Środa") || !strings.Contains(md, "## Gospel") || !strings.Contains(md, "Jezus wyszedł") {
+ t.Errorf("markdown:\n%s", md)
+ }
+ txt := Text("2026-07-22", info, sampleSecs(), "bt", "new", "en")
+ if !strings.Contains(txt, "Jezus wyszedł") || !strings.Contains(txt, "Gospel") {
+ t.Errorf("text:\n%s", txt)
+ }
+}
+
+func TestReadingsPDF(t *testing.T) {
+ info := liturgy.DayInfo{Name: "Środa XV tygodnia"}
+ pdf, err := ReadingsPDF("2026-07-22", info, sampleSecs(), "bt", "new", "en")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(pdf) < 1000 || !bytes.HasPrefix(pdf, []byte("%PDF")) {
+ t.Errorf("bad pdf len=%d", len(pdf))
+ }
+}