diff options
author | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-03 16:06:02 +0530 |
---|---|---|
committer | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-03 16:06:02 +0530 |
commit | 84b6f8ce829e7a57604b4e983c91bc52a7299ac4 (patch) | |
tree | 144987beb596c72643bf136d84cde9ab2a355266 /tests | |
parent | 74e511631a7f05143e487584a4325fe65c774ba5 (diff) |
add 'u' key to go up one level
Diffstat (limited to 'tests')
-rw-r--r-- | tests/interactive.rs | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/tests/interactive.rs b/tests/interactive.rs index 8d5eb18..e21a092 100644 --- a/tests/interactive.rs +++ b/tests/interactive.rs @@ -115,6 +115,11 @@ mod app { node_by_index(&app, *app.state.selected.as_ref().unwrap()), "it selects the first node in the list", ); + + assert_eq!( + app.traversal.root_index, app.state.root, + "the root is the 'virtual' root", + ); } // SORTING @@ -179,20 +184,36 @@ mod app { "it selects the first entry in the directory" ); - // when trying to enter a file (a node with no children) - app.process_events(&mut terminal, b"jo".keys())?; + // when hitting the u key while inside a sub-directory + app.process_events(&mut terminal, b"u".keys())?; { assert_eq!( - new_root_idx, app.state.root, - "it does not enter it, keeping the previous root" + app.traversal.root_index, + app.state.root, + "it sets the root to be the (roots) parent directory, being the virtual root" ); assert_eq!( - node_by_index(&app, index_by_name(&app, ".hidden.666")), + node_by_name(&app, fixture_str(short_root)), node_by_index(&app, *app.state.selected.as_ref().unwrap()), - "it does not change the selection" + "changes the selection to the first item in the list of entries" ); } } + // when hitting the u key while inside of the root directory + // We are moving the cursor down just to have a non-default selection + app.process_events(&mut terminal, b"ju".keys())?; + { + assert_eq!( + app.traversal.root_index, + app.state.root, + "it keeps the root - it can't go further up" + ); + assert_eq!( + node_by_name(&app, fixture_str(long_root)), + node_by_index(&app, *app.state.selected.as_ref().unwrap()), + "keeps the previous selection" + ); + } } Ok(()) |