Skip to content

Commit

Permalink
Add additional tests for multi-progress multiline rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
happenslol authored and djc committed Sep 22, 2022
1 parent be579da commit 222df5b
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions tests/render.rs
Expand Up @@ -774,3 +774,89 @@ fn multi_zombie_handling() {

assert_eq!(in_mem.contents(), "pb1 done!\npb3 done!\npb2 done!");
}

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

let pb1 = mp.add(ProgressBar::new_spinner().with_message("test1"));
let pb2 = mp.add(ProgressBar::new_spinner().with_message("test2"));

assert_eq!(in_mem.contents(), "");

pb1.inc(1);
pb2.inc(1);

assert_eq!(
in_mem.contents(),
r#"
⠁ test1
⠁ test2
"#
.trim()
);

pb1.set_message("test1\n test1 line2\n test1 line3");

assert_eq!(
in_mem.contents(),
r#"
⠁ test1
test1 line2
test1 line3
⠁ test2
"#
.trim()
);

pb1.inc(1);
pb2.inc(1);

assert_eq!(
in_mem.contents(),
r#"
⠉ test1
test1 line2
test1 line3
⠉ test2
"#
.trim()
);

pb2.set_message("test2\n test2 line2");

assert_eq!(
in_mem.contents(),
r#"
⠉ test1
test1 line2
test1 line3
⠉ test2
test2 line2
"#
.trim()
);

pb1.set_message("single line again");

assert_eq!(
in_mem.contents(),
r#"
⠉ single line again
⠉ test2
test2 line2
"#
.trim()
);

pb1.finish_with_message("test1 done!");
pb2.finish_with_message("test2 done!");

assert_eq!(
in_mem.contents(),
r#" test1 done!
test2 done!"#
);
}

0 comments on commit 222df5b

Please sign in to comment.