Skip to content

Commit

Permalink
Tests for refresh & selection
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrwach committed Jan 20, 2024
1 parent 65f6735 commit dcff2ee
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/interactive/app/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,13 @@ mod tests {
B: Backend,
{
while self.state.scan.is_some() {
if let Some(res) = self.state.process_event(
self.state.process_event(
&mut self.window,
&mut self.traversal,
&mut self.display,
terminal,
&events,
)? {
return Ok(res);
}
)?;
}
Ok(WalkResult {
num_errors: self.stats.io_errors,
Expand Down
45 changes: 45 additions & 0 deletions src/interactive/app/tests/journeys_readonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,51 @@ fn simple_user_journey_read_only() -> Result<()> {
assert!(app.window.glob_pane.is_none());
}

// Refresh finishes eventually
{
assert!(app.state.scan.is_none());

// 'R' refreshes all entries in the view
app.process_events(&mut terminal, into_events([
Event::Key(KeyEvent::new(KeyCode::Char('R'), KeyModifiers::NONE)),
]))?;
assert!(app.state.scan.is_some());

// refresh should finish eventually
app.run_until_traversed(&mut terminal, into_events([]))?;
assert!(app.state.scan.is_none());
}

// Refresh finishes eventually
{
// Refresh is not running
assert!(app.state.scan.is_none());

app.process_events(&mut terminal, into_codes("j"))?;
assert_eq!(
node_by_name(&app, fixture_str(long_root)),
node_by_index(&app, *app.state.navigation().selected.as_ref().unwrap()),
"it moves the cursor down and selects the next item based on the current sort mode"
);

// 'R' refreshes all entries in the view
app.process_events(&mut terminal, into_events([
Event::Key(KeyEvent::new(KeyCode::Char('R'), KeyModifiers::NONE)),
]))?;
assert!(app.state.scan.is_some());

// Refresh should finish
app.run_until_traversed(&mut terminal, into_events([]))?;
assert!(app.state.scan.is_none());

// Previous selection is preserved
assert_eq!(
node_by_name(&app, fixture_str(long_root)),
node_by_index(&app, *app.state.navigation().selected.as_ref().unwrap()),
"previous selection is preserved after refresh"
);
}

// Entry-Navigation
{
// when hitting the j key
Expand Down

0 comments on commit dcff2ee

Please sign in to comment.