@@ -16,7 +16,7 @@ use yew::platform::time::sleep;
1616use yew:: prelude:: * ;
1717use yew:: suspense:: { use_future, Suspension , SuspensionResult } ;
1818use yew:: virtual_dom:: VNode ;
19- use yew:: { component, Renderer , ServerRenderer } ;
19+ use yew:: { component, scheduler , Renderer , ServerRenderer } ;
2020
2121wasm_bindgen_test:: wasm_bindgen_test_configure!( run_in_browser) ;
2222
@@ -62,12 +62,12 @@ async fn hydration_works() {
6262 . unwrap ( )
6363 . set_inner_html ( & s) ;
6464
65- sleep ( Duration :: ZERO ) . await ;
65+ scheduler :: flush ( ) . await ;
6666
6767 Renderer :: < App > :: with_root ( gloo:: utils:: document ( ) . get_element_by_id ( "output" ) . unwrap ( ) )
6868 . hydrate ( ) ;
6969
70- sleep ( Duration :: ZERO ) . await ;
70+ scheduler :: flush ( ) . await ;
7171
7272 let result = obtain_result_by_id ( "output" ) ;
7373
@@ -85,7 +85,7 @@ async fn hydration_works() {
8585 . unwrap ( )
8686 . click ( ) ;
8787
88- sleep ( Duration :: ZERO ) . await ;
88+ scheduler :: flush ( ) . await ;
8989
9090 let result = obtain_result_by_id ( "output" ) ;
9191
@@ -237,7 +237,7 @@ async fn hydration_with_suspense() {
237237 . unwrap ( )
238238 . set_inner_html ( & s) ;
239239
240- sleep ( Duration :: ZERO ) . await ;
240+ scheduler :: flush ( ) . await ;
241241
242242 Renderer :: < App > :: with_root ( gloo:: utils:: document ( ) . get_element_by_id ( "output" ) . unwrap ( ) )
243243 . hydrate ( ) ;
@@ -393,7 +393,7 @@ async fn hydration_with_suspense_not_suspended_at_start() {
393393 . unwrap ( )
394394 . set_inner_html ( & s) ;
395395
396- sleep ( Duration :: ZERO ) . await ;
396+ scheduler :: flush ( ) . await ;
397397
398398 Renderer :: < App > :: with_root ( gloo:: utils:: document ( ) . get_element_by_id ( "output" ) . unwrap ( ) )
399399 . hydrate ( ) ;
@@ -524,7 +524,7 @@ async fn hydration_nested_suspense_works() {
524524 . unwrap ( )
525525 . set_inner_html ( & s) ;
526526
527- sleep ( Duration :: ZERO ) . await ;
527+ scheduler :: flush ( ) . await ;
528528
529529 Renderer :: < App > :: with_root ( gloo:: utils:: document ( ) . get_element_by_id ( "output" ) . unwrap ( ) )
530530 . hydrate ( ) ;
@@ -661,12 +661,12 @@ async fn hydration_node_ref_works() {
661661 . unwrap ( )
662662 . set_inner_html ( & s) ;
663663
664- sleep ( Duration :: ZERO ) . await ;
664+ scheduler :: flush ( ) . await ;
665665
666666 Renderer :: < App > :: with_root ( gloo:: utils:: document ( ) . get_element_by_id ( "output" ) . unwrap ( ) )
667667 . hydrate ( ) ;
668668
669- sleep ( Duration :: ZERO ) . await ;
669+ scheduler :: flush ( ) . await ;
670670
671671 let result = obtain_result_by_id ( "output" ) ;
672672 assert_eq ! (
@@ -682,7 +682,7 @@ async fn hydration_node_ref_works() {
682682 . unwrap ( )
683683 . click ( ) ;
684684
685- sleep ( Duration :: ZERO ) . await ;
685+ scheduler :: flush ( ) . await ;
686686
687687 let result = obtain_result_by_id ( "output" ) ;
688688 assert_eq ! (
@@ -754,16 +754,13 @@ async fn hydration_list_order_works() {
754754 . unwrap ( )
755755 . set_inner_html ( & s) ;
756756
757- sleep ( Duration :: ZERO ) . await ;
757+ scheduler :: flush ( ) . await ;
758758
759759 Renderer :: < App > :: with_root ( gloo:: utils:: document ( ) . get_element_by_id ( "output" ) . unwrap ( ) )
760760 . hydrate ( ) ;
761761
762762 // Wait until all suspended components becomes revealed.
763- sleep ( Duration :: ZERO ) . await ;
764- sleep ( Duration :: ZERO ) . await ;
765- sleep ( Duration :: ZERO ) . await ;
766- sleep ( Duration :: ZERO ) . await ;
763+ scheduler:: flush ( ) . await ;
767764
768765 let result = obtain_result_by_id ( "output" ) ;
769766 assert_eq ! (
@@ -837,13 +834,13 @@ async fn hydration_suspense_no_flickering() {
837834 . unwrap ( )
838835 . set_inner_html ( & s) ;
839836
840- sleep ( Duration :: ZERO ) . await ;
837+ scheduler :: flush ( ) . await ;
841838
842839 Renderer :: < App > :: with_root ( gloo:: utils:: document ( ) . get_element_by_id ( "output" ) . unwrap ( ) )
843840 . hydrate ( ) ;
844841
845842 // Wait until all suspended components becomes revealed.
846- sleep ( Duration :: ZERO ) . await ;
843+ scheduler :: flush ( ) . await ;
847844
848845 let result = obtain_result_by_id ( "output" ) ;
849846 assert_eq ! (
@@ -950,16 +947,13 @@ async fn hydration_order_issue_nested_suspense() {
950947 . unwrap ( )
951948 . set_inner_html ( & s) ;
952949
953- sleep ( Duration :: ZERO ) . await ;
950+ scheduler :: flush ( ) . await ;
954951
955952 Renderer :: < App > :: with_root ( gloo:: utils:: document ( ) . get_element_by_id ( "output" ) . unwrap ( ) )
956953 . hydrate ( ) ;
957954
958955 // Wait until all suspended components becomes revealed.
959- sleep ( Duration :: ZERO ) . await ;
960- sleep ( Duration :: ZERO ) . await ;
961- sleep ( Duration :: ZERO ) . await ;
962- sleep ( Duration :: ZERO ) . await ;
956+ scheduler:: flush ( ) . await ;
963957
964958 let result = obtain_result_by_id ( "output" ) ;
965959 assert_eq ! (
@@ -1180,7 +1174,7 @@ async fn hydration_with_camelcase_svg_elements() {
11801174 . unwrap ( )
11811175 . set_inner_html ( & s) ;
11821176
1183- sleep ( Duration :: ZERO ) . await ;
1177+ scheduler :: flush ( ) . await ;
11841178
11851179 // Hydrate - this should not panic
11861180 Renderer :: < App > :: with_root ( gloo:: utils:: document ( ) . get_element_by_id ( "output" ) . unwrap ( ) )
@@ -1268,15 +1262,12 @@ async fn hydration_suspended_child_does_not_trap_sibling_slot() {
12681262 . unwrap ( )
12691263 . set_inner_html ( & s) ;
12701264
1271- sleep ( Duration :: ZERO ) . await ;
1265+ scheduler :: flush ( ) . await ;
12721266
12731267 Renderer :: < App > :: with_root ( gloo:: utils:: document ( ) . get_element_by_id ( "output" ) . unwrap ( ) )
12741268 . hydrate ( ) ;
12751269
1276- sleep ( Duration :: ZERO ) . await ;
1277- sleep ( Duration :: ZERO ) . await ;
1278- sleep ( Duration :: ZERO ) . await ;
1279- sleep ( Duration :: ZERO ) . await ;
1270+ scheduler:: flush ( ) . await ;
12801271
12811272 let result = obtain_result ( ) ;
12821273
0 commit comments