wip: error boundary

This commit is contained in:
Jonathan Kelley committed 2022-11-22 18:38:27 -08:00
1 parent 112c954e00
commit 0e5a59f9ed
17 files changed
+343 -316

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
use dioxus::prelude::*;
use dioxus_core::SuspenseContext;
/// Ensure no issues with not building the virtualdom before
#[test]
fn root_node_isnt_null() {
let dom = VirtualDom::new(|cx| render!("Hello world!"));
let scope = dom.base_scope();
// The root should be a valid pointer
assert_ne!(scope.root_node() as *const _, std::ptr::null_mut());
// 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());
}
+3 -3
View File
@@ -1,6 +1,6 @@
//! Verify that tasks get polled by the virtualdom properly, and that we escape wait_for_work safely
use dioxus_core::*;
use dioxus::prelude::*;
use std::time::Duration;
#[tokio::test]
@@ -11,7 +11,7 @@ async fn it_works() {
tokio::select! {
_ = dom.wait_for_work() => {}
_ = tokio::time::sleep(Duration::from_millis(1000)) => {}
_ = tokio::time::sleep(Duration::from_millis(600)) => {}
};
}
@@ -32,5 +32,5 @@ fn app(cx: Scope) -> Element {
});
});
None
cx.render(rsx!(()))
}