formData: set default filename for Blob to <blob> (#5907)

This commit is contained in:
Marcos Casagrande 2020-05-28 15:02:00 +02:00 committed by GitHub
parent 3cbcdd4250
commit c9bbb200d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 3 deletions

View file

@ -359,6 +359,24 @@ unitTest(
}
);
unitTest(
{ perms: { net: true } },
async function fetchInitFormDataBlobFilenameBody(): Promise<void> {
const form = new FormData();
form.append("field", "value");
form.append("file", new Blob([new TextEncoder().encode("deno")]));
const response = await fetch("http://localhost:4545/echo_server", {
method: "POST",
body: form,
});
const resultForm = await response.formData();
assertEquals(form.get("field"), resultForm.get("field"));
const file = resultForm.get("file");
assert(file instanceof File);
assertEquals(file.name, "blob");
}
);
unitTest({ perms: { net: true } }, async function fetchUserAgent(): Promise<
void
> {