update tests
This commit is contained in:
1 parent
58b74c1155
commit
35befa1784
12 files changed
+334
-236
No files matched your search
@@ -6,10 +6,58 @@ use std::sync::Arc;
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_router::prelude::*;
|
||||
use gloo::utils::document;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::str::FromStr;
|
||||
use wasm_bindgen_test::*;
|
||||
|
||||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Routable)]
|
||||
enum Route {
|
||||
#[route("/")]
|
||||
Home {},
|
||||
#[nest("/blog")]
|
||||
#[route("/")]
|
||||
BlogList {},
|
||||
#[route("/:id")]
|
||||
BlogPost { id: usize },
|
||||
}
|
||||
|
||||
fn App(cx: Scope) -> Element {
|
||||
render!(Router {
|
||||
config: RouterConfiguration {
|
||||
history: Box::<WebHistory<Route>>::default(),
|
||||
..Default::default()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[inline_props]
|
||||
fn Home(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
h1 { "Home" }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[inline_props]
|
||||
fn BlogList(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[inline_props]
|
||||
fn BlogPost(cx: Scope, id: usize) -> Element {
|
||||
cx.render(rsx! {
|
||||
div { }
|
||||
})
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn simple_test() {
|
||||
fn main() {
|
||||
@@ -18,51 +66,6 @@ fn simple_test() {
|
||||
dioxus_web::launch(App);
|
||||
}
|
||||
|
||||
fn App(cx: Scope) -> Element {
|
||||
use_router(
|
||||
cx,
|
||||
&|| RouterConfiguration {
|
||||
on_update: Some(Arc::new(|_| None)),
|
||||
..Default::default()
|
||||
},
|
||||
&|| {
|
||||
Segment::content(comp(Home)).fixed(
|
||||
"blog",
|
||||
Route::empty().nested(
|
||||
Segment::content(comp(BlogList)).catch_all((comp(BlogPost), PostId {})),
|
||||
),
|
||||
)
|
||||
},
|
||||
);
|
||||
|
||||
render!(Outlet {})
|
||||
}
|
||||
|
||||
fn Home(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
h1 { "Home" }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn BlogList(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
struct PostId;
|
||||
fn BlogPost(cx: Scope) -> Element {
|
||||
let _id = use_route(cx)?.parameter::<PostId>().unwrap();
|
||||
|
||||
cx.render(rsx! {
|
||||
div { }
|
||||
})
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
let _ = document();
|
||||
|
||||
Reference in new issue
Block a user