mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-11-25 09:02:46 +03:00
Merge pull request #452 from brisad/add-fetch-api-response
Add Response interface part of fetch API
This commit is contained in:
commit
eabbe0e56e
@ -2,3 +2,4 @@ extern crate wasm_bindgen_test_project_builder as project_builder;
|
||||
use project_builder::project;
|
||||
|
||||
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