Skip to content

Commit fca5ba1

Browse files
committed
Add checkbox test for custom search matcher
1 parent 615687f commit fca5ba1

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tests/prompts/test_checkbox.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,3 +416,23 @@ def test_does_not_wrap_up_when_cycle_list_false():
416416

417417
result, cli = feed_cli_with_input("checkbox", message, text, **kwargs)
418418
assert result == ["foo"]
419+
420+
421+
def test_filter_custom_match():
422+
message = "Foo message"
423+
kwargs = {"choices": ["abc", "def", "ghi", "Ghi", "jkl"]}
424+
text = "G" + KeyInputs.SPACE + KeyInputs.ENTER + "\r"
425+
426+
def case_sensitive(filter_text: str, c: Choice) -> bool:
427+
return filter_text in c.title
428+
429+
result, cli = feed_cli_with_input(
430+
"checkbox",
431+
message,
432+
text,
433+
use_search_filter=True,
434+
search_matcher=case_sensitive,
435+
use_jk_keys=False,
436+
**kwargs,
437+
)
438+
assert result == ["Ghi"]

0 commit comments

Comments
 (0)