use html_node::{
text,
typed::{self, elements::*, html},
};
#[test]
fn basic() {
let shopping_list = vec!["milk", "eggs", "bread"];
let html = html! {
};
let expected = "\
\
";
assert_eq!(html.to_string(), expected);
}
#[test]
fn pretty_printed() {
let shopping_list = vec!["milk", "eggs", "bread"];
let html = html! {
};
println!("--- pretty-printed ---\n{html:#}");
let expected = "\
\
";
let pretty_html = format!("{html:#}");
assert_eq!(pretty_html, expected);
}
#[test]
fn component() {
typed::component! {
ShoppingListItem {
index: i32,
};
|ShoppingListItemAttributes { index }, _, children| html! {
}
}
let shopping_list = vec!["milk", "eggs", "bread"];
let html = html! {
Shopping List
{ shopping_list.into_iter().zip(1..).map(|(item, i)| html! {
{text!("{item}")}
}) }
};
let expected = "\
\
";
assert_eq!(html.to_string(), expected);
}