Add Response interface part of fetch API

This commit is contained in:
Michael Hoffmann 2018-07-10 23:49:14 +02:00
parent 42938792c7
commit 717e260a99
3 changed files with 38 additions and 0 deletions

View File

@ -2,3 +2,4 @@ extern crate wasm_bindgen_test_project_builder as project_builder;
use project_builder::project;
mod event;
mod response;

View 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();
}