summaryrefslogtreecommitdiff
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.go30
1 files changed, 24 insertions, 6 deletions
diff --git a/internal/web/render_test.go b/internal/web/render_test.go
index 0e64168..ea44ed2 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", "horizontal"))
+ html := string(RenderReadings(secs, []string{"wuj"}, "new", "horizontal", "pl"))
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", "horizontal"))
+ html := string(RenderReadings(secs, []string{"pl"}, "new", "horizontal", "pl"))
if strings.Contains(html, "<script>alert(1)</script>") {
t.Errorf("raw <script> leaked into rendered output: %q", html)
}
@@ -56,7 +56,7 @@ 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"))
+ html := string(RenderReadings(secs, []string{"wuj", "vul"}, "new", "vertical", "pl"))
if !strings.Contains(html, "display-vertical") {
t.Errorf("vertical output missing display-vertical container: %q", html[:min(300, len(html))])
}
@@ -70,7 +70,7 @@ func TestRenderReadingsVertical(t *testing.T) {
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"))
+ html := string(RenderReadings(secs, []string{"wuj", "vul"}, "new", "interlinear", "pl"))
if !strings.Contains(html, "ilverse") {
t.Errorf("interlinear output missing ilverse: %q", html[:min(300, len(html))])
}
@@ -91,7 +91,7 @@ func TestRenderReadingsInterlinear(t *testing.T) {
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"))
+ html := string(RenderReadings(secs, []string{"pl", "vul"}, "new", "interlinear", "pl"))
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))])
}
@@ -102,12 +102,30 @@ func TestRenderReadingsInterlinearExcludesPL(t *testing.T) {
func TestRenderReadingsInterlinearNoVersifiedNote(t *testing.T) {
secs := []liturgy.Section{{Heading: "Bez odwołania", PartID: "ewangelia"}}
- html := string(RenderReadings(secs, []string{"wuj"}, "new", "interlinear"))
+ html := string(RenderReadings(secs, []string{"wuj"}, "new", "interlinear", "pl"))
if strings.Contains(html, "ilverse") {
t.Errorf("expected no ilverse blocks when nothing resolves: %q", html)
}
}
+// TestRenderReadingsLocalizesEN checks that lang="en" localises both the
+// version-column label (via render.GatherVersion) and the section heading's
+// part-label word (via render.LocalizeHeading, brief §3b), while the
+// citation stays exactly as scraped.
+func TestRenderReadingsLocalizesEN(t *testing.T) {
+ secs := []liturgy.Section{{Heading: "Ewangelia (J 20, 1. 11-18)", PartID: "ewangelia"}}
+ html := string(RenderReadings(secs, []string{"vul"}, "new", "horizontal", "en"))
+ if !strings.Contains(html, "Gospel (J 20, 1. 11-18)") {
+ t.Errorf("en output missing localised heading: %q", html[:min(300, len(html))])
+ }
+ if !strings.Contains(html, "Vulgate (Latin)") {
+ t.Errorf("en output missing localised version label: %q", html[:min(300, len(html))])
+ }
+ if strings.Contains(html, "Ewangelia") {
+ t.Errorf("en output should not carry the Polish heading label: %q", html[:min(300, len(html))])
+ }
+}
+
func TestUserTheme(t *testing.T) {
dir := t.TempDir()
t.Setenv("XDG_CONFIG_HOME", dir)