diff options
author | Marcos Casagrande <marcoscvp90@gmail.com> | 2020-06-01 14:32:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-01 14:32:08 +0200 |
commit | 1d3dce9a68c981aded31b4eb12f8a2ec4beecfab (patch) | |
tree | ea21bc746bab92715d5d9621edd272167f61451a /cli/tests | |
parent | edeeedf40161dcc4932a33139a7fffa1a73cc142 (diff) |
fix(cli/js/web): formData parser for binary files (#6015)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/fetch_test.ts | 19 |
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 }, }, |