test(editor): start to ensure existing functionality does not regress

tauraamui created

Change summary

internal/tui/components/chat/editor/editor_test.go | 18 ++++++++++++++-
1 file changed, 16 insertions(+), 2 deletions(-)

Detailed changes

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(), "/")
 }