Below: drive the wizard model directly (skipping the bubbletea Program) by feeding key events and inspecting state. This avoids needing a real TTY in tests.
(s string)
| 137 | // needing a real TTY in tests. |
| 138 | |
| 139 | func keyEvent(s string) tea.KeyMsg { |
| 140 | switch s { |
| 141 | case "enter": |
| 142 | return tea.KeyMsg{Type: tea.KeyEnter} |
| 143 | case "esc": |
| 144 | return tea.KeyMsg{Type: tea.KeyEsc} |
| 145 | case "up": |
| 146 | return tea.KeyMsg{Type: tea.KeyUp} |
| 147 | case "down": |
| 148 | return tea.KeyMsg{Type: tea.KeyDown} |
| 149 | case "backspace": |
| 150 | return tea.KeyMsg{Type: tea.KeyBackspace} |
| 151 | case "ctrl+c": |
| 152 | return tea.KeyMsg{Type: tea.KeyCtrlC} |
| 153 | } |
| 154 | return tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune(s)} |
| 155 | } |
| 156 | |
| 157 | func drive(t *testing.T, m launchWizardModel, keys ...string) launchWizardModel { |
| 158 | t.Helper() |
no outgoing calls
no test coverage detected