mirror of
https://codeberg.org/demostf/tf-demos-viewer.git
synced 2026-06-03 18:14:11 +02:00
init repo
This commit is contained in:
commit
4882477d73
10 changed files with 5912 additions and 0 deletions
35
tests/app.rs
Normal file
35
tests/app.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
use wasm_bindgen_test::{wasm_bindgen_test_configure, wasm_bindgen_test};
|
||||
use futures::prelude::*;
|
||||
use wasm_bindgen::JsValue;
|
||||
use wasm_bindgen_futures::JsFuture;
|
||||
|
||||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
|
||||
// This runs a unit test in native Rust, so it can only use Rust APIs.
|
||||
#[test]
|
||||
fn rust_test() {
|
||||
assert_eq!(1, 1);
|
||||
}
|
||||
|
||||
|
||||
// This runs a unit test in the browser, so it can use browser APIs.
|
||||
#[wasm_bindgen_test]
|
||||
fn web_test() {
|
||||
assert_eq!(1, 1);
|
||||
}
|
||||
|
||||
|
||||
// This runs a unit test in the browser, and in addition it supports asynchronous Future APIs.
|
||||
#[wasm_bindgen_test(async)]
|
||||
fn async_test() -> impl Future<Item = (), Error = JsValue> {
|
||||
// Creates a JavaScript Promise which will asynchronously resolve with the value 42.
|
||||
let promise = js_sys::Promise::resolve(&JsValue::from(42));
|
||||
|
||||
// Converts that Promise into a Future.
|
||||
// The unit test will wait for the Future to resolve.
|
||||
JsFuture::from(promise)
|
||||
.map(|x| {
|
||||
assert_eq!(x, 42);
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue