diff options
Diffstat (limited to 'internal/viinput/model_test.go')
| -rw-r--r-- | internal/viinput/model_test.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/internal/viinput/model_test.go b/internal/viinput/model_test.go index dbbfe4b..1035038 100644 --- a/internal/viinput/model_test.go +++ b/internal/viinput/model_test.go @@ -1,6 +1,7 @@ package viinput import ( + "strings" "testing" tea "charm.land/bubbletea/v2" @@ -288,6 +289,37 @@ func TestModelUndoRestoresPriorState(t *testing.T) { } } +func TestModelViewUsesModeSpecificCursorStyles(t *testing.T) { + t.Parallel() + + model := New() + model.Focus() + model.Prompt = "edit> " + model.SetValue("abc") + model.cursor = 1 + model.mode = ModeNormal + + got := model.View() + if !strings.HasPrefix(got, model.Prompt) { + t.Fatalf("view = %q, want prefix %q", got, model.Prompt) + } + if !strings.Contains(got, "a") || !strings.Contains(got, "bc") { + t.Fatalf("view = %q, want rendered contents", got) + } + if !strings.Contains(got, cursorGlyph(ModeNormal)) { + t.Fatalf("normal view = %q, want block cursor", got) + } + if !strings.Contains(got, "\x1b[") { + t.Fatalf("normal view = %q, want lipgloss styling", got) + } + + model.mode = ModeInsert + got = model.View() + if !strings.Contains(got, cursorGlyph(ModeInsert)) { + t.Fatalf("insert view = %q, want bar cursor", got) + } +} + func key(value string) tea.KeyPressMsg { return tea.KeyPressMsg{Code: 0, Text: value} } |
