Add a test for using right-word to get to the end of an input

This commit is contained in:
Dave Pearson
2023-01-29 11:53:21 +00:00
parent 5bf0542e47
commit 054c23ab29

View File

@@ -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.