1
use crate::{Help, Section};
2
use std::collections::HashMap;
3

            
4
#[test]
5
2
fn test_help_section_format() {
6
1
    let help_section = Section {
7
1
        title: String::from("Test section title"),
8
1
        entries: HashMap::from([("x", "x doc"), ("yy", "yy doc")]),
9
    };
10
1
    let expected_output = r#"Test section title
11
  x  => x doc
12
  yy => yy doc"#;
13
1
    assert_eq!(help_section.format(), expected_output);
14
2
}
15

            
16
#[test]
17
2
fn test_help_format() {
18
1
    let help_section_1 = Section {
19
1
        title: String::from("Test section title"),
20
1
        entries: HashMap::from([("x", "x doc"), ("yy", "yy doc")]),
21
    };
22
1
    let help_section_2 = Section {
23
1
        title: String::from("Other test section title"),
24
1
        entries: HashMap::from([("blah", "blah doc"), ("derp", "derp doc")]),
25
    };
26
1
    let help = Help {
27
1
        sections: vec![help_section_1, help_section_2],
28
    };
29
1
    let expected_output = r#"Test section title
30
  x  => x doc
31
  yy => yy doc
32

            
33
Other test section title
34
  blah => blah doc
35
  derp => derp doc"#;
36
1
    assert_eq!(help.format(), expected_output);
37
2
}