(t *testing.T)
| 699 | } |
| 700 | |
| 701 | func TestMultiSelectFiltering(t *testing.T) { |
| 702 | tests := []struct { |
| 703 | name string |
| 704 | filtering bool |
| 705 | }{ |
| 706 | {"Filtering off", false}, |
| 707 | {"Filtering on", true}, |
| 708 | } |
| 709 | |
| 710 | for _, tc := range tests { |
| 711 | t.Run(tc.name, func(t *testing.T) { |
| 712 | field := NewMultiSelect[string]().Options(NewOptions("Foo", "Bar", "Baz")...).Title("Which one?").Filterable(tc.filtering) |
| 713 | f := NewForm(NewGroup(field)) |
| 714 | f.Update(f.Init()) |
| 715 | // Filter for values starting with a 'B' only. |
| 716 | f.Update(keypress('/')) |
| 717 | f.Update(keypress('B')) |
| 718 | |
| 719 | view := viewModel(f) |
| 720 | // When we're filtering, the list should change. |
| 721 | if tc.filtering && strings.Contains(view, "Foo") { |
| 722 | t.Log(pretty.Render(view)) |
| 723 | t.Error("Foo should not in filtered list.") |
| 724 | } |
| 725 | // When we're not filtering, the list shouldn't change. |
| 726 | if !tc.filtering && !strings.Contains(view, "Foo") { |
| 727 | t.Log(pretty.Render(view)) |
| 728 | t.Error("Expected list to contain Foo.") |
| 729 | } |
| 730 | }) |
| 731 | } |
| 732 | t.Run("Remove filter option from help menu.", func(t *testing.T) { |
| 733 | field := NewMultiSelect[string]().Options(NewOptions("Foo", "Bar", "Baz")...).Title("Which one?").Filterable(false) |
| 734 | f := NewForm(NewGroup(field)) |
| 735 | f.Update(f.Init()) |
| 736 | view := viewModel(f) |
| 737 | if strings.Contains(view, "filter") { |
| 738 | t.Log(pretty.Render(view)) |
| 739 | t.Error("Expected list to hide filtering in help menu.") |
| 740 | } |
| 741 | }) |
| 742 | } |
| 743 | |
| 744 | func TestSelectPageNavigation(t *testing.T) { |
| 745 | opts := NewOptions( |
nothing calls this directly
no test coverage detected
searching dependent graphs…