2024-03-18 04:14:26 +00:00
|
|
|
use dioxus::prelude::*;
|
|
|
|
|
|
|
|
/// Make sure that rsx! is parsing templates and their attributes properly
|
|
|
|
#[test]
|
|
|
|
fn attributes_pass_properly() {
|
|
|
|
let h = rsx! {
|
|
|
|
circle {
|
|
|
|
cx: 50,
|
|
|
|
cy: 50,
|
|
|
|
r: 40,
|
|
|
|
stroke: "green",
|
|
|
|
fill: "yellow"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
let o = h.unwrap();
|
|
|
|
|
2024-07-30 17:16:27 +00:00
|
|
|
let template = &o.template;
|
2024-03-18 04:14:26 +00:00
|
|
|
|
|
|
|
assert_eq!(template.attr_paths.len(), 3);
|
|
|
|
|
|
|
|
let _circle = template.roots[0];
|
|
|
|
let TemplateNode::Element { attrs, tag, namespace, children } = _circle else {
|
|
|
|
panic!("Expected an element");
|
|
|
|
};
|
|
|
|
|
|
|
|
assert_eq!(tag, "circle");
|
|
|
|
assert_eq!(namespace, Some("http://www.w3.org/2000/svg"));
|
|
|
|
assert_eq!(children.len(), 0);
|
|
|
|
assert_eq!(attrs.len(), 5);
|
|
|
|
}
|