dioxus/packages/core/tests/safety.rs

20 lines
496 B
Rust
Raw Normal View History

2022-11-22 21:32:26 -08:00
//! Tests related to safety of the library.
2022-11-22 18:38:27 -08:00
use dioxus::prelude::*;
2024-01-10 19:21:15 -06:00
/// Ensure no issues with not calling rebuild_to_vec
2022-11-22 18:38:27 -08:00
#[test]
fn root_node_isnt_null() {
2024-01-11 15:18:11 -06:00
let dom = VirtualDom::new(|| render!("Hello world!"));
2022-11-22 18:38:27 -08:00
let scope = dom.base_scope();
2022-11-22 21:32:26 -08: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 15:18:11 -06:00
dom.in_runtime(|| {
// The height should be 0
assert_eq!(ScopeId::ROOT.height(), 0);
});
2022-11-22 18:38:27 -08:00
}