Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic Message Batching #2421

Merged
merged 5 commits into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion packages/yew-router/tests/basename.rs
@@ -1,4 +1,6 @@
use gloo::timers::future::sleep;
use serde::{Deserialize, Serialize};
use std::time::Duration;
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};
use yew::functional::function_component;
use yew::prelude::*;
Expand Down Expand Up @@ -112,19 +114,29 @@ fn root() -> Html {
// - query parameters
// - 404 redirects
#[test]
fn router_works() {
async fn router_works() {
yew::start_app_in_element::<Root>(gloo::utils::document().get_element_by_id("output").unwrap());

sleep(Duration::ZERO).await;

assert_eq!("Home", obtain_result_by_id("result"));

sleep(Duration::ZERO).await;

let initial_length = history_length();

sleep(Duration::ZERO).await;

click("button"); // replacing the current route

sleep(Duration::ZERO).await;
assert_eq!("2", obtain_result_by_id("result-params"));
assert_eq!("bar", obtain_result_by_id("result-query"));
assert_eq!(initial_length, history_length());

click("button"); // pushing a new route

sleep(Duration::ZERO).await;
assert_eq!("3", obtain_result_by_id("result-params"));
assert_eq!("baz", obtain_result_by_id("result-query"));
assert_eq!(initial_length + 1, history_length());
Expand Down
14 changes: 13 additions & 1 deletion packages/yew-router/tests/browser_router.rs
@@ -1,4 +1,6 @@
use gloo::timers::future::sleep;
use serde::{Deserialize, Serialize};
use std::time::Duration;
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};
use yew::functional::function_component;
use yew::prelude::*;
Expand Down Expand Up @@ -112,19 +114,29 @@ fn root() -> Html {
// - query parameters
// - 404 redirects
#[test]
fn router_works() {
async fn router_works() {
yew::start_app_in_element::<Root>(gloo::utils::document().get_element_by_id("output").unwrap());

sleep(Duration::ZERO).await;
futursolo marked this conversation as resolved.
Show resolved Hide resolved

assert_eq!("Home", obtain_result_by_id("result"));

sleep(Duration::ZERO).await;

let initial_length = history_length();

sleep(Duration::ZERO).await;

click("button"); // replacing the current route

sleep(Duration::ZERO).await;
assert_eq!("2", obtain_result_by_id("result-params"));
assert_eq!("bar", obtain_result_by_id("result-query"));
assert_eq!(initial_length, history_length());

click("button"); // pushing a new route

sleep(Duration::ZERO).await;
assert_eq!("3", obtain_result_by_id("result-params"));
assert_eq!("baz", obtain_result_by_id("result-query"));
assert_eq!(initial_length + 1, history_length());
Expand Down
14 changes: 13 additions & 1 deletion packages/yew-router/tests/hash_router.rs
@@ -1,4 +1,6 @@
use gloo::timers::future::sleep;
use serde::{Deserialize, Serialize};
use std::time::Duration;
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};
use yew::functional::function_component;
use yew::prelude::*;
Expand Down Expand Up @@ -112,19 +114,29 @@ fn root() -> Html {
// - query parameters
// - 404 redirects
#[test]
fn router_works() {
async fn router_works() {
yew::start_app_in_element::<Root>(gloo::utils::document().get_element_by_id("output").unwrap());

sleep(Duration::ZERO).await;

assert_eq!("Home", obtain_result_by_id("result"));

sleep(Duration::ZERO).await;

let initial_length = history_length();

sleep(Duration::ZERO).await;

click("button"); // replacing the current route

sleep(Duration::ZERO).await;
assert_eq!("2", obtain_result_by_id("result-params"));
assert_eq!("bar", obtain_result_by_id("result-query"));
assert_eq!(initial_length, history_length());

click("button"); // pushing a new route

sleep(Duration::ZERO).await;
assert_eq!("3", obtain_result_by_id("result-params"));
assert_eq!("baz", obtain_result_by_id("result-query"));
assert_eq!(initial_length + 1, history_length());
Expand Down