Skip to content

Commit

Permalink
add render test for Ticker drop behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-laplante committed Mar 19, 2022
1 parent 94aff04 commit 515a2a9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use indicatif::{
InMemoryTerm, MultiProgress, ProgressBar, ProgressDrawTarget, ProgressFinish, ProgressStyle,
TermLike,
};
use std::time::Duration;

#[test]
fn basic_progress_bar() {
Expand Down Expand Up @@ -242,3 +243,28 @@ Another line printed"#
.trim()
);
}

#[test]
fn ticker_drop() {
let in_mem = InMemoryTerm::new(10, 80);
let mp =
MultiProgress::with_draw_target(ProgressDrawTarget::term_like(Box::new(in_mem.clone())));

let mut spinner: Option<ProgressBar> = None;

for i in 0..5 {
let new_spinner = mp.add(
ProgressBar::new_spinner()
.with_finish(ProgressFinish::AndLeave)
.with_message(format!("doing stuff {}", i)),
);
new_spinner.enable_steady_tick(Duration::from_millis(50));
spinner.replace(new_spinner);
}

drop(spinner);
assert_eq!(
in_mem.contents(),
" doing stuff 0\n doing stuff 1\n doing stuff 2\n doing stuff 3\n doing stuff 4"
);
}

0 comments on commit 515a2a9

Please sign in to comment.