forked from yewstack/yew
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod.rs
42 lines (34 loc) · 995 Bytes
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#![cfg(target_arch = "wasm32")]
mod common;
use std::time::Duration;
use common::obtain_result;
use wasm_bindgen_test::*;
use yew::platform::time::sleep;
use yew::prelude::*;
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_test]
async fn props_are_passed() {
#[derive(Properties, Clone, PartialEq)]
struct PropsPassedFunctionProps {
value: String,
}
#[function_component]
fn PropsComponent(props: &PropsPassedFunctionProps) -> Html {
assert_eq!(&props.value, "props");
html! {
<div id="result">
{"done"}
</div>
}
}
yew::Renderer::<PropsComponent>::with_root_and_props(
gloo_utils::document().get_element_by_id("output").unwrap(),
PropsPassedFunctionProps {
value: "props".to_string(),
},
)
.render();
sleep(Duration::ZERO).await;
let result = obtain_result();
assert_eq!(result.as_str(), "done");
}