diff --git a/internal/tui/components/chat/editor/editor_test.go b/internal/tui/components/chat/editor/editor_test.go index b9d56e023b231c9687224bb304213aa112a80000..6796042c3674a41a4434bd05d8238d22b9715490 100644 --- a/internal/tui/components/chat/editor/editor_test.go +++ b/internal/tui/components/chat/editor/editor_test.go @@ -3,11 +3,25 @@ package editor import ( "testing" + tea "github.com/charmbracelet/bubbletea/v2" "github.com/charmbracelet/crush/internal/app" "github.com/stretchr/testify/require" + "github.com/zeebo/assert" ) func TestEditorTypingForwardSlashOpensCompletions(t *testing.T) { - editorCmp := newEditor(&app.App{}) - require.NotNil(t, editorCmp) + testEditor := newEditor(&app.App{}) + require.NotNil(t, testEditor) + + // Simulate pressing the '/' key + keyPressMsg := tea.KeyPressMsg{ + Text: "/", + } + + m, cmds := testEditor.Update(keyPressMsg) + testEditor = m.(*editorCmp) + cmds() + + assert.True(t, testEditor.isCompletionsOpen) + assert.Equal(t, testEditor.textarea.Value(), "/") }