From 40db35abe7080e5fc800cd06861802ca1a0fb6fe Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Fri, 23 Jun 2023 16:15:57 +0200 Subject: [PATCH] test(ui): Replace `sleep` by `yield_now`. Eh, removing `sleep` from the tests is always a pleasure right? --- crates/matrix-sdk-ui/tests/integration/room_list.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/matrix-sdk-ui/tests/integration/room_list.rs b/crates/matrix-sdk-ui/tests/integration/room_list.rs index 4df085837..4da17629a 100644 --- a/crates/matrix-sdk-ui/tests/integration/room_list.rs +++ b/crates/matrix-sdk-ui/tests/integration/room_list.rs @@ -1,4 +1,4 @@ -use std::{ops::Not, time::Duration}; +use std::ops::Not; use assert_matches::assert_matches; use eyeball_im::VectorDiff; @@ -21,7 +21,7 @@ use ruma::{ }; use serde_json::json; use stream_assert::{assert_next_matches, assert_pending}; -use tokio::time::sleep; +use tokio::task::yield_now; use wiremock::MockServer; use crate::{ @@ -1142,7 +1142,7 @@ async fn test_loading_states() -> Result<(), Error> { }; // Wait on Tokio to run all the tasks. It won't happen in the main app. - sleep(Duration::from_millis(50)).await; + yield_now().await; // There is a loading state update, it's loaded now! assert_next_matches!( @@ -1174,7 +1174,7 @@ async fn test_loading_states() -> Result<(), Error> { }; // Wait on Tokio to run all the tasks. It won't happen in the main app. - sleep(Duration::from_millis(50)).await; + yield_now().await; // There is a loading state update because the number of rooms has been updated. assert_next_matches!( @@ -1206,7 +1206,7 @@ async fn test_loading_states() -> Result<(), Error> { }; // Wait on Tokio to run all the tasks. It won't happen in the main app. - sleep(Duration::from_millis(50)).await; + yield_now().await; // No loading state update. assert_pending!(all_rooms_loading_state);