Files
test-repo/tests/fetch/response.js
T
Christopher Chedeau cf45afba61 Add testing
- This brings in the flow test suite that contains a ton of JavaScript parsing edge cases
- This creates snapshot tests using the pretty printer for all of them
- If uncomment `RUN_AST_TESTS` line in `tests/run_specs.js`, it checks ast(pretty_print(x)) == ast(x). Right now, "178 failed, 197 passed, 375 of 377 total". So half of the tests are not passing, most of them are crashes and many of the rest are subtle issues.
2016-12-23 19:51:53 +00:00

47 lines
1.2 KiB
JavaScript

/* @flow */
const a: Response = new Response(); // correct
const b: Response = new Response(new Blob()); // correct
const c: Response = new Response(new FormData()); // correct
const d: Response = new Response(new FormData(), {
status: 404
}); // correct
const e: Response = new Response("responsebody", {
status: "404"
}); // incorrect
const f: Response = new Response("responsebody", {
status: 404,
headers: "'Content-Type': 'image/jpeg'"
}); // incorrect
const g: Response = new Response("responsebody", {
status: 404,
headers: {
'Content-Type': 'image/jpeg'
}
}); // correct
const h: Response = new Response("responsebody", {
status: 404,
headers: new Headers({
'Content-Type': 'image/jpeg'
})
}); // correct, if verbose
const i: Response = new Response({
status: 404,
headers: new Headers({
'Content-Type': 'image/jpeg'
})
}); // incorrect
const ok: boolean = h.ok;
const status: number = h.status;
h.text().then((t: string) => t); // correct
h.text().then((t: Buffer) => t); // incorrect
h.arrayBuffer().then((ab: ArrayBuffer) => ab); // correct
h.arrayBuffer().then((ab: Buffer) => ab); // incorrect