aboutsummaryrefslogtreecommitdiff
path: root/internal/tui
diff options
context:
space:
mode:
Diffstat (limited to 'internal/tui')
-rw-r--r--internal/tui/tui_test.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index baa5c05..60b473b 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -1,6 +1,7 @@
package tui
import (
+ "errors"
"strings"
"testing"
@@ -51,6 +52,48 @@ func TestBodyLinesLocalisesMessages(t *testing.T) {
}
}
+// TestBodyLinesSingleSpaceConcatenation is a regression test for the
+// i18n-migration whitespace bug: i18n.UI.NoReadingsFor/ErrorPrefix must
+// carry exactly one trailing space, since bodyLines concatenates the date/
+// error string directly onto them with no separator of its own -- the
+// pre-i18n TUI code produced "błąd: " + err / "brak czytań na " + date (one
+// space), and the i18n fields regressed to two.
+func TestBodyLinesSingleSpaceConcatenation(t *testing.T) {
+ enEmpty := Model{cfg: config.Config{UILanguage: "en"}, date: "2026-07-22"}
+ lines := enEmpty.bodyLines(80)
+ if len(lines) == 0 || !strings.Contains(lines[0], "no readings for 2026-07-22") {
+ t.Errorf("en no-readings bodyLines[0] = %q, want it to contain %q (single space)", lines[0], "no readings for 2026-07-22")
+ }
+ if strings.Contains(lines[0], "for 2026") {
+ t.Errorf("en no-readings bodyLines[0] = %q, has 2+ spaces before the date", lines[0])
+ }
+
+ plEmpty := Model{cfg: config.Config{UILanguage: "pl"}, date: "2026-07-22"}
+ lines = plEmpty.bodyLines(80)
+ if len(lines) == 0 || !strings.Contains(lines[0], "brak czytań na 2026-07-22") {
+ t.Errorf("pl no-readings bodyLines[0] = %q, want it to contain %q (single space)", lines[0], "brak czytań na 2026-07-22")
+ }
+
+ errText := "boom"
+ enErr := Model{cfg: config.Config{UILanguage: "en"}, err: errors.New(errText)}
+ lines = enErr.bodyLines(80)
+ if len(lines) == 0 || !strings.Contains(lines[0], "error: "+errText) {
+ t.Errorf("en error bodyLines[0] = %q, want it to contain %q (single space)", lines[0], "error: "+errText)
+ }
+ if strings.Contains(lines[0], "error: ") {
+ t.Errorf("en error bodyLines[0] = %q, has 2+ spaces after \"error:\"", lines[0])
+ }
+
+ plErr := Model{cfg: config.Config{UILanguage: "pl"}, err: errors.New(errText)}
+ lines = plErr.bodyLines(80)
+ if len(lines) == 0 || !strings.Contains(lines[0], "błąd: "+errText) {
+ t.Errorf("pl error bodyLines[0] = %q, want it to contain %q (single space)", lines[0], "błąd: "+errText)
+ }
+ if strings.Contains(lines[0], "błąd: ") {
+ t.Errorf("pl error bodyLines[0] = %q, has 2+ spaces after \"błąd:\"", lines[0])
+ }
+}
+
// TestBodyLinesLocalisesHeading checks that a modern-lectionary section
// heading's label word follows cfg.UILanguage while the citation stays
// exactly as scraped (render.LocalizeHeading, brief §3b).