deno.land / std@0.166.0 / testing / _format_test.ts

_format_test.ts
نووسراو ببینە
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.import { green, red, stripColor } from "../fmt/colors.ts";import { assertEquals, assertThrows } from "./asserts.ts";import { format } from "./_format.ts";
Deno.test("assert diff formatting (strings)", () => { assertThrows( () => { assertEquals([..."abcd"].join("\n"), [..."abxde"].join("\n")); }, Error, ` a\\n b\\n${green("+ x")}\\n${green("+ d")}\\n${green("+ e")}${red("- c")}\\n${red("- d")}`, );});
// Check that the diff formatter overrides some default behaviours of// `Deno.inspect()` which are problematic for diffing.Deno.test("assert diff formatting", () => { // Wraps objects into multiple lines even when they are small. Prints trailing // commas. assertEquals( stripColor(format({ a: 1, b: 2 })), `{ a: 1, b: 2,}`, );
// Wraps Object with getters assertEquals( format(Object.defineProperty({}, "a", { enumerable: true, get() { return 1; }, })), `{ a: 1,}`, );
// Same for nested small objects. assertEquals( stripColor(format([{ x: { a: 1, b: 2 }, y: ["a", "b"] }])), `[ { x: { a: 1, b: 2, }, y: [ "a", "b", ], },]`, );
// Grouping is disabled. assertEquals( stripColor(format(["i", "i", "i", "i", "i", "i", "i"])), `[ "i", "i", "i", "i", "i", "i", "i",]`, );});
std
Deno standard library
GitHub Repositorydenoland/deno_std
GitHub Stars
2458

Version Info

Tagged at
2 months ago