attributes_pass.rs 801 B

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