dioxus/packages/core/tests/safety.rs

20 lines
496 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::*;
2024-01-11 01:21:15 +00:00
/// Ensure no issues with not calling rebuild_to_vec
2022-11-23 02:38:27 +00:00
#[test]
fn root_node_isnt_null() {
2024-01-11 21:18:11 +00:00
let dom = VirtualDom::new(|| render!("Hello world!"));
2022-11-23 02:38:27 +00:00
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());
2024-01-11 21:18:11 +00:00
dom.in_runtime(|| {
// The height should be 0
assert_eq!(ScopeId::ROOT.height(), 0);
});
2022-11-23 02:38:27 +00:00
}