1
0

attributes_pass.rs 744 B

12345678910111213141516171819202122232425262728293031
  1. use dioxus::prelude::*;
  2. /// Make sure that rsx! is parsing templates and their attributes properly
  3. #[test]
  4. fn attributes_pass_properly() {
  5. let h = rsx! {
  6. circle {
  7. cx: 50,
  8. cy: 50,
  9. r: 40,
  10. stroke: "green",
  11. fill: "yellow"
  12. }
  13. };
  14. let o = h.unwrap();
  15. let template = &o.template;
  16. assert_eq!(template.attr_paths.len(), 3);
  17. let _circle = template.roots[0];
  18. let TemplateNode::Element { attrs, tag, namespace, children } = _circle else {
  19. panic!("Expected an element");
  20. };
  21. assert_eq!(tag, "circle");
  22. assert_eq!(namespace, Some("http://www.w3.org/2000/svg"));
  23. assert_eq!(children.len(), 0);
  24. assert_eq!(attrs.len(), 5);
  25. }