mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
19 lines
622 B
TypeScript
19 lines
622 B
TypeScript
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||
|
|
||
|
import { assertEquals } from "../assert/assert_equals.ts";
|
||
|
import { toArrayBuffer } from "./to_array_buffer.ts";
|
||
|
|
||
|
Deno.test("[streams] toArrayBuffer", async () => {
|
||
|
const stream = new ReadableStream<Uint8Array>({
|
||
|
start(controller) {
|
||
|
controller.enqueue(Uint8Array.of(1, 2, 3, 4, 5));
|
||
|
controller.enqueue(Uint8Array.of(6, 7));
|
||
|
controller.enqueue(Uint8Array.of(8, 9));
|
||
|
controller.close();
|
||
|
},
|
||
|
});
|
||
|
|
||
|
const buf = await toArrayBuffer(stream);
|
||
|
assertEquals(buf, Uint8Array.of(1, 2, 3, 4, 5, 6, 7, 8, 9).buffer);
|
||
|
});
|