aboutsummaryrefslogtreecommitdiff
path: root/internal/render/render_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-23 13:33:11 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-23 13:33:11 +0200
commitcb1f49117d15b9690b46f344c0d6777e558b9021 (patch)
tree9a5e618ba198fcf8376944bc9630298ce75a2263 /internal/render/render_test.go
parent0351f4f188207d0204e1e0124d32127e820e33d5 (diff)
downloadlectio-cb1f49117d15b9690b46f344c0d6777e558b9021.tar.gz
lectio-cb1f49117d15b9690b46f344c0d6777e558b9021.zip
render: gather versions + compare + dedup
Diffstat (limited to 'internal/render/render_test.go')
-rw-r--r--internal/render/render_test.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/internal/render/render_test.go b/internal/render/render_test.go
new file mode 100644
index 0000000..87f9ed2
--- /dev/null
+++ b/internal/render/render_test.go
@@ -0,0 +1,53 @@
+package render
+
+import (
+ "strings"
+ "testing"
+
+ "github.com/lukaszkasprzak/lectio/internal/liturgy"
+)
+
+func TestGatherPLDedup(t *testing.T) {
+ sec := liturgy.Section{
+ Heading: "Psalm (Ps 1)",
+ Paragraphs: [][]string{{"stanza one"}, {"refrain"}, {"stanza two"}, {"refrain"}},
+ }
+ _, blocks := GatherVersion("pl", sec, "new")
+ n := 0
+ for _, b := range blocks {
+ if b == "refrain" {
+ n++
+ }
+ }
+ if n != 1 {
+ t.Errorf("refrain appears %d times, want 1 (deduped)", n)
+ }
+}
+
+func TestGatherBible(t *testing.T) {
+ sec := liturgy.Section{Heading: "Ewangelia (J 20, 1. 11-18)"}
+ label, blocks := GatherVersion("wuj", sec, "new")
+ if !strings.Contains(label, "Wujek") {
+ t.Errorf("label = %q", label)
+ }
+ if len(blocks) == 0 || !strings.HasPrefix(blocks[0], "20:1") {
+ t.Errorf("first block = %q", blocks)
+ }
+}
+
+func TestGatherTraditional(t *testing.T) {
+ sec := liturgy.Section{Citation: "Luke 7:36-50"}
+ _, blocks := GatherVersion("vul", sec, "traditional")
+ if len(blocks) == 0 || !strings.HasPrefix(blocks[0], "7:36") {
+ t.Errorf("first block = %q", blocks)
+ }
+}
+
+func TestOfflineVersions(t *testing.T) {
+ got := OfflineVersions([]string{"pl", "wuj", "vul"})
+ for _, v := range got {
+ if v == "pl" {
+ t.Error("pl not dropped offline")
+ }
+ }
+}