diff options
Diffstat (limited to 'js/fetch_test.ts')
-rw-r--r-- | js/fetch_test.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/js/fetch_test.ts b/js/fetch_test.ts index cd3e6ebf0..c631f2517 100644 --- a/js/fetch_test.ts +++ b/js/fetch_test.ts @@ -58,6 +58,30 @@ testPerm({ net: true }, async function fetchEmptyInvalid() { assertEqual(err.name, "InvalidUri"); }); +testPerm({ net: true }, async function fetchMultipartFormDataSuccess() { + const response = await fetch( + "http://localhost:4545/tests/subdir/multipart_form_data.txt" + ); + const formData = await response.formData(); + assert(formData.has("field_1")); + assertEqual(formData.get("field_1").toString(), "value_1 \r\n"); + assert(formData.has("field_2")); + const file = formData.get("field_2") as File; + assertEqual(file.name, "file.js"); + // Currently we cannot read from file... +}); + +testPerm({ net: true }, async function fetchURLEncodedFormDataSuccess() { + const response = await fetch( + "http://localhost:4545/tests/subdir/form_urlencoded.txt" + ); + const formData = await response.formData(); + assert(formData.has("field_1")); + assertEqual(formData.get("field_1").toString(), "Hi"); + assert(formData.has("field_2")); + assertEqual(formData.get("field_2").toString(), "<Deno>"); +}); + // TODO(ry) The following tests work but are flaky. There's a race condition // somewhere. Here is what one of these flaky failures looks like: // |