summaryrefslogtreecommitdiff
path: root/tests/unit/serve_test.ts
diff options
context:
space:
mode:
authorAsher Gomez <ashersaupingomez@gmail.com>2024-05-23 10:27:58 +1000
committerGitHub <noreply@github.com>2024-05-23 00:27:58 +0000
commit8a636d0600dc7000d1e12b2fc4f4f46ecd70164a (patch)
treea568fcac6b658e041f15da3b62953a5b812433f6 /tests/unit/serve_test.ts
parentf5d0c4b1ea39e34e2e068264f18021a4f7412479 (diff)
feat(ext/fetch): `Request.bytes()` and `Response.bytes()` (#23823)
Closes #23790
Diffstat (limited to 'tests/unit/serve_test.ts')
-rw-r--r--tests/unit/serve_test.ts17
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/unit/serve_test.ts b/tests/unit/serve_test.ts
index 74628ace1..f7f01076b 100644
--- a/tests/unit/serve_test.ts
+++ b/tests/unit/serve_test.ts
@@ -340,7 +340,7 @@ Deno.test(
});
const resp = await fetch(`http://localhost:${servePort}`);
- dataPromise = resp.arrayBuffer();
+ dataPromise = resp.bytes();
}
assertEquals((await dataPromise).byteLength, 1048576);
@@ -358,7 +358,7 @@ Deno.test(
const [_, data] = await Promise.all([
server.shutdown(),
- resp.arrayBuffer(),
+ resp.bytes(),
]);
assertEquals(data.byteLength, 1048576);
@@ -1861,13 +1861,12 @@ Deno.test(
signal: ac.signal,
});
const response = await fetch(`http://localhost:${servePort}/`);
- const body = await response.arrayBuffer();
+ const body = await response.bytes();
assertEquals(1024 * 1024, body.byteLength);
- const buffer = new Uint8Array(body);
for (let i = 0; i < 256; i++) {
assertEquals(
i,
- buffer[i * 4096],
+ body[i * 4096],
`sentinel mismatch at index ${i * 4096}`,
);
}
@@ -2078,8 +2077,8 @@ Deno.test(
await deferred.promise;
assertEquals(resp.status, 200);
- const body = await resp.arrayBuffer();
- assertEquals(new Uint8Array(body), new Uint8Array([128]));
+ const body = await resp.bytes();
+ assertEquals(body, new Uint8Array([128]));
ac.abort();
await server.finished;
@@ -2694,7 +2693,7 @@ for (const testCase of compressionTestCases) {
headers: testCase.in as HeadersInit,
});
await deferred.promise;
- const body = await resp.arrayBuffer();
+ const body = await resp.bytes();
if (testCase.expect == null) {
assertEquals(body.byteLength, testCase.length);
assertEquals(
@@ -2731,7 +2730,7 @@ Deno.test(
const server = Deno.serve({
handler: async (request) => {
assertEquals(
- new Uint8Array(await request.arrayBuffer()),
+ await request.bytes(),
makeTempData(70 * 1024),
);
deferred.resolve();