Add tests for ^BSpace (^H)
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
from testing.runner import and_exit
|
from testing.runner import and_exit
|
||||||
from testing.runner import run
|
from testing.runner import run
|
||||||
|
|
||||||
@@ -42,27 +44,37 @@ def test_key_navigation_in_command_mode():
|
|||||||
h.await_cursor_position(x=11, y=23)
|
h.await_cursor_position(x=11, y=23)
|
||||||
h.await_text('\nhello world\n')
|
h.await_text('\nhello world\n')
|
||||||
|
|
||||||
h.press('Bspace')
|
|
||||||
h.await_cursor_position(x=10, y=23)
|
|
||||||
h.await_text('\nhello worl\n')
|
|
||||||
|
|
||||||
h.press('Home')
|
h.press('Home')
|
||||||
|
|
||||||
h.press('Bspace') # does nothing at beginning
|
|
||||||
h.await_cursor_position(x=0, y=23)
|
|
||||||
h.await_text('\nhello worl\n')
|
|
||||||
|
|
||||||
h.press('DC')
|
h.press('DC')
|
||||||
h.await_cursor_position(x=0, y=23)
|
h.await_cursor_position(x=0, y=23)
|
||||||
h.await_text('\nello worl\n')
|
h.await_text('\nello world\n')
|
||||||
|
|
||||||
# unknown keys don't do anything
|
# unknown keys don't do anything
|
||||||
h.press('^J')
|
h.press('^J')
|
||||||
h.await_text('\nello worl\n')
|
h.await_text('\nello world\n')
|
||||||
|
|
||||||
h.press('Enter')
|
h.press('Enter')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('key', ('BSpace', '^H'))
|
||||||
|
def test_command_mode_backspace(key):
|
||||||
|
with run() as h, and_exit(h):
|
||||||
|
trigger_command_mode(h)
|
||||||
|
h.press('hello world')
|
||||||
|
h.await_text('\nhello world\n')
|
||||||
|
|
||||||
|
h.press(key)
|
||||||
|
h.await_text('\nhello worl\n')
|
||||||
|
|
||||||
|
h.press('Home')
|
||||||
|
h.press(key) # does nothing at beginning
|
||||||
|
h.await_cursor_position(x=0, y=23)
|
||||||
|
h.await_text('\nhello worl\n')
|
||||||
|
|
||||||
|
h.press('^C')
|
||||||
|
|
||||||
|
|
||||||
def test_command_mode_ctrl_k():
|
def test_command_mode_ctrl_k():
|
||||||
with run() as h, and_exit(h):
|
with run() as h, and_exit(h):
|
||||||
trigger_command_mode(h)
|
trigger_command_mode(h)
|
||||||
|
|||||||
@@ -204,6 +204,24 @@ def test_search_multiple_sessions_append_to_history(xdg_data_home):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('key', ('BSpace', '^H'))
|
||||||
|
def test_search_reverse_search_history_backspace(xdg_data_home, key):
|
||||||
|
xdg_data_home.join('babi/history/search').ensure().write(
|
||||||
|
'line_5\n'
|
||||||
|
'line_3\n'
|
||||||
|
'line_1\n',
|
||||||
|
)
|
||||||
|
with run() as h, and_exit(h):
|
||||||
|
h.press('^W')
|
||||||
|
h.press('^R')
|
||||||
|
h.await_text('search(reverse-search)``:')
|
||||||
|
h.press('linea')
|
||||||
|
h.await_text('search(failed reverse-search)`linea`: line_1')
|
||||||
|
h.press(key)
|
||||||
|
h.await_text('search(reverse-search)`line`: line_1')
|
||||||
|
h.press('^C')
|
||||||
|
|
||||||
|
|
||||||
def test_search_reverse_search_history(xdg_data_home, ten_lines):
|
def test_search_reverse_search_history(xdg_data_home, ten_lines):
|
||||||
xdg_data_home.join('babi/history/search').ensure().write(
|
xdg_data_home.join('babi/history/search').ensure().write(
|
||||||
'line_5\n'
|
'line_5\n'
|
||||||
@@ -216,10 +234,6 @@ def test_search_reverse_search_history(xdg_data_home, ten_lines):
|
|||||||
h.await_text('search(reverse-search)``:')
|
h.await_text('search(reverse-search)``:')
|
||||||
h.press('line')
|
h.press('line')
|
||||||
h.await_text('search(reverse-search)`line`: line_1')
|
h.await_text('search(reverse-search)`line`: line_1')
|
||||||
h.press('a')
|
|
||||||
h.await_text('search(failed reverse-search)`linea`: line_1')
|
|
||||||
h.press('BSpace')
|
|
||||||
h.await_text('search(reverse-search)`line`: line_1')
|
|
||||||
h.press('^R')
|
h.press('^R')
|
||||||
h.await_text('search(reverse-search)`line`: line_3')
|
h.await_text('search(reverse-search)`line`: line_3')
|
||||||
h.press('Enter')
|
h.press('Enter')
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
from testing.runner import and_exit
|
from testing.runner import and_exit
|
||||||
from testing.runner import run
|
from testing.runner import run
|
||||||
|
|
||||||
@@ -14,7 +16,7 @@ def test_basic_text_editing(tmpdir):
|
|||||||
|
|
||||||
def test_backspace_at_beginning_of_file():
|
def test_backspace_at_beginning_of_file():
|
||||||
with run() as h, and_exit(h):
|
with run() as h, and_exit(h):
|
||||||
h.press('Bspace')
|
h.press('BSpace')
|
||||||
h.await_text_missing('unknown key')
|
h.await_text_missing('unknown key')
|
||||||
assert h.screenshot().strip().splitlines()[1:] == []
|
assert h.screenshot().strip().splitlines()[1:] == []
|
||||||
assert '*' not in h.screenshot()
|
assert '*' not in h.screenshot()
|
||||||
@@ -27,7 +29,7 @@ def test_backspace_joins_lines(tmpdir):
|
|||||||
with run(str(f)) as h, and_exit(h):
|
with run(str(f)) as h, and_exit(h):
|
||||||
h.await_text('foo')
|
h.await_text('foo')
|
||||||
h.press('Down')
|
h.press('Down')
|
||||||
h.press('Bspace')
|
h.press('BSpace')
|
||||||
h.await_text('foobar')
|
h.await_text('foobar')
|
||||||
h.await_text('f *')
|
h.await_text('f *')
|
||||||
h.await_cursor_position(x=3, y=1)
|
h.await_cursor_position(x=3, y=1)
|
||||||
@@ -43,13 +45,14 @@ def test_backspace_at_end_of_file_still_allows_scrolling_down(tmpdir):
|
|||||||
with run(str(f)) as h, and_exit(h):
|
with run(str(f)) as h, and_exit(h):
|
||||||
h.await_text('hello world')
|
h.await_text('hello world')
|
||||||
h.press('Down')
|
h.press('Down')
|
||||||
h.press('Bspace')
|
h.press('BSpace')
|
||||||
h.press('Down')
|
h.press('Down')
|
||||||
h.await_cursor_position(x=0, y=2)
|
h.await_cursor_position(x=0, y=2)
|
||||||
assert '*' not in h.screenshot()
|
assert '*' not in h.screenshot()
|
||||||
|
|
||||||
|
|
||||||
def test_backspace_deletes_text(tmpdir):
|
@pytest.mark.parametrize('key', ('BSpace', '^H'))
|
||||||
|
def test_backspace_deletes_text(tmpdir, key):
|
||||||
f = tmpdir.join('f')
|
f = tmpdir.join('f')
|
||||||
f.write('ohai there')
|
f.write('ohai there')
|
||||||
|
|
||||||
@@ -57,7 +60,7 @@ def test_backspace_deletes_text(tmpdir):
|
|||||||
h.await_text('ohai there')
|
h.await_text('ohai there')
|
||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
h.press('Right')
|
h.press('Right')
|
||||||
h.press('Bspace')
|
h.press(key)
|
||||||
h.await_text('ohi')
|
h.await_text('ohi')
|
||||||
h.await_text('f *')
|
h.await_text('f *')
|
||||||
h.await_cursor_position(x=2, y=1)
|
h.await_cursor_position(x=2, y=1)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ def test_undo_redo_action_interrupts_actions():
|
|||||||
with run() as h, and_exit(h):
|
with run() as h, and_exit(h):
|
||||||
h.press('hello')
|
h.press('hello')
|
||||||
h.await_text('hello')
|
h.await_text('hello')
|
||||||
h.press('Bspace')
|
h.press('BSpace')
|
||||||
h.await_text_missing('hello')
|
h.await_text_missing('hello')
|
||||||
h.press('M-u')
|
h.press('M-u')
|
||||||
h.await_text('hello')
|
h.await_text('hello')
|
||||||
|
|||||||
Reference in New Issue
Block a user