diff options
author | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-03 14:48:22 +0530 |
---|---|---|
committer | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-03 14:49:21 +0530 |
commit | 748dfc353a7d8c7bbb6bbfb097bacec18b80e32a (patch) | |
tree | 7d04a7f9887a5672c8cc8fa10ee1310d36d37433 /tests | |
parent | a76ad5009ac9177e1efb37130d1dcedb5df1e5de (diff) |
add 'k' navigation key
Diffstat (limited to 'tests')
-rw-r--r-- | tests/interactive.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/interactive.rs b/tests/interactive.rs index 5b9136f..50d80c8 100644 --- a/tests/interactive.rs +++ b/tests/interactive.rs @@ -118,14 +118,35 @@ mod app { } // Entry-Navigation - // when hitting the j key { + // when hitting the j key app.process_events(&mut terminal, b"j".keys())?; assert_eq!( node_by_name(&app, fixture_str(long_root)), node_by_index(&app, *app.state.selected.as_ref().unwrap()), "it moves the cursor down and selects the next entry based on the current sort mode" ); + // when hitting it while there is nowhere to go + app.process_events(&mut terminal, b"j".keys())?; + assert_eq!( + node_by_name(&app, fixture_str(long_root)), + node_by_index(&app, *app.state.selected.as_ref().unwrap()), + "it stays at the previous position" + ); + // when hitting the k key + app.process_events(&mut terminal, b"k".keys())?; + assert_eq!( + node_by_name(&app, fixture_str(short_root)), + node_by_index(&app, *app.state.selected.as_ref().unwrap()), + "it moves the cursor up and selects the next entry based on the current sort mode" + ); + // when hitting the k key again + app.process_events(&mut terminal, b"k".keys())?; + assert_eq!( + node_by_name(&app, fixture_str(short_root)), + node_by_index(&app, *app.state.selected.as_ref().unwrap()), + "it stays at the current cursor position as there is nowhere to go" + ); } Ok(()) |