diff --git a/tests/render.rs b/tests/render.rs index 0d8a5a67..1dc368ce 100644 --- a/tests/render.rs +++ b/tests/render.rs @@ -4,6 +4,7 @@ use indicatif::{ InMemoryTerm, MultiProgress, ProgressBar, ProgressDrawTarget, ProgressFinish, ProgressStyle, TermLike, }; +use std::time::Duration; #[test] fn basic_progress_bar() { @@ -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 = 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" + ); +}