current state
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
|
||||
// Since sidekick-tui/main.go uses global variables and is a tea.Model,
|
||||
// we test basic model behavior.
|
||||
|
||||
func TestInitialModel(t *testing.T) {
|
||||
// For testing, sidekick.LoadConfig would fail or look in its default dir.
|
||||
// This ensures that the model can be initialized even without a config.
|
||||
m := initialModel()
|
||||
|
||||
if m.agent == nil {
|
||||
t.Error("expected default agent to be initialized even without config")
|
||||
}
|
||||
|
||||
if m.textarea.Value() != "" {
|
||||
t.Errorf("expected empty textarea, got %s", m.textarea.Value())
|
||||
}
|
||||
}
|
||||
|
||||
func TestModelUpdate(t *testing.T) {
|
||||
m := initialModel()
|
||||
m.ready = true
|
||||
m.width = 80
|
||||
m.height = 24
|
||||
|
||||
// Test a key message (Enter)
|
||||
m.textarea.SetValue("Hello")
|
||||
newModel, cmd := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
|
||||
|
||||
tm := newModel.(model)
|
||||
if tm.isThinking != true {
|
||||
t.Error("expected model to be in thinking state after Enter")
|
||||
}
|
||||
if tm.textarea.Value() != "" {
|
||||
t.Error("expected textarea to be reset after Enter")
|
||||
}
|
||||
if cmd == nil {
|
||||
t.Error("expected a command after Enter")
|
||||
}
|
||||
|
||||
// Test an agent response message
|
||||
respModel, _ := tm.Update(agentResponseMsg{response: "Hi"})
|
||||
rm := respModel.(model)
|
||||
if rm.isThinking != false {
|
||||
t.Error("expected model to stop thinking after response")
|
||||
}
|
||||
if len(rm.messages) < 2 {
|
||||
t.Error("expected message list to grow after response")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user