(t *testing.T)
| 272 | } |
| 273 | |
| 274 | func TestHuhPrompterConfirm(t *testing.T) { |
| 275 | tests := []struct { |
| 276 | name string |
| 277 | defaultValue bool |
| 278 | ix interaction |
| 279 | wantResult bool |
| 280 | }{ |
| 281 | { |
| 282 | name: "default false submitted as-is", |
| 283 | ix: newInteraction(enter()), |
| 284 | wantResult: false, |
| 285 | }, |
| 286 | { |
| 287 | name: "default true submitted as-is", |
| 288 | defaultValue: true, |
| 289 | ix: newInteraction(enter()), |
| 290 | wantResult: true, |
| 291 | }, |
| 292 | { |
| 293 | name: "toggle from false to true with left arrow", |
| 294 | ix: newInteraction(left(), enter()), |
| 295 | wantResult: true, |
| 296 | }, |
| 297 | { |
| 298 | name: "toggle from true to false with right arrow", |
| 299 | defaultValue: true, |
| 300 | ix: newInteraction(right(), enter()), |
| 301 | wantResult: false, |
| 302 | }, |
| 303 | { |
| 304 | name: "accept with y key", |
| 305 | ix: newInteraction(pressY(), enter()), |
| 306 | wantResult: true, |
| 307 | }, |
| 308 | { |
| 309 | name: "reject with n key", |
| 310 | defaultValue: true, |
| 311 | ix: newInteraction(pressN(), enter()), |
| 312 | wantResult: false, |
| 313 | }, |
| 314 | } |
| 315 | |
| 316 | for _, tt := range tests { |
| 317 | t.Run(tt.name, func(t *testing.T) { |
| 318 | p := newTestHuhPrompter() |
| 319 | f, result := p.buildConfirmForm("Sure?", tt.defaultValue) |
| 320 | runForm(t, f, tt.ix) |
| 321 | require.Equal(t, tt.wantResult, *result) |
| 322 | }) |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | func TestHuhPrompterPassword(t *testing.T) { |
| 327 | tests := []struct { |
nothing calls this directly
no test coverage detected