try fix CI test

This commit is contained in:
Adrian Wannenmacher 2022-12-16 12:33:46 +01:00
parent 75357e974d
commit 38915b1f96
No known key found for this signature in database
GPG key ID: 19D986ECB1E492D5
2 changed files with 74 additions and 0 deletions

View file

@ -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"

View 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();
}