diff options
Diffstat (limited to 'internal/render/render_test.go')
| -rw-r--r-- | internal/render/render_test.go | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/internal/render/render_test.go b/internal/render/render_test.go index b016d6b..affaaf8 100644 --- a/internal/render/render_test.go +++ b/internal/render/render_test.go @@ -76,6 +76,56 @@ func TestCompareLabelLang(t *testing.T) { } } +// TestGatherVersionNoVersionLang checks that the "(not in %s)" block +// (bible.Lookup finding nothing at all) follows lang -- pl reproduces the +// original Polish wording exactly, en uses internal/i18n's English wording. +func TestGatherVersionNoVersionLang(t *testing.T) { + sec := liturgy.Section{Heading: "Ewangelia (J 20, 1. 11-18)"} + + _, blocks := GatherVersion("zzz", sec, "new", "pl") + if len(blocks) == 0 || blocks[0] != `(brak w „zzz”)` { + t.Errorf(`GatherVersion(..., "pl") blocks = %v, want [(brak w „zzz”)]`, blocks) + } + + _, blocks = GatherVersion("zzz", sec, "new", "en") + if len(blocks) == 0 || blocks[0] != "(not in zzz)" { + t.Errorf(`GatherVersion(..., "en") blocks = %v, want [(not in zzz)]`, blocks) + } +} + +// TestGatherVersionNoReferenceLang checks the "(no reference)" block (no +// citation resolvable at all) follows lang. +func TestGatherVersionNoReferenceLang(t *testing.T) { + sec := liturgy.Section{Heading: "Bez odwołania"} + + _, blocks := GatherVersion("wuj", sec, "new", "pl") + if len(blocks) == 0 || blocks[0] != "(brak odwołania)" { + t.Errorf(`GatherVersion(..., "pl") blocks = %v, want [(brak odwołania)]`, blocks) + } + + _, blocks = GatherVersion("wuj", sec, "new", "en") + if len(blocks) == 0 || blocks[0] != "(no reference)" { + t.Errorf(`GatherVersion(..., "en") blocks = %v, want [(no reference)]`, blocks) + } +} + +// TestGatherVersionNoReferenceErrLang checks the "(no reference: ...)" block +// (a citation that bible.ToEnglishRef fails to convert, e.g. an unrecognised +// book) follows lang. +func TestGatherVersionNoReferenceErrLang(t *testing.T) { + sec := liturgy.Section{Citation: "Xyz 1, 1-2"} + + _, blocks := GatherVersion("wuj", sec, "new", "pl") + if len(blocks) == 0 || !strings.HasPrefix(blocks[0], "(brak odwołania: ") { + t.Errorf(`GatherVersion(..., "pl") blocks = %v, want prefix "(brak odwołania: "`, blocks) + } + + _, blocks = GatherVersion("wuj", sec, "new", "en") + if len(blocks) == 0 || !strings.HasPrefix(blocks[0], "(no reference: ") { + t.Errorf(`GatherVersion(..., "en") blocks = %v, want prefix "(no reference: "`, blocks) + } +} + func TestOfflineVersions(t *testing.T) { got := OfflineVersions([]string{"pl", "wuj", "vul"}) for _, v := range got { @@ -143,6 +193,12 @@ func TestLocalizeHeading(t *testing.T) { {"unknown partID unchanged", "Coś innego (X 1)", "", "en", "Coś innego (X 1)"}, {"already-English heading unchanged (traditional lectionary, no pl prefix to match)", "Gospel (Luke 7:36-50)", "ewangelia", "en", "Gospel (Luke 7:36-50)"}, {"prefix mismatch unchanged", "Nieoczekiwany tytuł (J 1)", "ewangelia", "en", "Nieoczekiwany tytuł (J 1)"}, + // Split (two-reading) feast day: niedziela.pl scrapes + // PartID="drugie_czytanie" onto a heading that still literally + // starts with "1. czytanie" (its own numbering quirk). Matching + // must follow the heading's actual text, not partID's label, so + // this localises to "1st reading", not staying Polish. + {"drugie_czytanie partID with a 1. czytanie heading (split feast day)", "1. czytanie (Dz 2, 14. 22-33)", "drugie_czytanie", "en", "1st reading (Dz 2, 14. 22-33)"}, } for _, c := range cases { |
