test(tree): add output test for tree format

This commit is contained in:
Orhun Parmaksız 2021-12-18 14:28:57 +03:00
parent 251327519b
commit 5a729d8acb
No known key found for this signature in database
GPG key ID: F83424824B3E4B90

View file

@ -221,9 +221,28 @@ mod tests {
}
#[test]
fn test_print_line() {
let value = String::from("abc\ndef");
fn test_tree_output() {
env::set_var("NO_COLOR", "1");
let lines = ["a", "a/b/e", "a/b", "a/b/c/d"];
let tree = Tree::from_input(&mut lines.iter(), '/');
let mut output = Vec::new();
tree.print(&mut output, Color::White).unwrap();
let expected_output = "\
a
b
e
c
d\n";
assert_eq!(expected_output, String::from_utf8_lossy(&output));
}
#[test]
fn test_print_line() {
env::set_var("NO_COLOR", "1");
let value = String::from("abc\ndef");
let mut output = Vec::new();
TreeNode {