(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestPickerOptions(t *testing.T) { |
| 10 | t.Run("returns the labels", func(t *testing.T) { |
| 11 | options := pickerOptions{pickerOption{label: "Foo"}, pickerOption{label: "Bar"}} |
| 12 | want := []string{"Foo", "Bar"} |
| 13 | got := options.labels() |
| 14 | |
| 15 | assert.Equal(t, want, got) |
| 16 | }) |
| 17 | |
| 18 | t.Run("returns the default label", func(t *testing.T) { |
| 19 | options := pickerOptions{pickerOption{label: "Foo"}, pickerOption{label: "Bar"}} |
| 20 | want := "Foo" |
| 21 | got := options.defaultLabel() |
| 22 | |
| 23 | assert.Equal(t, want, got) |
| 24 | }) |
| 25 | |
| 26 | t.Run("returns an empty label when there are no options", func(t *testing.T) { |
| 27 | options := pickerOptions{} |
| 28 | want := "" |
| 29 | got := options.defaultLabel() |
| 30 | |
| 31 | assert.Equal(t, want, got) |
| 32 | }) |
| 33 | |
| 34 | t.Run("returns the value for a given label", func(t *testing.T) { |
| 35 | options := pickerOptions{pickerOption{label: "Foo", value: "0"}, pickerOption{label: "Bar", value: "1"}} |
| 36 | want := "1" |
| 37 | got := options.getValue("Bar") |
| 38 | |
| 39 | assert.Equal(t, want, got) |
| 40 | }) |
| 41 | |
| 42 | t.Run("returns an empty value given a non-existent label", func(t *testing.T) { |
| 43 | options := pickerOptions{pickerOption{label: "Foo"}} |
| 44 | want := "" |
| 45 | got := options.getValue("Bar") |
| 46 | |
| 47 | assert.Equal(t, want, got) |
| 48 | }) |
| 49 | |
| 50 | t.Run("return the values for a given set of labels", func(t *testing.T) { |
| 51 | options := pickerOptions{pickerOption{label: "Foo", value: "0"}, pickerOption{label: "Bar", value: "1"}, pickerOption{label: "Baz", value: "2"}} |
| 52 | want := []string{"0", "2"} |
| 53 | got := options.getValues("Foo", "Baz") |
| 54 | |
| 55 | assert.Equal(t, want, got) |
| 56 | }) |
| 57 | |
| 58 | t.Run("returns empty values for a given set of non-existant labels", func(t *testing.T) { |
| 59 | options := pickerOptions{pickerOption{label: "Foo", value: "0"}, pickerOption{label: "Bar", value: "1"}, pickerOption{label: "Baz", value: "2"}} |
| 60 | want := []string(nil) |
| 61 | got := options.getValues("Buz") |
| 62 | |
| 63 | assert.Equal(t, want, got) |
| 64 | }) |
| 65 | } |
nothing calls this directly
no test coverage detected