mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 22:54:12 +00:00
try fix CI test
This commit is contained in:
parent
75357e974d
commit
38915b1f96
2 changed files with 74 additions and 0 deletions
|
@ -23,6 +23,7 @@ thiserror = "1.0.37"
|
|||
[features]
|
||||
regex = ["dioxus-router-core/regex"]
|
||||
serde = ["dioxus-router-core/serde"]
|
||||
wasm_test = []
|
||||
web = ["dioxus-router-core/web"]
|
||||
|
||||
[dev-dependencies]
|
||||
|
@ -35,3 +36,7 @@ dioxus-desktop = { path = "../desktop" }
|
|||
[target.'cfg(target_family = "wasm")'.dev-dependencies]
|
||||
dioxus-router = { path = ".", features = ["web"] }
|
||||
dioxus-web = { path= "../web" }
|
||||
|
||||
[target.'cfg(feature = "wasm_test")'.dev-dependencies]
|
||||
gloo = "0.8.0"
|
||||
wasm-bindgen-test = "0.3.33"
|
||||
|
|
69
packages/router/tests/web_router.rs
Normal file
69
packages/router/tests/web_router.rs
Normal file
|
@ -0,0 +1,69 @@
|
|||
#![cfg(feature = "wasm_test")]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_router::prelude::*;
|
||||
use gloo::utils::document;
|
||||
use wasm_bindgen_test::*;
|
||||
|
||||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn simple_test() {
|
||||
fn main() {
|
||||
console_error_panic_hook::set_once();
|
||||
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
|
||||
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();
|
||||
}
|
Loading…
Reference in a new issue