fmt: wasm body (#1359)
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
use super::multipart::Form;
|
use super::multipart::Form;
|
||||||
/// dox
|
/// dox
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use js_sys::{Uint8Array};
|
use js_sys::Uint8Array;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use wasm_bindgen::JsValue;
|
use wasm_bindgen::JsValue;
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ impl fmt::Debug for Body {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
// use js_sys::{Array, Uint8Array};
|
// use js_sys::{Array, Uint8Array};
|
||||||
use wasm_bindgen::{prelude::*};
|
use wasm_bindgen::prelude::*;
|
||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
|
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
|
||||||
@@ -161,11 +161,18 @@ mod tests {
|
|||||||
|
|
||||||
let mut init = web_sys::RequestInit::new();
|
let mut init = web_sys::RequestInit::new();
|
||||||
init.method("POST");
|
init.method("POST");
|
||||||
init.body(Some(body.to_js_value().expect("could not convert body to JsValue").as_ref()));
|
init.body(Some(
|
||||||
|
body.to_js_value()
|
||||||
|
.expect("could not convert body to JsValue")
|
||||||
|
.as_ref(),
|
||||||
|
));
|
||||||
|
|
||||||
let js_req = web_sys::Request::new_with_str_and_init("", &init).expect("could not create JS request");
|
let js_req = web_sys::Request::new_with_str_and_init("", &init)
|
||||||
|
.expect("could not create JS request");
|
||||||
let text_promise = js_req.text().expect("could not get text promise");
|
let text_promise = js_req.text().expect("could not get text promise");
|
||||||
let text = crate::wasm::promise::<JsValue>(text_promise).await.expect("could not get request body as text");
|
let text = crate::wasm::promise::<JsValue>(text_promise)
|
||||||
|
.await
|
||||||
|
.expect("could not get request body as text");
|
||||||
|
|
||||||
assert_eq!(text.as_string().expect("text is not a string"), body_value);
|
assert_eq!(text.as_string().expect("text is not a string"), body_value);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user