From b1db99a10832f0a616290c1685ec4202eff728f3 Mon Sep 17 00:00:00 2001 From: nhatthm Date: Fri, 23 Apr 2021 10:25:10 +0200 Subject: [PATCH] Fix tests --- answer.go | 2 +- multiselect_test.go | 17 ++++++++++++++--- select_test.go | 15 +++++++++++++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/answer.go b/answer.go index 3f2c035..ddf3dfe 100644 --- a/answer.go +++ b/answer.go @@ -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 { diff --git a/multiselect_test.go b/multiselect_test.go index 7ae4e53..0a9a16f 100644 --- a/multiselect_test.go +++ b/multiselect_test.go @@ -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", @@ -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", diff --git a/select_test.go b/select_test.go index 00a5edc..3d70c7c 100644 --- a/select_test.go +++ b/select_test.go @@ -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",