summaryrefslogtreecommitdiff
path: root/cli/tests/unit/fetch_test.ts
diff options
context:
space:
mode:
authorMarcos Casagrande <marcoscvp90@gmail.com>2020-06-01 14:32:08 +0200
committerGitHub <noreply@github.com>2020-06-01 14:32:08 +0200
commit1d3dce9a68c981aded31b4eb12f8a2ec4beecfab (patch)
treeea21bc746bab92715d5d9621edd272167f61451a /cli/tests/unit/fetch_test.ts
parentedeeedf40161dcc4932a33139a7fffa1a73cc142 (diff)
fix(cli/js/web): formData parser for binary files (#6015)
Diffstat (limited to 'cli/tests/unit/fetch_test.ts')
-rw-r--r--cli/tests/unit/fetch_test.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts
index c1dde92a9..57414d652 100644
--- a/cli/tests/unit/fetch_test.ts
+++ b/cli/tests/unit/fetch_test.ts
@@ -217,6 +217,25 @@ unitTest(
);
unitTest(
+ { perms: { net: true } },
+ async function fetchInitFormDataBinaryFileBody(): Promise<void> {
+ // Some random bytes
+ // prettier-ignore
+ const binaryFile = new Uint8Array([108,2,0,0,145,22,162,61,157,227,166,77,138,75,180,56,119,188,177,183]);
+ const response = await fetch("http://localhost:4545/echo_multipart_file", {
+ method: "POST",
+ body: binaryFile,
+ });
+ const resultForm = await response.formData();
+ const resultFile = resultForm.get("file") as File;
+
+ assertEquals(resultFile.type, "application/octet-stream");
+ assertEquals(resultFile.name, "file.bin");
+ assertEquals(new Uint8Array(await resultFile.arrayBuffer()), binaryFile);
+ }
+);
+
+unitTest(
{
perms: { net: true },
},