MCPcopy
hub / github.com/SurgeDM/Surge / TestUpdate_FilePickerUseDirReturnsToAddInput

Function TestUpdate_FilePickerUseDirReturnsToAddInput

internal/tui/update_test.go:1194–1220  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1192}
1193
1194func TestUpdate_FilePickerUseDirReturnsToAddInput(t *testing.T) {
1195 browseDir := t.TempDir()
1196
1197 m := RootModel{
1198 state: FilePickerState,
1199 focusedInput: 2,
1200 inputs: newInputModels(),
1201 keys: config.DefaultKeyMap(),
1202 Settings: config.DefaultSettings(),
1203 filepicker: newFilepicker(browseDir),
1204 filepickerOrigin: FilePickerOriginAdd,
1205 }
1206 m.filepicker.CurrentDirectory = browseDir
1207
1208 updated, _ := m.Update(tea.KeyPressMsg{Code: tea.KeyEnter})
1209 m2 := unwrapRootModel(t, updated)
1210
1211 if got, want := m2.state, InputState; got != want {
1212 t.Fatalf("state after use dir = %v, want %v", got, want)
1213 }
1214 if got, want := m2.inputs[2].Value(), browseDir; got != want {
1215 t.Fatalf("path input after use dir = %q, want %q", got, want)
1216 }
1217 if got, want := m2.focusedInput, 2; got != want {
1218 t.Fatalf("focusedInput after use dir = %d, want %d", got, want)
1219 }
1220}
1221
1222func TestNewFilepickerEscIsCancelOnly(t *testing.T) {
1223 fp := newFilepicker(t.TempDir())

Callers

nothing calls this directly

Calls 6

UpdateMethod · 0.95
DefaultKeyMapFunction · 0.92
DefaultSettingsFunction · 0.92
newInputModelsFunction · 0.85
newFilepickerFunction · 0.85
unwrapRootModelFunction · 0.85

Tested by

no test coverage detected