aboutsummaryrefslogtreecommitdiff
path: root/internal/web/render_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/web/render_test.go')
-rw-r--r--internal/web/render_test.go58
1 files changed, 56 insertions, 2 deletions
diff --git a/internal/web/render_test.go b/internal/web/render_test.go
index 7ee666a..974c6f1 100644
--- a/internal/web/render_test.go
+++ b/internal/web/render_test.go
@@ -11,7 +11,7 @@ import (
func TestRenderReadings(t *testing.T) {
secs := []liturgy.Section{{Heading: "Ewangelia (J 20, 1. 11-18)", PartID: "ewangelia"}}
- html := string(RenderReadings(secs, []string{"wuj"}, "new"))
+ html := string(RenderReadings(secs, []string{"wuj"}, "new", "horizontal"))
if !strings.Contains(html, "Ewangelia") || !strings.Contains(html, "class=") {
t.Errorf("reading pane missing heading/classes: %q", html[:min(200, len(html))])
}
@@ -45,7 +45,7 @@ func TestRenderReadingsEscapesScriptText(t *testing.T) {
PartID: "pierwsze_czytanie",
Paragraphs: [][]string{{"<script>alert(1)</script>"}},
}}
- html := string(RenderReadings(secs, []string{"pl"}, "new"))
+ html := string(RenderReadings(secs, []string{"pl"}, "new", "horizontal"))
if strings.Contains(html, "<script>alert(1)</script>") {
t.Errorf("raw <script> leaked into rendered output: %q", html)
}
@@ -54,6 +54,60 @@ func TestRenderReadingsEscapesScriptText(t *testing.T) {
}
}
+func TestRenderReadingsVertical(t *testing.T) {
+ secs := []liturgy.Section{{Heading: "Ewangelia (J 20, 1. 11-18)", PartID: "ewangelia"}}
+ html := string(RenderReadings(secs, []string{"wuj", "vul"}, "new", "vertical"))
+ if !strings.Contains(html, "display-vertical") {
+ t.Errorf("vertical output missing display-vertical container: %q", html[:min(300, len(html))])
+ }
+ if !strings.Contains(html, "vcol") {
+ t.Errorf("vertical output missing vcol columns: %q", html[:min(300, len(html))])
+ }
+ if !strings.Contains(html, "Wujek") || !strings.Contains(html, "Wulgata") {
+ t.Errorf("vertical output missing both version labels: %q", html[:min(300, len(html))])
+ }
+}
+
+func TestRenderReadingsInterlinear(t *testing.T) {
+ secs := []liturgy.Section{{Heading: "Ewangelia (J 20, 1. 11-18)", PartID: "ewangelia"}}
+ html := string(RenderReadings(secs, []string{"wuj", "vul"}, "new", "interlinear"))
+ if !strings.Contains(html, "ilverse") {
+ t.Errorf("interlinear output missing ilverse: %q", html[:min(300, len(html))])
+ }
+ if !strings.Contains(html, `class="vnum"`) {
+ t.Errorf("interlinear output missing vnum: %q", html[:min(300, len(html))])
+ }
+ // The first ilverse block should group both version labels under one key.
+ // Bound it by the next vnum span (each ilverse carries exactly one).
+ i := strings.Index(html, `class="vnum"`)
+ block := html[i:]
+ if j := strings.Index(html[i+1:], `class="vnum"`); j != -1 {
+ block = html[i : i+1+j]
+ }
+ if !strings.Contains(block, "Wujek") || !strings.Contains(block, "Wulgata") {
+ t.Errorf("first interlinear verse block missing both version labels: %q", block)
+ }
+}
+
+func TestRenderReadingsInterlinearExcludesPL(t *testing.T) {
+ secs := []liturgy.Section{{Heading: "Ewangelia (J 20, 1. 11-18)", PartID: "ewangelia"}}
+ html := string(RenderReadings(secs, []string{"pl", "vul"}, "new", "interlinear"))
+ if strings.Contains(html, "Polski (niedziela.pl)") {
+ t.Errorf("interlinear output should substitute wuj for pl, not carry pl's label: %q", html[:min(300, len(html))])
+ }
+ if !strings.Contains(html, "Wujek") {
+ t.Errorf("interlinear output should substitute wuj for pl: %q", html[:min(300, len(html))])
+ }
+}
+
+func TestRenderReadingsInterlinearNoVersifiedNote(t *testing.T) {
+ secs := []liturgy.Section{{Heading: "Bez odwoĊ‚ania", PartID: "ewangelia"}}
+ html := string(RenderReadings(secs, []string{"wuj"}, "new", "interlinear"))
+ if strings.Contains(html, "ilverse") {
+ t.Errorf("expected no ilverse blocks when nothing resolves: %q", html)
+ }
+}
+
func TestUserTheme(t *testing.T) {
dir := t.TempDir()
t.Setenv("XDG_CONFIG_HOME", dir)