aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/console/html_output_formatter_test.rs
blob: 2274ffe3db2067b8b55be4bf235b8aeff66a94a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//! ref: composer/tests/Composer/Test/Console/HtmlOutputFormatterTest.php

use indexmap::IndexMap;
use shirabe::console::html_output_formatter::HtmlOutputFormatter;
use shirabe_external_packages::symfony::console::formatter::{
    OutputFormatterStyle, OutputFormatterStyleInterface,
};

#[test]
#[ignore]
fn test_formatting() {
    let mut styles: IndexMap<String, Box<dyn OutputFormatterStyleInterface>> = IndexMap::new();
    styles.insert(
        "warning".to_string(),
        Box::new(OutputFormatterStyle::new(
            Some("black"),
            Some("yellow"),
            vec![],
        )),
    );

    let mut formatter = HtmlOutputFormatter::new(styles);

    assert_eq!(
        Some(
            "text <span style=\"color:green;\">green</span> <span style=\"color:yellow;\">yellow</span> <span style=\"color:black;background-color:yellow;\">black w/ yellow bg</span>"
                .to_string()
        ),
        formatter
            .format(Some(
                "text <info>green</info> <comment>yellow</comment> <warning>black w/ yellow bg</warning>"
            ))
            .unwrap()
    );
}