mirror of
https://github.com/denoland/std.git
synced 2024-11-22 04:59:05 +00:00
24 lines
706 B
TypeScript
24 lines
706 B
TypeScript
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
|
|
import { assert } from "../assert/assert.ts";
|
|
import { assertEquals } from "../assert/assert_equals.ts";
|
|
import { toBlob } from "./to_blob.ts";
|
|
|
|
Deno.test("[streams] toBlob", 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 blob = await toBlob(stream);
|
|
assert(blob instanceof Blob);
|
|
assertEquals(
|
|
await blob.arrayBuffer(),
|
|
Uint8Array.of(1, 2, 3, 4, 5, 6, 7, 8, 9).buffer,
|
|
);
|
|
});
|