summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSebastian Thiel <sthiel@thoughtworks.com>2019-06-03 12:03:43 +0530
committerSebastian Thiel <sthiel@thoughtworks.com>2019-06-03 12:03:43 +0530
commit05c8ec1a6e2ce9af3f55d75cb761cf3b66244bb8 (patch)
tree12bd04d0864f9232debad5ccefb76ab2c7d82741 /tests
parent11147d8e344435b95adaca68e5125836c0bf2ed9 (diff)
The first test for user input, yeah!
Diffstat (limited to 'tests')
-rw-r--r--tests/interactive.rs27
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/interactive.rs b/tests/interactive.rs
index 159f05e..1fb32da 100644
--- a/tests/interactive.rs
+++ b/tests/interactive.rs
@@ -1,10 +1,13 @@
mod app {
- use dua::interactive::{EntryData, TerminalApp, Tree, TreeIndexType};
- use dua::{ByteFormat, Color, TraversalSorting, WalkOptions};
+ use dua::{
+ interactive::{widgets::SortMode, EntryData, TerminalApp, Tree, TreeIndexType},
+ ByteFormat, Color, TraversalSorting, WalkOptions,
+ };
use failure::Error;
use petgraph::prelude::NodeIndex;
use pretty_assertions::assert_eq;
use std::{ffi::OsString, fmt, path::Path};
+ use termion::input::TermRead;
use tui::backend::TestBackend;
use tui::Terminal;
@@ -38,6 +41,26 @@ mod app {
Ok(())
}
+ #[test]
+ fn simple_user_journey() -> Result<(), Error> {
+ let (mut terminal, mut app) = initialized_app_and_terminal("sample-02")?;
+ assert_eq!(
+ app.state.sorting,
+ SortMode::SizeDescending,
+ "it starts in descending order by size"
+ );
+
+ // when hitting the S key
+ app.process_events(&mut terminal, b"s".keys())?;
+ assert_eq!(
+ app.state.sorting,
+ SortMode::SizeAscending,
+ "it sets the sort to size ascending"
+ );
+
+ Ok(())
+ }
+
fn initialized_app_and_terminal(
fixture_path: &str,
) -> Result<(Terminal<TestBackend>, TerminalApp), Error> {