Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatthm committed Apr 23, 2021
1 parent 425117b commit b1db99a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion answer.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (a *HelpAction) Do(c Console) error {

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

func pressHelp(help string, options ...string) *HelpAction {
Expand Down
17 changes: 14 additions & 3 deletions multiselect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestMultiSelectPrompt(t *testing.T) {
scenario: "navigation",
expectSurvey: surveyexpect.Expect(func(s *surveyexpect.Survey) {
s.ExpectMultiSelect("Select destinations").
Type("United").
Type("United").Delete(2).
ExpectOptions(
"> [ ] United Kingdom",
"[ ] United States",
Expand Down Expand Up @@ -158,10 +158,21 @@ func TestMultiSelectPrompt_NoHelpButStillExpect(t *testing.T) {
s.WithTimeout(50 * time.Millisecond)

s.ExpectMultiSelect("Select destinations").
ShowHelp("Your favorite countries")
ShowHelp("Your favorite countries").
ExpectOptions(
"> [ ] option 1",
"[ ] option 2",
)
})(testingT)

expectedError := "there are remaining expectations that were not met:\n\nExpect : MultiSelect Prompt\nMessage: \"Select destinations\"\npress \"?\""
expectedError := `there are remaining expectations that were not met:
Expect : MultiSelect Prompt
Message: "Select destinations"
press "?" and see "Your favorite countries"
Expect a multiselect list:
> [ ] option 1
[ ] option 2`

p := &survey.MultiSelect{
Message: "Select destinations",
Expand Down
15 changes: 13 additions & 2 deletions select_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,21 @@ func TestSelectPrompt_NoHelpButStillExpect(t *testing.T) {
s.WithTimeout(50 * time.Millisecond)

s.ExpectSelect("Select a country").
ShowHelp("Your favorite country")
ShowHelp("Your favorite country").
ExpectOptions(
"> option 1",
"option 2",
)
})(testingT)

expectedError := "there are remaining expectations that were not met:\n\nExpect : Select Prompt\nMessage: \"Select a country\"\npress \"?\""
expectedError := `there are remaining expectations that were not met:
Expect : Select Prompt
Message: "Select a country"
press "?" and see "Your favorite country"
Expect a select list:
> option 1
option 2`

p := &survey.Select{
Message: "Select a country",
Expand Down

0 comments on commit b1db99a

Please sign in to comment.