deno.land / std@0.224.0 / ini / stringify_test.ts

stringify_test.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { stringify, type StringifyOptions } from "./mod.ts";import { assertEquals } from "../assert/mod.ts";
function assertValidStringify( obj: unknown, expected: unknown, options?: StringifyOptions,) { assertEquals(stringify(obj, options), expected);}
Deno.test({ name: "stringify()", fn() { assertValidStringify({ a: "b" }, `a=b`); assertValidStringify({ a: "b" }, `a = b`, { pretty: true }); assertValidStringify({ a: "b" }, `a : b`, { assignment: ":", pretty: true, }); assertValidStringify( { a: "b", section: { c: "d" }, e: "f" }, `a=b\ne=f\n[section]\nc=d`, ); assertValidStringify( { dates: { a: new Date("1977-05-25") } }, `[dates]\na=1977-05-25T00:00:00.000Z`, { replacer: (_, val) => val?.toJSON() }, ); },});
std

Version Info

Tagged at
6 months ago