-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break out tokio test, use required flavor=multi_thread.
- Loading branch information
1 parent
6fb3a33
commit 0694577
Showing
4 changed files
with
42 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use alcro::{Content, UIBuilder}; | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
async fn test_bind_tokio() { | ||
let ui = UIBuilder::new() | ||
.content(Content::Html( | ||
r#" | ||
<script> | ||
async function foo(x) { | ||
const result = await bar(x + 'b'); | ||
return result + 'd'; | ||
} | ||
</script> | ||
"#, | ||
)) | ||
.custom_args(&["--headless"]) | ||
.run() | ||
.expect("Unable to launch"); | ||
|
||
ui.bind_tokio("bar", move |args| async move { | ||
tokio::task::yield_now().await; | ||
Ok(format!("{}c", args[0].as_str().expect("arg to be str")).into()) | ||
}) | ||
.unwrap(); | ||
|
||
assert_eq!(ui.eval("foo('a')").unwrap(), "abcd"); | ||
} |