(t *testing.T)
| 155 | } |
| 156 | |
| 157 | func TestMultiSelect(t *testing.T) { |
| 158 | t.Parallel() |
| 159 | |
| 160 | tests := []struct { |
| 161 | name string |
| 162 | items []string |
| 163 | allowCustom bool |
| 164 | want []string |
| 165 | }{ |
| 166 | { |
| 167 | name: "MultiSelect", |
| 168 | items: []string{"aaa", "bbb", "ccc"}, |
| 169 | allowCustom: false, |
| 170 | want: []string{"aaa", "bbb", "ccc"}, |
| 171 | }, |
| 172 | { |
| 173 | name: "MultiSelectWithCustomInput", |
| 174 | items: []string{"Code", "Chairs", "Whale", "Diamond", "Carrot"}, |
| 175 | allowCustom: true, |
| 176 | want: []string{"Code", "Chairs", "Whale", "Diamond", "Carrot"}, |
| 177 | }, |
| 178 | } |
| 179 | |
| 180 | for _, tt := range tests { |
| 181 | t.Run(tt.name, func(t *testing.T) { |
| 182 | t.Parallel() |
| 183 | |
| 184 | ptty := ptytest.New(t) |
| 185 | msgChan := make(chan []string) |
| 186 | |
| 187 | go func() { |
| 188 | resp, err := newMultiSelect(ptty, tt.items, tt.allowCustom) |
| 189 | assert.NoError(t, err) |
| 190 | msgChan <- resp |
| 191 | }() |
| 192 | |
| 193 | require.Equal(t, tt.want, <-msgChan) |
| 194 | }) |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | func newMultiSelect(pty *ptytest.PTY, items []string, custom bool) ([]string, error) { |
| 199 | var values []string |
nothing calls this directly
no test coverage detected