summaryrefslogtreecommitdiff
path: root/internal/tui/reader_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-24 16:18:27 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-24 16:18:27 +0200
commit19e02a3290dc78de088f9a72fb9c16dbf6517ffc (patch)
tree867b1a58fe6b40bae4abb83b5aca068065b45bcc /internal/tui/reader_test.go
parent0321ea57f5c561215a8dea111ed7f3ea7b05594e (diff)
downloadlectio-19e02a3290dc78de088f9a72fb9c16dbf6517ffc.tar.gz
lectio-19e02a3290dc78de088f9a72fb9c16dbf6517ffc.zip
tui reader: m opens a verse cursor (↑/↓ pick the verse) then a note box (write or skip); d in bookmarks confirms before deleting; v0.19.0
Diffstat (limited to 'internal/tui/reader_test.go')
-rw-r--r--internal/tui/reader_test.go24
1 files changed, 19 insertions, 5 deletions
diff --git a/internal/tui/reader_test.go b/internal/tui/reader_test.go
index 514f892..f3e43d5 100644
--- a/internal/tui/reader_test.go
+++ b/internal/tui/reader_test.go
@@ -114,10 +114,15 @@ func TestReaderBookmarkFlow(t *testing.T) {
if m.mode != modeRead {
t.Fatal("did not enter reading")
}
- // mark: m -> type note -> enter
+ // mark: m -> pick a verse -> note box -> enter
m = key(m, runes("m"))
+ if m.mode != modeMarkVerse {
+ t.Fatal("m did not enter the verse picker")
+ }
+ m = key(m, runes("j")) // move the cursor down to John 1:2
+ m = key(m, tea.KeyMsg{Type: tea.KeyEnter})
if m.mode != modeMark {
- t.Fatal("m did not enter modeMark")
+ t.Fatal("enter did not open the note box")
}
m = key(m, runes("hi"))
m = key(m, tea.KeyMsg{Type: tea.KeyEnter})
@@ -129,8 +134,8 @@ func TestReaderBookmarkFlow(t *testing.T) {
if m.mode != modeBookmarks || len(m.marks) != 1 {
t.Fatalf("bookmarks mode=%v n=%d", m.mode, len(m.marks))
}
- if m.marks[0].Book != "John" || m.marks[0].Note != "hi" {
- t.Errorf("mark = %+v", m.marks[0])
+ if m.marks[0].Book != "John" || m.marks[0].Verse != 2 || m.marks[0].Note != "hi" {
+ t.Errorf("mark = %+v (want John 1:2 note hi)", m.marks[0])
}
if !strings.Contains(m.View(), "John") {
t.Errorf("bookmarks view missing John:\n%s", m.View())
@@ -140,9 +145,18 @@ func TestReaderBookmarkFlow(t *testing.T) {
if m.mode != modeRead || m.books[m.bookIdx].Canonical != "John" {
t.Errorf("jump failed: mode=%v book=%q", m.mode, m.books[m.bookIdx].Canonical)
}
- // delete via list
+ // delete via list, with confirmation
m = key(m, runes("b"))
m = key(m, runes("d"))
+ if !m.confirmDelete {
+ t.Fatal("d did not ask for confirmation")
+ }
+ m = key(m, runes("n")) // cancel
+ if m.confirmDelete || len(m.marks) != 1 {
+ t.Fatalf("n did not cancel (confirm=%v n=%d)", m.confirmDelete, len(m.marks))
+ }
+ m = key(m, runes("d"))
+ m = key(m, runes("y")) // confirm
if len(m.marks) != 0 {
t.Errorf("delete failed, %d remaining", len(m.marks))
}