mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
d102a10235
* refactor: import from `@std/assert` * update
24 lines
551 B
TypeScript
24 lines
551 B
TypeScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
import { assertEquals } from "@std/assert";
|
|
import { toJson } from "./to_json.ts";
|
|
|
|
Deno.test("toJson()", async () => {
|
|
const byteStream = ReadableStream.from(["[", "1, 2, 3, 4", "]"])
|
|
.pipeThrough(new TextEncoderStream());
|
|
|
|
assertEquals(await toJson(byteStream), [1, 2, 3, 4]);
|
|
|
|
const stringStream = ReadableStream.from([
|
|
'{ "a": 2,',
|
|
' "b": 3,',
|
|
' "c": 4 }',
|
|
]);
|
|
|
|
assertEquals(await toJson(stringStream), {
|
|
a: 2,
|
|
b: 3,
|
|
c: 4,
|
|
});
|
|
});
|