use leptos::*;
use leptos_mview::mview;
mod utils;
use utils::check_str;
#[test]
fn spread_html_element() {
let attrs: Vec<(&'static str, Attribute)> = vec![
("a", "b".into_attribute()),
("data-index", 0.into_attribute()),
("class", "c".into_attribute()),
];
let res = mview! {
div {..attrs} class="b" {
"children"
}
};
check_str(
res,
r#"
children
"#,
);
}
#[test]
fn spread_in_component() {
#[component]
fn Spreadable(#[prop(attrs)] attrs: Vec<(&'static str, Attribute)>) -> impl IntoView {
mview! {
div {..attrs};
}
}
let res = mview! {
Spreadable attr:class="b" attr:contenteditable=true attr:data-index=0;
};
check_str(
res,
r#""#,
);
}
#[test]
fn spread_on_component() {
#[component]
fn Spreadable(#[prop(attrs)] attrs: Vec<(&'static str, Attribute)>) -> impl IntoView {
mview! {
div {..attrs};
}
}
let attrs: Vec<(&'static str, Attribute)> = vec![
("a", "b".into_attribute()),
("data-index", 0.into_attribute()),
("class", "c".into_attribute()),
];
let res = mview! {
Spreadable attr:contenteditable=true {..attrs};
};
check_str(
res,
r#""#,
);
}