mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add a test for using left-word to get home from the end of an input
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user