summaryrefslogtreecommitdiff
path: root/packages/integrations/node/test/api-route.test.js
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2022-07-26 10:31:54 -0400
committerGravatar GitHub <noreply@github.com> 2022-07-26 10:31:54 -0400
commit8c3de73ebfae60aa0204ef748fd2c124ee64867a (patch)
tree9c62632c0ac72082c0ca85deea039159655edf75 /packages/integrations/node/test/api-route.test.js
parent80e2e59036b3e13b4ff3ce13e0c3f78b3d08effa (diff)
downloadastro-8c3de73ebfae60aa0204ef748fd2c124ee64867a.tar.gz
astro-8c3de73ebfae60aa0204ef748fd2c124ee64867a.tar.zst
astro-8c3de73ebfae60aa0204ef748fd2c124ee64867a.zip
Fixes binary data request bodies in the Node adapter (#4055)
* Fixes binary data request bodies in the Node adapter * Fix type
Diffstat (limited to 'packages/integrations/node/test/api-route.test.js')
-rw-r--r--packages/integrations/node/test/api-route.test.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/packages/integrations/node/test/api-route.test.js b/packages/integrations/node/test/api-route.test.js
index 034b53c07..cd074ef27 100644
--- a/packages/integrations/node/test/api-route.test.js
+++ b/packages/integrations/node/test/api-route.test.js
@@ -31,4 +31,20 @@ describe('API routes', () => {
expect(json.length).to.equal(1);
expect(json[0].name).to.equal('Broccoli Soup');
});
+
+ it('Can get binary data', async () => {
+ const { handler } = await import('./fixtures/api-route/dist/server/entry.mjs');
+
+ let { req, res, done } = createRequestAndResponse({
+ method: 'POST',
+ url: '/binary',
+ });
+
+ handler(req, res);
+ req.send(Buffer.from(new Uint8Array([1, 2, 3, 4, 5])));
+
+ let [out] = await done;
+ let arr = Array.from(new Uint8Array(out.buffer));
+ expect(arr).to.deep.equal([5, 4, 3, 2, 1]);
+ });
});