diff options
author | Marcos Casagrande <marcoscvp90@gmail.com> | 2020-05-27 22:37:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-27 16:37:19 -0400 |
commit | f8c6500eef59e046f4fd90d3c37a1e16606a0a78 (patch) | |
tree | cef5ad982756be9b8c6095d62088a67152d37591 | |
parent | db9c2c156a064469fc0ac6a1ad48ae4425926681 (diff) |
test(clie/web/fetch): Re-enable tests (#5904)
-rw-r--r-- | cli/tests/unit/fetch_test.ts | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts index 97b001b55..4a4212c0c 100644 --- a/cli/tests/unit/fetch_test.ts +++ b/cli/tests/unit/fetch_test.ts @@ -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< 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 @@ -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")`); } ); |