1
0

safety.rs 672 B

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