Skip to content
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

test(clie/web/fetch): Re-enable tests #5904

Merged
merged 1 commit into from
May 27, 2020
Merged
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
16 changes: 6 additions & 10 deletions cli/tests/unit/fetch_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,20 @@ unitTest({ perms: { net: true } }, async function fetchBodyUsed(): Promise<
assertEquals(response.bodyUsed, true);
});

// TODO(ry) response.body shouldn't be iterable. Instead we should use
// response.body.getReader().
/*
unitTest({ perms: { net: true } }, async function fetchAsyncIterator(): Promise<
Copy link
Contributor Author

Choose a reason for hiding this comment

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

void
> {
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
const headers = response.headers;

assert(response.body !== null);
let total = 0;
for await (const chunk of response.body) {
total += chunk.length;
}

assertEquals(total, Number(headers.get("Content-Length")));
const _json = await response.json();
});
*/

unitTest({ perms: { net: true } }, async function fetchBodyReader(): Promise<
void
Expand Down Expand Up @@ -198,11 +195,10 @@ unitTest(
assert(formData.has("field_1"));
assertEquals(formData.get("field_1")!.toString(), "value_1 \r\n");
assert(formData.has("field_2"));
/* TODO(ry) Re-enable this test once we bring back the global File type.
const file = formData.get("field_2") as File;
assertEquals(file.name, "file.js");
*/
// Currently we cannot read from file...
const file = formData.get("field_2") as File;
assertEquals(file.name, "file.js");

assertEquals(await file.text(), `console.log("Hi")`);
}
);

Expand Down