Skip to content

Add Response interface part of fetch API #452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/web-sys/tests/all/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ extern crate wasm_bindgen_test_project_builder as project_builder;
use project_builder::project;

mod event;
mod response;
37 changes: 37 additions & 0 deletions crates/web-sys/tests/all/response.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use super::project;

#[test]
fn response() {
project()
.add_local_dependency("web-sys", env!("CARGO_MANIFEST_DIR"))
.headless(true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are going to end up repeating these three lines in every single test in this crate -- would you be interested in writing a follow up PR that defines a helper function to preconfigure these bits in crates/web-sys/tests/all/main.rs ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly! :)

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