dioxus/packages/core/tests/safety.rs

23 lines
650 B
Rust
Raw Normal View History

2022-11-23 05:32:26 +00:00
//! Tests related to safety of the library.
2022-11-23 02:38:27 +00:00
use dioxus::prelude::*;
use dioxus_core::SuspenseContext;
2022-11-23 05:32:26 +00:00
/// Ensure no issues with not calling rebuild
2022-11-23 02:38:27 +00:00
#[test]
fn root_node_isnt_null() {
let dom = VirtualDom::new(|cx| render!("Hello world!"));
let scope = dom.base_scope();
2022-11-23 05:32:26 +00:00
// We haven't built the tree, so trying to get out the root node should fail
assert!(scope.try_root_node().is_none());
2022-11-23 02:38:27 +00:00
// The height should be 0
assert_eq!(scope.height(), 0);
// There should be a default suspense context
// todo: there should also be a default error boundary
assert!(scope.has_context::<SuspenseContext>().is_some());
}