Skip to content

Commit

Permalink
Attempt to stop tests from interferring with each other.
Browse files Browse the repository at this point in the history
  • Loading branch information
finnbear committed Sep 11, 2024
1 parent 4e01d07 commit ba487e2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/yew-router/tests/link.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::sync::Mutex;
use std::time::Duration;

use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -80,6 +81,10 @@ fn navigation_menu() -> Html {
}
}

/// When multiple tests use browser router, and at least one has a base name,
/// can't run them at the same time.
static BROWSER_ROUTER: Mutex<()> = Mutex::new(());

#[function_component(RootForBrowserRouter)]
fn root_for_browser_router() -> Html {
html! {
Expand All @@ -91,6 +96,7 @@ fn root_for_browser_router() -> Html {

#[test]
async fn link_in_browser_router() {
let _guard = BROWSER_ROUTER.lock().unwrap();
let div = gloo::utils::document().create_element("div").unwrap();
let _ = div.set_attribute("id", "browser-router");
let _ = gloo::utils::body().append_child(&div);
Expand All @@ -113,9 +119,9 @@ async fn link_in_browser_router() {
"/search?q=Rust&lang=en_US",
link_href("#browser-router ul > li.search-q-lang > a")
);
drop(_guard);
}

/*
#[function_component(RootForBasename)]
fn root_for_basename() -> Html {
html! {
Expand All @@ -127,6 +133,7 @@ fn root_for_basename() -> Html {

#[test]
async fn link_with_basename() {
let _guard = BROWSER_ROUTER.lock().unwrap();
let div = gloo::utils::document().create_element("div").unwrap();
let _ = div.set_attribute("id", "with-basename");
let _ = gloo::utils::body().append_child(&div);
Expand All @@ -152,8 +159,8 @@ async fn link_with_basename() {
"/base/search?q=Rust&lang=en_US",
link_href("#with-basename ul > li.search-q-lang > a")
);
drop(_guard);
}
*/

#[function_component(RootForHashRouter)]
fn root_for_hash_router() -> Html {
Expand Down

0 comments on commit ba487e2

Please sign in to comment.