mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-11-25 09:02:46 +03:00
Add Response interface part of fetch API
This commit is contained in:
parent
42938792c7
commit
717e260a99
@ -2,3 +2,4 @@ extern crate wasm_bindgen_test_project_builder as project_builder;
|
|||||||
use project_builder::project;
|
use project_builder::project;
|
||||||
|
|
||||||
mod event;
|
mod event;
|
||||||
|
mod response;
|
||||||
|
37
crates/web-sys/tests/all/response.rs
Normal file
37
crates/web-sys/tests/all/response.rs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
use super::project;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn response() {
|
||||||
|
project()
|
||||||
|
.add_local_dependency("web-sys", env!("CARGO_MANIFEST_DIR"))
|
||||||
|
.headless(true)
|
||||||
|
.file(
|
||||||
|
"src/lib.rs",
|
||||||
|
r#"
|
||||||
|
#![feature(proc_macro, wasm_custom_section)]
|
||||||
|
extern crate wasm_bindgen;
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
extern crate web_sys;
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub fn test_response(response: &web_sys::Response) {
|
||||||
|
assert!(!response.ok());
|
||||||
|
assert!(!response.redirected());
|
||||||
|
assert_eq!(response.status(), 501);
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file(
|
||||||
|
"test.js",
|
||||||
|
r#"
|
||||||
|
import * as assert from "assert";
|
||||||
|
import * as wasm from "./out";
|
||||||
|
|
||||||
|
export function test() {
|
||||||
|
let response = new Response(null, {status: 501});
|
||||||
|
wasm.test_response(response);
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.test();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user