Merge pull request #452 from brisad/add-fetch-api-response

Add Response interface part of fetch API
This commit is contained in:
Nick Fitzgerald 2018-07-10 15:22:12 -07:00 committed by GitHub
commit eabbe0e56e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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();
}