diff options
Diffstat (limited to 'internal/tui/reader_test.go')
| -rw-r--r-- | internal/tui/reader_test.go | 24 |
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)) } |
