summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaeyeon Jeong <daeyeon.dev@gmail.com>2023-04-24 14:01:43 +0900
committerJames M Snell <jasnell@gmail.com>2023-05-04 17:02:23 -0700
commitaf9b48a2f17b11b66a8b81beeaba3c408b863795 (patch)
tree09e3d9631550a36ebc04470172613ab62739cc57 /test
parentd2d5789daaf4da49e89cf371ec0ca5094db3d945 (diff)
downloadnode-new-af9b48a2f17b11b66a8b81beeaba3c408b863795.tar.gz
src: fix creating an ArrayBuffer from a Blob created with `openAsBlob`
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com> PR-URL: https://github.com/nodejs/node/pull/47691 Fixes: https://github.com/nodejs/node/issues/47683 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-blob-file-backed.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/parallel/test-blob-file-backed.js b/test/parallel/test-blob-file-backed.js
index b25137a34c..acf04a4438 100644
--- a/test/parallel/test-blob-file-backed.js
+++ b/test/parallel/test-blob-file-backed.js
@@ -69,6 +69,23 @@ writeFileSync(testfile3, '');
})().then(common.mustCall());
(async () => {
+ // Refs: https://github.com/nodejs/node/issues/47683
+ const blob = await openAsBlob(testfile);
+ const res = blob.slice(10, 20);
+ const ab = await res.arrayBuffer();
+ strictEqual(res.size, ab.byteLength);
+
+ let length = 0;
+ const stream = await res.stream();
+ for await (const chunk of stream)
+ length += chunk.length;
+ strictEqual(res.size, length);
+
+ const res1 = blob.slice(995, 1005);
+ strictEqual(await res1.text(), data.slice(995, 1005));
+})().then(common.mustCall());
+
+(async () => {
const blob = await openAsBlob(testfile2);
const stream = blob.stream();
const read = async () => {