From 054c23ab2990202ee1c5be824a18b1964afe85f9 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Sun, 29 Jan 2023 11:53:21 +0000 Subject: [PATCH] Add a test for using right-word to get to the end of an input --- tests/input/test_input_key_actions.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/input/test_input_key_actions.py b/tests/input/test_input_key_actions.py index a387f4e90..521229ae6 100644 --- a/tests/input/test_input_key_actions.py +++ b/tests/input/test_input_key_actions.py @@ -117,4 +117,22 @@ async def test_input_right_word_from_end() -> None: assert input.cursor_position == len(input.value) +async def test_input_right_word_to_the_end() -> None: + """Using right-word to get to the end should hop the correct number of times.""" + async with InputTester().run_test() as pilot: + expected_hops: dict[str | None, int] = { + "empty": 0, + "single-word": 1, + "multi-no-punctuation": 6, + "multi-punctuation": 10, + "multi-and-hyphenated": 7, + } + for input in pilot.app.query(Input): + hops = 0 + while input.cursor_position < len(input.value): + input.action_cursor_right_word() + hops += 1 + assert hops == expected_hops[input.id] + + # TODO: more tests.