safety.rs 650 B

12345678910111213141516171819202122
  1. //! Tests related to safety of the library.
  2. use dioxus::prelude::*;
  3. use dioxus_core::SuspenseContext;
  4. /// Ensure no issues with not calling rebuild
  5. #[test]
  6. fn root_node_isnt_null() {
  7. let dom = VirtualDom::new(|cx| render!("Hello world!"));
  8. let scope = dom.base_scope();
  9. // We haven't built the tree, so trying to get out the root node should fail
  10. assert!(scope.try_root_node().is_none());
  11. // The height should be 0
  12. assert_eq!(scope.height(), 0);
  13. // There should be a default suspense context
  14. // todo: there should also be a default error boundary
  15. assert!(scope.has_context::<SuspenseContext>().is_some());
  16. }