Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ranile committed Jun 13, 2023
1 parent 3aaea76 commit ef727b3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/yew-router-macro/src/routable_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl Routable {
Fields::Unit => quote! { Self::#ident },
Fields::Named(field) => {
let fields = field.named.iter().map(|it| {
//named fields have idents
// named fields have idents
it.ident.as_ref().unwrap()
});
quote! { Self::#ident { #(#fields: {
Expand Down
3 changes: 1 addition & 2 deletions packages/yew-router/src/macro_helpers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub use urlencoding::encode as encode_for_url;
pub use urlencoding::decode as decode_for_url;
pub use urlencoding::{decode as decode_for_url, encode as encode_for_url};

use crate::utils::strip_slash_suffix;
use crate::Routable;
Expand Down
1 change: 0 additions & 1 deletion packages/yew-router/tests/router_unit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ fn router_always_404() {
NotFound,
}


assert_eq!(
Some(AppRoute::NotFound),
AppRoute::recognize("/not/matched/route")
Expand Down
40 changes: 20 additions & 20 deletions packages/yew-router/tests/url_encoded_routes.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
use std::time::Duration;

use yew::platform::time::sleep;
use yew_router::prelude::*;
use yew::prelude::*;
use yew_router::prelude::*;

mod utils;
use utils::*;
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};
wasm_bindgen_test_configure!(run_in_browser);



#[derive(Routable, Debug, Clone, PartialEq)]
enum AppRoute {
#[at("/")]
Expand All @@ -20,20 +19,18 @@ enum AppRoute {

#[function_component]
fn Comp() -> Html {
let switch = move |routes: AppRoute| {
match routes {
AppRoute::Root => html! {
<>
<h1>{ "Root" }</h1>
<Link<AppRoute> to={AppRoute::Search { query: "a/b".to_string() }}>
{"Click me"}
</Link<AppRoute>>
</>
},
AppRoute::Search { query } => html! {
<p id="q">{ query }</p>
},
}
let switch = move |routes: AppRoute| match routes {
AppRoute::Root => html! {
<>
<h1>{ "Root" }</h1>
<Link<AppRoute> to={AppRoute::Search { query: "a/b".to_string() }}>
{"Click me"}
</Link<AppRoute>>
</>
},
AppRoute::Search { query } => html! {
<p id="q">{ query }</p>
},
};
html! {
<Switch<AppRoute> render={switch} />
Expand All @@ -49,7 +46,6 @@ fn root() -> Html {
}
}


#[test]
async fn url_encoded_roundtrip() {
yew::Renderer::<Root>::with_root(gloo::utils::document().get_element_by_id("output").unwrap())
Expand All @@ -61,7 +57,11 @@ async fn url_encoded_roundtrip() {
assert_eq!(res, "a/b");

assert_eq!(
gloo::utils::window().location().pathname().unwrap().to_string(),
gloo::utils::window()
.location()
.pathname()
.unwrap()
.to_string(),
"/search/a%2Fb"
)
}
}

0 comments on commit ef727b3

Please sign in to comment.