Add a test for using left-word to get home from the end of an input

This commit is contained in:
Dave Pearson
2023-01-29 11:57:00 +00:00
parent 054c23ab29
commit b7203edd4a

View File

@@ -135,4 +135,23 @@ async def test_input_right_word_to_the_end() -> None:
assert hops == expected_hops[input.id]
async def test_input_left_word_from_the_end() -> None:
"""Using left-word to get home from 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):
input.action_end()
hops = 0
while input.cursor_position:
input.action_cursor_left_word()
hops += 1
assert hops == expected_hops[input.id]
# TODO: more tests.