package editor import ( "testing" "pad/internal/ui" ) // TestCursorExistsInLayout checks if the EditorLayout produces a cursor element. func TestCursorExistsInLayout(t *testing.T) { state := NewState() TheState = state // Set to EditorPage state.page = EditorPage elems := EditorLayout(ui.Dp(800), ui.Dp(600), false) cursorFound := false for _, e := range elems { // Assuming we add a Type() method to ui.Element interface later. // For now, this will fail to compile if Type() doesn't exist. // Let's assume we can cast or inspect the element. if e.Type() == "cursor" { cursorFound = true break } } if !cursorFound { t.Error("Expected cursor element in EditorLayout") } } // TestKeyDownMove verifies key down events update CursorPosition. func TestKeyDownMove(t *testing.T) { state := NewState() TheState = state state.Editor.Buffer = "Hello" state.Editor.CursorPosition = 1 // Simulate Right Arrow HandleKeyDown("Right") if state.Editor.CursorPosition != 2 { t.Errorf("Expected cursor position 2, got %d", state.Editor.CursorPosition) } // Simulate Left Arrow HandleKeyDown("Left") if state.Editor.CursorPosition != 1 { t.Errorf("Expected cursor position 1, got %d", state.Editor.CursorPosition) } }