diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-24 13:07:37 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-24 13:07:37 +0200 |
| commit | a675a983424f1f8d103fc12d55ef4f7129a92d62 (patch) | |
| tree | b9483bf09f03cb9047a548289556c73a9343bbb0 /internal/tui/tui_test.go | |
| parent | 55a5c793d04b55892fcddfc753d8526bd5748f03 (diff) | |
| download | lectio-a675a983424f1f8d103fc12d55ef4f7129a92d62.tar.gz lectio-a675a983424f1f8d103fc12d55ef4f7129a92d62.zip | |
qol: tui jump-to-date (d) + lectio --citation/--week + hide bt for traditional web; v0.10.0
Diffstat (limited to 'internal/tui/tui_test.go')
| -rw-r--r-- | internal/tui/tui_test.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go index 330259d..f99c4ac 100644 --- a/internal/tui/tui_test.go +++ b/internal/tui/tui_test.go @@ -5,6 +5,8 @@ import ( "strings" "testing" + tea "github.com/charmbracelet/bubbletea" + "github.com/lukaszkasprzak/lectio/internal/config" "github.com/lukaszkasprzak/lectio/internal/liturgy" ) @@ -161,3 +163,41 @@ func TestFooterKeysLocalised(t *testing.T) { t.Errorf("pl View() footer missing %q: %q", "q wyjście", out) } } + +func TestJumpToDate(t *testing.T) { + send := func(m Model, s string) Model { + for _, r := range s { + nm, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{r}}) + m = nm.(Model) + } + return m + } + + m := New(config.Default(), "2026-07-22", "wuj") + m = send(m, "d") + if !m.jumping { + t.Fatal("'d' did not enter jump mode") + } + m = send(m, "2026-01-02") + if m.jumpBuf != "2026-01-02" { + t.Fatalf("jumpBuf = %q", m.jumpBuf) + } + nm, _ := m.Update(tea.KeyMsg{Type: tea.KeyEnter}) + m = nm.(Model) + if m.jumping { + t.Error("still in jump mode after Enter") + } + if m.date != "2026-01-02" { + t.Errorf("date = %q, want 2026-01-02", m.date) + } + + // Esc cancels without changing the date. + m2 := New(config.Default(), "2026-07-22", "wuj") + m2 = send(m2, "d") + m2 = send(m2, "2099") + nm2, _ := m2.Update(tea.KeyMsg{Type: tea.KeyEsc}) + m2 = nm2.(Model) + if m2.jumping || m2.jumpBuf != "" || m2.date != "2026-07-22" { + t.Errorf("esc did not cancel cleanly: jumping=%v buf=%q date=%q", m2.jumping, m2.jumpBuf, m2.date) + } +} |
