veilid/veilid-core/tests/web.rs

105 lines
2.4 KiB
Rust
Raw Normal View History

2021-11-22 11:28:30 -05:00
//! Test suite for the Web and headless browsers.
#![cfg(target_arch = "wasm32")]
2022-11-29 22:51:51 -05:00
#![recursion_limit = "256"]
2021-11-22 11:28:30 -05:00
2023-07-02 17:23:04 -04:00
use cfg_if::*;
use parking_lot::Once;
2022-11-29 22:51:51 -05:00
use veilid_core::tests::*;
2021-11-22 11:28:30 -05:00
use wasm_bindgen_test::*;
wasm_bindgen_test_configure!(run_in_browser);
2022-03-15 09:33:34 -04:00
extern crate wee_alloc;
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
2021-11-22 11:28:30 -05:00
static SETUP_ONCE: Once = Once::new();
pub fn setup() -> () {
SETUP_ONCE.call_once(|| {
console_error_panic_hook::set_once();
2022-11-29 22:51:51 -05:00
cfg_if! {
if #[cfg(feature = "tracing")] {
let mut builder = tracing_wasm::WASMLayerConfigBuilder::new();
builder.set_report_logs_in_timings(false);
builder.set_max_level(Level::TRACE);
builder.set_console_config(tracing_wasm::ConsoleConfig::ReportWithConsoleColor);
tracing_wasm::set_as_global_default_with_config(builder.build());
} else {
wasm_logger::init(wasm_logger::Config::default());
}
}
2021-11-22 11:28:30 -05:00
});
}
#[wasm_bindgen_test]
2023-05-29 15:24:57 -04:00
async fn wasm_test_host_interface() {
2021-11-22 11:28:30 -05:00
setup();
test_host_interface::test_all().await;
}
2022-10-02 18:47:36 -04:00
#[wasm_bindgen_test]
2023-05-29 15:24:57 -04:00
async fn wasm_test_types() {
2022-11-29 22:51:51 -05:00
setup();
2023-05-29 15:24:57 -04:00
test_types::test_all().await;
2022-11-29 22:51:51 -05:00
}
#[wasm_bindgen_test]
2023-05-29 15:24:57 -04:00
async fn wasm_test_veilid_core() {
2022-11-29 22:51:51 -05:00
setup();
test_veilid_core::test_all().await;
}
#[wasm_bindgen_test]
2023-05-29 15:24:57 -04:00
async fn wasm_test_veilid_config() {
2022-11-29 22:51:51 -05:00
setup();
test_veilid_config::test_all().await;
}
#[wasm_bindgen_test]
2023-05-29 15:24:57 -04:00
async fn wasm_test_connection_table() {
2022-11-29 22:51:51 -05:00
setup();
test_connection_table::test_all().await;
}
#[wasm_bindgen_test]
2023-05-29 15:24:57 -04:00
async fn wasm_test_signed_node_info() {
setup();
test_signed_node_info::test_all().await;
}
#[wasm_bindgen_test]
async fn wasm_test_table_store() {
2022-11-29 22:51:51 -05:00
setup();
test_table_store::test_all().await;
}
#[wasm_bindgen_test]
2023-05-29 15:24:57 -04:00
async fn wasm_test_protected_store() {
2022-10-02 18:47:36 -04:00
setup();
2022-11-29 22:51:51 -05:00
test_protected_store::test_all().await;
}
2022-10-02 18:47:36 -04:00
2022-11-29 22:51:51 -05:00
#[wasm_bindgen_test]
2023-05-29 15:24:57 -04:00
async fn wasm_test_crypto() {
2022-11-29 22:51:51 -05:00
setup();
test_crypto::test_all().await;
}
#[wasm_bindgen_test]
2023-05-29 15:24:57 -04:00
async fn wasm_test_envelope_receipt() {
2022-11-29 22:51:51 -05:00
setup();
test_envelope_receipt::test_all().await;
2022-10-02 18:47:36 -04:00
}
2023-05-29 15:24:57 -04:00
2023-05-25 18:22:01 -04:00
#[wasm_bindgen_test]
async fn wasm_test_serialize_json() {
setup();
test_serialize_json::test_all().await;
}
2023-05-29 15:24:57 -04:00
#[wasm_bindgen_test]
2023-05-30 13:23:48 -04:00
async fn wasm_test_serialize_routing_table() {
2023-05-29 15:24:57 -04:00
setup();
2023-05-30 13:23:48 -04:00
test_serialize_routing_table::test_all().await;
2023-05-29 15:24:57 -04:00
}