@@ -105,26 +105,36 @@ func TestConfirmForm(t *testing.T) {
105105 assert .Contains (t , view , "No" )
106106 })
107107
108- t .Run ("default value is respected " , func (t * testing.T ) {
108+ t .Run ("default true starts on Yes " , func (t * testing.T ) {
109109 choice := true
110110 f := buildConfirmForm (nil , "Continue?" , & choice )
111111 f .Update (f .Init ())
112112
113- assert .True (t , choice )
113+ view := ansi .Strip (f .View ())
114+ assert .Contains (t , view , style .Chevron ()+ " Yes" )
114115 })
115116
116- t .Run ("toggle changes value " , func (t * testing.T ) {
117+ t .Run ("default false starts on No " , func (t * testing.T ) {
117118 choice := false
118119 f := buildConfirmForm (nil , "Continue?" , & choice )
119120 f .Update (f .Init ())
120121
121- // Toggle to Yes
122- f .Update (tea.KeyPressMsg {Code : tea .KeyLeft })
123- assert .True (t , choice )
122+ view := ansi .Strip (f .View ())
123+ assert .Contains (t , view , style .Chevron ()+ " No" )
124+ })
125+
126+ t .Run ("arrow keys change selection" , func (t * testing.T ) {
127+ choice := true
128+ f := buildConfirmForm (nil , "Continue?" , & choice )
129+ f .Update (f .Init ())
124130
125- // Toggle back to No
126- f .Update (tea.KeyPressMsg {Code : tea .KeyRight })
131+ // Move down to No
132+ f .Update (tea.KeyPressMsg {Code : tea .KeyDown })
127133 assert .False (t , choice )
134+
135+ // Move back up to Yes
136+ f .Update (tea.KeyPressMsg {Code : tea .KeyUp })
137+ assert .True (t , choice )
128138 })
129139}
130140
@@ -450,12 +460,12 @@ func TestFormsAccessible(t *testing.T) {
450460 assert .Contains (t , out .String (), "Pick one (press Enter for 1)" )
451461 })
452462
453- t .Run ("confirm form accepts yes/no input" , func (t * testing.T ) {
463+ t .Run ("confirm form accepts numbered input" , func (t * testing.T ) {
454464 var choice bool
455465 f := buildConfirmForm (io , "Continue?" , & choice )
456466
457467 var out strings.Builder
458- err := f .WithOutput (& out ).WithInput (strings .NewReader ("y \n " )).Run ()
468+ err := f .WithOutput (& out ).WithInput (strings .NewReader ("1 \n " )).Run ()
459469
460470 assert .NoError (t , err )
461471 assert .True (t , choice )
0 commit comments