mod readme_component_set;

use coyotes::Html;
use readme_component_set as rcs;

#[test]
fn no_added_spaces() {
    let template = rcs::no_added_spaces();
    let expected = "<p>hai :3</p>";

    let mut html = Html::new();
    let results = html.render(&template);

    assert_eq!(Ok(expected.to_string()), results);
}

#[test]
fn collapse_spaces_and_new_lines() {
    let template = rcs::collapse_spaces_and_new_lines();
    let expected = "<p>\n\thai :3\n</p>";

    let mut html = Html::new();
    let results = html.render(&template);

    assert_eq!(Ok(expected.to_string()), results);
}

#[test]
fn attribute_collapse_spaces() {
    let template = rcs::attribute_collapse_spaces();
    let expected = "<p attr attr2 att3></p>";

    let mut html = Html::new();
    let results = html.render(&template);

    assert_eq!(Ok(expected.to_string()), results);
}

#[test]
fn attribute_preserve_new_lines() {
    let template = rcs::attribute_preserve_new_lines();
    let expected = "<p\n\tattr\n\tattr2\n\tattr3>\n</p>";

    let mut html = Html::new();
    let results = html.render(&template);

    assert_eq!(Ok(expected.to_string()), results);
}

#[test]
fn attribute_values_preserve_new_lines() {
    let template = rcs::attribute_values_preserve_new_lines();
    let expected = "<p\n\tattr='\n\n\t\thai :3 hello!\n\n\t'\n></p>";

    let mut html = Html::new();
    let results = html.render(&template);

    assert_eq!(Ok(expected.to_string()), results);
}

#[test]
fn attribute_injections() {
    let template = rcs::attribute_injections();
    let expected = "<p hai hello></p>";

    let mut html = Html::new();
    let results = html.render(&template);

    assert_eq!(Ok(expected.to_string()), results);
}

#[test]
fn attribute_injections_with_new_lines() {
    let template = rcs::attribute_injections_with_new_lines();
    let expected = "<p\n\thai\n\thello></p>";

    let mut html = Html::new();
    let results = html.render(&template);

    assert_eq!(Ok(expected.to_string()), results);
}

#[test]
fn component_injections() {
    let template = rcs::component_injections();
    let expected = "<p> <span>hai :3</span>\n\t<span>hello</span>\n</p>";

    let mut html = Html::new();
    let results = html.render(&template);

    assert_eq!(Ok(expected.to_string()), results);
}

#[test]
fn text_component_injections() {
    let template = rcs::text_component_injections();
    let expected = "<p>\n\n\thai :3\n\n</p>";

    let mut html = Html::new();
    let results = html.render(&template);

    assert_eq!(Ok(expected.to_string()), results);
}
