diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-23 21:51:40 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-23 21:51:40 +0200 |
| commit | 4c776396115c8120c3e1cb8fda993449fcdcd326 (patch) | |
| tree | 0144fb325663dde063057a5ec568c59d4cbe79da /internal/tui/tui_test.go | |
| parent | bfa8df7b36ccbd44703e0705d51a2ed553a23164 (diff) | |
| download | lectio-4c776396115c8120c3e1cb8fda993449fcdcd326.tar.gz lectio-4c776396115c8120c3e1cb8fda993449fcdcd326.zip | |
i18n: ui_language config (default en) for UI chrome across cli/tui/web; version labels localised
Diffstat (limited to 'internal/tui/tui_test.go')
| -rw-r--r-- | internal/tui/tui_test.go | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go index 2aa7b84..baa5c05 100644 --- a/internal/tui/tui_test.go +++ b/internal/tui/tui_test.go @@ -1,9 +1,11 @@ package tui import ( + "strings" "testing" "github.com/lukaszkasprzak/lectio/internal/config" + "github.com/lukaszkasprzak/lectio/internal/liturgy" ) func TestVersionCycle(t *testing.T) { @@ -29,3 +31,55 @@ func TestOfflineDropsPL(t *testing.T) { } } } + +// TestBodyLinesLocalisesMessages checks that the loading/no-readings/error +// messages follow cfg.UILanguage. +func TestBodyLinesLocalisesMessages(t *testing.T) { + en := Model{cfg: config.Config{UILanguage: "en"}, loading: true} + if lines := en.bodyLines(80); len(lines) == 0 || !strings.Contains(lines[0], "loading") { + t.Errorf("en loading bodyLines = %v, want it to contain %q", lines, "loading") + } + + pl := Model{cfg: config.Config{UILanguage: "pl"}, loading: true} + if lines := pl.bodyLines(80); len(lines) == 0 || !strings.Contains(lines[0], "ładowanie") { + t.Errorf("pl loading bodyLines = %v, want it to contain %q", lines, "ładowanie") + } + + enEmpty := Model{cfg: config.Config{UILanguage: "en"}, date: "2026-07-22"} + if lines := enEmpty.bodyLines(80); len(lines) == 0 || !strings.Contains(lines[0], "no readings for") { + t.Errorf("en no-readings bodyLines = %v, want it to contain %q", lines, "no readings for") + } +} + +// 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). +func TestBodyLinesLocalisesHeading(t *testing.T) { + sec := liturgy.Section{Heading: "Ewangelia (J 20, 1. 11-18)", PartID: "ewangelia"} + + en := Model{cfg: config.Config{UILanguage: "en", Lectionary: "new"}, sections: []liturgy.Section{sec}} + body := strings.Join(en.bodyLines(80), "\n") + if !strings.Contains(body, "Gospel (J 20, 1. 11-18)") { + t.Errorf("en bodyLines missing localised heading: %q", body) + } + + pl := Model{cfg: config.Config{UILanguage: "pl", Lectionary: "new"}, sections: []liturgy.Section{sec}} + body = strings.Join(pl.bodyLines(80), "\n") + if !strings.Contains(body, "Ewangelia (J 20, 1. 11-18)") { + t.Errorf("pl bodyLines missing unchanged heading: %q", body) + } +} + +// TestFooterKeysLocalised checks the footer keybar text follows +// cfg.UILanguage. +func TestFooterKeysLocalised(t *testing.T) { + en := Model{cfg: config.Config{UILanguage: "en"}, date: "2026-07-22"} + if out := en.View(); !strings.Contains(out, "q quit") { + t.Errorf("en View() footer missing %q: %q", "q quit", out) + } + + pl := Model{cfg: config.Config{UILanguage: "pl"}, date: "2026-07-22"} + if out := pl.View(); !strings.Contains(out, "q wyjście") { + t.Errorf("pl View() footer missing %q: %q", "q wyjście", out) + } +} |
