Files
test-repo/tests/flow/fetch/request.js
T
Simon Lydell dc93bdc983 Sync the Flow tests (#1163)
* Extract custom tests from tests/flow/

Approach:

1. Remove all .js files in tests/flow except .snap.js files.
2. Copy over all .js files from tests/ in the flow repo.
3. Go through the diff looking for deletions.
   - It was easy to see which deletions were due to changes in the tests
     due to updates in the flow repo.
   - For the rest of the deletions, I used `git blame` to verify that
     they had been added by us since the flow tests were copied over.

This makes tests/flow/ simply a copy of the tests from the flow repo,
making it easier to sync with the upstream flow tests in the future.

* Add a script for syncing the flow tests

* Sync the flow tests
2017-04-08 07:52:38 -07:00

68 lines
1.8 KiB
JavaScript

/* @flow */
const a: Request = new Request(); // incorrect
const b: Request = new Request('http://example.org'); // correct
const c: Request = new Request(b); // correct
const d: Request = new Request(c.clone()); // correct (doesn't make much sense though)
const e: Request = new Request(b, c); // incorrect
const f: Request = new Request({}) // incorrect
const g: Request = new Request('http://example.org', {}) // correct
const h: Request = new Request('http://example.org', {
method: 'GET',
headers: {
'Content-Type': 'image/jpeg'
},
mode: 'cors',
cache: 'default'
}) // correct
var bodyUsed: boolean = h.bodyUsed;
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
const i: Request = new Request('http://example.org', {
method: 'POST',
headers: {
'Content-Type': 'application/octet-stream'
},
body: new ArrayBuffer(10),
}); // correct
const j: Request = new Request('http://example.org', {
method: 'POST',
headers: {
'Content-Type': 'application/octet-stream'
},
body: new Uint8Array(10),
}); // correct
const k: Request = new Request('http://example.org', {
method: 'POST',
headers: {
'Content-Type': 'image/jpeg'
},
body: new URLSearchParams("key=value"),
mode: 'cors',
cache: 'default'
}) // correct
const l: Request = new Request('http://example.org', {
method: 'GET',
headers: 'Content-Type: image/jpeg',
mode: 'cors',
cache: 'default'
}) // incorrect - headers is string
const m: Request = new Request('http://example.org', {
method: 'CONNECT',
headers: {
'Content-Type': 'image/jpeg'
},
mode: 'cors',
cache: 'default'
}) // incorrect - CONNECT is forbidden