Skip to content

Commit b1db99a

Browse files
committed
Fix tests
1 parent 425117b commit b1db99a

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

answer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (a *HelpAction) Do(c Console) error {
180180

181181
// String represents the answer as a string.
182182
func (a *HelpAction) String() string {
183-
return fmt.Sprintf("press %q", a.icon)
183+
return fmt.Sprintf("press %q and see %q", a.icon, a.help)
184184
}
185185

186186
func pressHelp(help string, options ...string) *HelpAction {

multiselect_test.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestMultiSelectPrompt(t *testing.T) {
6363
scenario: "navigation",
6464
expectSurvey: surveyexpect.Expect(func(s *surveyexpect.Survey) {
6565
s.ExpectMultiSelect("Select destinations").
66-
Type("United").
66+
Type("United").Delete(2).
6767
ExpectOptions(
6868
"> [ ] United Kingdom",
6969
"[ ] United States",
@@ -158,10 +158,21 @@ func TestMultiSelectPrompt_NoHelpButStillExpect(t *testing.T) {
158158
s.WithTimeout(50 * time.Millisecond)
159159

160160
s.ExpectMultiSelect("Select destinations").
161-
ShowHelp("Your favorite countries")
161+
ShowHelp("Your favorite countries").
162+
ExpectOptions(
163+
"> [ ] option 1",
164+
"[ ] option 2",
165+
)
162166
})(testingT)
163167

164-
expectedError := "there are remaining expectations that were not met:\n\nExpect : MultiSelect Prompt\nMessage: \"Select destinations\"\npress \"?\""
168+
expectedError := `there are remaining expectations that were not met:
169+
170+
Expect : MultiSelect Prompt
171+
Message: "Select destinations"
172+
press "?" and see "Your favorite countries"
173+
Expect a multiselect list:
174+
> [ ] option 1
175+
[ ] option 2`
165176

166177
p := &survey.MultiSelect{
167178
Message: "Select destinations",

select_test.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,21 @@ func TestSelectPrompt_NoHelpButStillExpect(t *testing.T) {
135135
s.WithTimeout(50 * time.Millisecond)
136136

137137
s.ExpectSelect("Select a country").
138-
ShowHelp("Your favorite country")
138+
ShowHelp("Your favorite country").
139+
ExpectOptions(
140+
"> option 1",
141+
"option 2",
142+
)
139143
})(testingT)
140144

141-
expectedError := "there are remaining expectations that were not met:\n\nExpect : Select Prompt\nMessage: \"Select a country\"\npress \"?\""
145+
expectedError := `there are remaining expectations that were not met:
146+
147+
Expect : Select Prompt
148+
Message: "Select a country"
149+
press "?" and see "Your favorite country"
150+
Expect a select list:
151+
> option 1
152+
option 2`
142153

143154
p := &survey.Select{
144155
Message: "Select a country",

0 commit comments

Comments
 (0)