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.go45
1 files changed, 31 insertions, 14 deletions
diff --git a/internal/web/render_test.go b/internal/web/render_test.go
index 39bcc58..94d5e6e 100644
--- a/internal/web/render_test.go
+++ b/internal/web/render_test.go
@@ -124,26 +124,37 @@ func TestRenderReadingsInterlinear(t *testing.T) {
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)
- }
+ // Bound it by the next vnum span (each ilverse carries exactly one). The
+ // Wujek line appears only when the optional wuj corpus is embedded and
+ // contributes versified text to the alignment.
+ t.Run("both version labels", func(t *testing.T) {
+ requireCorpus(t, "wuj")
+ 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 TestRenderReadingsInterlinearExcludesBT(t *testing.T) {
secs := []liturgy.Section{{Heading: "Ewangelia", Citation: "J 20, 1. 11-18", Ref: "John 20:1,11-18", PartID: "ewangelia"}}
html := string(RenderReadings(secs, []string{"bt", "vul"}, "new", "interlinear", "pl", liturgy.DayInfo{}))
+ // bt is dropped before rendering regardless, so its own label never shows.
if strings.Contains(html, "Biblia TysiÄ…clecia (niedziela.pl)") {
t.Errorf("interlinear output should substitute wuj for bt, not carry bt's label: %q", html[:min(300, len(html))])
}
- if !strings.Contains(html, "Wujek") {
- t.Errorf("interlinear output should substitute wuj for bt: %q", html[:min(300, len(html))])
- }
+ // bt maps to wuj, but the Wujek label only renders when wuj is embedded and
+ // supplies versified text to the alignment.
+ t.Run("wuj substituted", func(t *testing.T) {
+ requireCorpus(t, "wuj")
+ if !strings.Contains(html, "Wujek") {
+ t.Errorf("interlinear output should substitute wuj for bt: %q", html[:min(300, len(html))])
+ }
+ })
}
func TestRenderReadingsInterlinearNoVersifiedNote(t *testing.T) {
@@ -190,9 +201,15 @@ func TestRenderReadingsLocalizesEN(t *testing.T) {
func TestRenderPassageColumns(t *testing.T) {
html := string(RenderPassage("John", "John", 3, []string{"wuj"}, "vertical", "en"))
- if !strings.Contains(html, "John 3") || !strings.Contains(html, "3:16") {
- t.Errorf("passage columns missing heading/verse:\n%s", html)
+ if !strings.Contains(html, "John 3") { // passage heading, independent of the corpus
+ t.Errorf("passage columns missing heading:\n%s", html)
}
+ t.Run("verse", func(t *testing.T) {
+ requireCorpus(t, "wuj") // the verse text comes from the optional wuj corpus
+ if !strings.Contains(html, "3:16") {
+ t.Errorf("passage columns missing verse:\n%s", html)
+ }
+ })
}
func TestRenderPassageInterlinear(t *testing.T) {