aboutsummaryrefslogtreecommitdiff
path: root/internal/export/export_test.go
blob: 5adf7d42f94c4a8ae233fa4ba03e9c765a65f99b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package export

import (
	"bytes"
	"strings"
	"testing"

	"github.com/lukaszkasprzak/lectio/internal/liturgy"
)

// sampleSecs builds a reading section the offline way: the English-canonical
// lookup reference lives in Ref, the display citation stays in the reader's
// sigla dialect. render.GatherVersion resolves Ref against a real embedded
// corpus, so the exported document carries actual verse text.
func sampleSecs() []liturgy.Section {
	return []liturgy.Section{{
		Heading:  "Ewangelia",
		Citation: "J 20, 1. 11-18",
		Ref:      "John 20:1,11-18",
		PartID:   "ewangelia",
	}}
}

func TestMarkdownAndText(t *testing.T) {
	info := liturgy.DayInfo{Name: "Środa XV tygodnia", Colour: "green"}
	// vul -> Vulgate Latin verse text, versified ("20:1  Una autem sabbati,
	// Maria Magdalene ...").
	md := Markdown("2026-07-22", info, sampleSecs(), "vul", "new", "en")
	if !strings.Contains(md, "# Środa") || !strings.Contains(md, "## Gospel") ||
		!strings.Contains(md, "20:1") || !strings.Contains(md, "Maria Magdalene") {
		t.Errorf("markdown:\n%s", md)
	}
	txt := Text("2026-07-22", info, sampleSecs(), "vul", "new", "en")
	if !strings.Contains(txt, "Maria Magdalene") || !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(), "vul", "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))
	}
}