editor_test.go

 1package editor
 2
 3import (
 4	"testing"
 5
 6	tea "github.com/charmbracelet/bubbletea/v2"
 7	"github.com/charmbracelet/crush/internal/app"
 8	"github.com/stretchr/testify/require"
 9	"github.com/zeebo/assert"
10)
11
12func TestEditorTypingForwardSlashOpensCompletions(t *testing.T) {
13	testEditor := newEditor(&app.App{})
14	require.NotNil(t, testEditor)
15
16	// Simulate pressing the '/' key
17	keyPressMsg := tea.KeyPressMsg{
18		Text: "/",
19	}
20
21	m, cmds := testEditor.Update(keyPressMsg)
22	testEditor = m.(*editorCmp)
23	cmds()
24
25	assert.True(t, testEditor.isCompletionsOpen)
26	assert.Equal(t, testEditor.textarea.Value(), "/")
27}