@kerebron/test-utils 0.4.28 → 0.4.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/_dnt.shims.js +1 -0
- package/esm/_dnt.shims.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/assert.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/assert.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/equal.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/equal.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/equals.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/equals.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/exists.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/exists.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/fail.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/fail.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/false.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/false.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/less.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/less.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/match.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/match.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/mod.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/mod.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/throws.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/throws.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.js.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.js +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.js +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff.js +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.js +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/format.js +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/format.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/styles.js +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/styles.js.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/types.js +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/types.js.map +1 -0
- package/esm/test-utils.js +1 -0
- package/esm/test-utils.js.map +1 -0
- package/package.json +5 -1
- package/src/_dnt.shims.ts +60 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/almost_equals.ts +55 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/array_includes.ts +57 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/assert.ts +23 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/assertion_error.ts +31 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/equal.ts +218 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/equals.ts +66 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/exists.ts +31 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/fail.ts +21 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/false.ts +26 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/greater.ts +30 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.ts +36 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/instance_of.ts +64 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/is_error.ts +65 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/less.ts +29 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/less_or_equal.ts +36 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/match.ts +30 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/mod.ts +47 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/not_equals.ts +37 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/not_instance_of.ts +33 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/not_match.ts +30 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.ts +42 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/object_match.ts +214 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/rejects.ts +123 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/strict_equals.ts +68 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/string_includes.ts +30 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/throws.ts +111 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/unimplemented.ts +21 -0
- package/src/deps/jsr.io/@std/assert/1.0.16/unreachable.ts +21 -0
- package/src/deps/jsr.io/@std/internal/1.0.12/build_message.ts +147 -0
- package/src/deps/jsr.io/@std/internal/1.0.12/diff.ts +317 -0
- package/src/deps/jsr.io/@std/internal/1.0.12/diff_str.ts +208 -0
- package/src/deps/jsr.io/@std/internal/1.0.12/format.ts +89 -0
- package/src/deps/jsr.io/@std/internal/1.0.12/styles.ts +233 -0
- package/src/deps/jsr.io/@std/internal/1.0.12/types.ts +30 -0
- package/src/test-utils.ts +12 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
// A module to print ANSI terminal colors. Inspired by chalk, kleur, and colors
|
|
4
|
+
// on npm.
|
|
5
|
+
|
|
6
|
+
// This code is vendored from `fmt/colors.ts`.
|
|
7
|
+
|
|
8
|
+
// deno-lint-ignore no-explicit-any
|
|
9
|
+
import * as dntShim from "../../../../../_dnt.shims.js";
|
|
10
|
+
|
|
11
|
+
const { Deno } = dntShim.dntGlobalThis as any;
|
|
12
|
+
const noColor = typeof Deno?.noColor === "boolean"
|
|
13
|
+
? Deno.noColor as boolean
|
|
14
|
+
: false;
|
|
15
|
+
|
|
16
|
+
interface Code {
|
|
17
|
+
open: string;
|
|
18
|
+
close: string;
|
|
19
|
+
regexp: RegExp;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const enabled = !noColor;
|
|
23
|
+
|
|
24
|
+
function code(open: number[], close: number): Code {
|
|
25
|
+
return {
|
|
26
|
+
open: `\x1b[${open.join(";")}m`,
|
|
27
|
+
close: `\x1b[${close}m`,
|
|
28
|
+
regexp: new RegExp(`\\x1b\\[${close}m`, "g"),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function run(str: string, code: Code): string {
|
|
33
|
+
return enabled
|
|
34
|
+
? `${code.open}${str.replace(code.regexp, code.open)}${code.close}`
|
|
35
|
+
: str;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Sets the style of text to be printed to bold.
|
|
40
|
+
*
|
|
41
|
+
* Disable by setting the `NO_COLOR` environmental variable.
|
|
42
|
+
*
|
|
43
|
+
* @param str Text to make bold
|
|
44
|
+
*
|
|
45
|
+
* @returns Bold text for printing
|
|
46
|
+
*
|
|
47
|
+
* @example Usage
|
|
48
|
+
* ```ts no-assert
|
|
49
|
+
* import { bold } from "@std/internal/styles";
|
|
50
|
+
*
|
|
51
|
+
* console.log(bold("Hello, world!")); // Prints "Hello, world!" in bold
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export function bold(str: string): string {
|
|
55
|
+
return run(str, code([1], 22));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Sets the color of text to be printed to red.
|
|
60
|
+
*
|
|
61
|
+
* Disable by setting the `NO_COLOR` environmental variable.
|
|
62
|
+
*
|
|
63
|
+
* @param str Text to make red
|
|
64
|
+
*
|
|
65
|
+
* @returns Red text for printing
|
|
66
|
+
*
|
|
67
|
+
* @example Usage
|
|
68
|
+
* ```ts no-assert
|
|
69
|
+
* import { red } from "@std/internal/styles";
|
|
70
|
+
*
|
|
71
|
+
* console.log(red("Hello, world!")); // Prints "Hello, world!" in red
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export function red(str: string): string {
|
|
75
|
+
return run(str, code([31], 39));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Sets the color of text to be printed to green.
|
|
80
|
+
*
|
|
81
|
+
* Disable by setting the `NO_COLOR` environmental variable.
|
|
82
|
+
*
|
|
83
|
+
* @param str Text to make green
|
|
84
|
+
*
|
|
85
|
+
* @returns Green text for print
|
|
86
|
+
*
|
|
87
|
+
* @example Usage
|
|
88
|
+
* ```ts no-assert
|
|
89
|
+
* import { green } from "@std/internal/styles";
|
|
90
|
+
*
|
|
91
|
+
* console.log(green("Hello, world!")); // Prints "Hello, world!" in green
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export function green(str: string): string {
|
|
95
|
+
return run(str, code([32], 39));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Sets the color of text to be printed to yellow.
|
|
100
|
+
*
|
|
101
|
+
* Disable by setting the `NO_COLOR` environmental variable.
|
|
102
|
+
*
|
|
103
|
+
* @param str Text to make yellow
|
|
104
|
+
*
|
|
105
|
+
* @returns Yellow text for print
|
|
106
|
+
*
|
|
107
|
+
* @example Usage
|
|
108
|
+
* ```ts no-assert
|
|
109
|
+
* import { yellow } from "@std/internal/styles";
|
|
110
|
+
*
|
|
111
|
+
* console.log(yellow("Hello, world!")); // Prints "Hello, world!" in yellow
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export function yellow(str: string): string {
|
|
115
|
+
return run(str, code([33], 39));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Sets the color of text to be printed to white.
|
|
120
|
+
*
|
|
121
|
+
* @param str Text to make white
|
|
122
|
+
*
|
|
123
|
+
* @returns White text for print
|
|
124
|
+
*
|
|
125
|
+
* @example Usage
|
|
126
|
+
* ```ts no-assert
|
|
127
|
+
* import { white } from "@std/internal/styles";
|
|
128
|
+
*
|
|
129
|
+
* console.log(white("Hello, world!")); // Prints "Hello, world!" in white
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export function white(str: string): string {
|
|
133
|
+
return run(str, code([37], 39));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Sets the color of text to be printed to gray.
|
|
138
|
+
*
|
|
139
|
+
* @param str Text to make gray
|
|
140
|
+
*
|
|
141
|
+
* @returns Gray text for print
|
|
142
|
+
*
|
|
143
|
+
* @example Usage
|
|
144
|
+
* ```ts no-assert
|
|
145
|
+
* import { gray } from "@std/internal/styles";
|
|
146
|
+
*
|
|
147
|
+
* console.log(gray("Hello, world!")); // Prints "Hello, world!" in gray
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export function gray(str: string): string {
|
|
151
|
+
return brightBlack(str);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Sets the color of text to be printed to bright-black.
|
|
156
|
+
*
|
|
157
|
+
* @param str Text to make bright-black
|
|
158
|
+
*
|
|
159
|
+
* @returns Bright-black text for print
|
|
160
|
+
*
|
|
161
|
+
* @example Usage
|
|
162
|
+
* ```ts no-assert
|
|
163
|
+
* import { brightBlack } from "@std/internal/styles";
|
|
164
|
+
*
|
|
165
|
+
* console.log(brightBlack("Hello, world!")); // Prints "Hello, world!" in bright-black
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
export function brightBlack(str: string): string {
|
|
169
|
+
return run(str, code([90], 39));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Sets the background color of text to be printed to red.
|
|
174
|
+
*
|
|
175
|
+
* @param str Text to make its background red
|
|
176
|
+
*
|
|
177
|
+
* @returns Red background text for print
|
|
178
|
+
*
|
|
179
|
+
* @example Usage
|
|
180
|
+
* ```ts no-assert
|
|
181
|
+
* import { bgRed } from "@std/internal/styles";
|
|
182
|
+
*
|
|
183
|
+
* console.log(bgRed("Hello, world!")); // Prints "Hello, world!" with red background
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export function bgRed(str: string): string {
|
|
187
|
+
return run(str, code([41], 49));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Sets the background color of text to be printed to green.
|
|
192
|
+
*
|
|
193
|
+
* @param str Text to make its background green
|
|
194
|
+
*
|
|
195
|
+
* @returns Green background text for print
|
|
196
|
+
*
|
|
197
|
+
* @example Usage
|
|
198
|
+
* ```ts no-assert
|
|
199
|
+
* import { bgGreen } from "@std/internal/styles";
|
|
200
|
+
*
|
|
201
|
+
* console.log(bgGreen("Hello, world!")); // Prints "Hello, world!" with green background
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
export function bgGreen(str: string): string {
|
|
205
|
+
return run(str, code([42], 49));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// https://github.com/chalk/ansi-regex/blob/02fa893d619d3da85411acc8fd4e2eea0e95a9d9/index.js
|
|
209
|
+
const ANSI_PATTERN = new RegExp(
|
|
210
|
+
[
|
|
211
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
212
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))",
|
|
213
|
+
].join("|"),
|
|
214
|
+
"g",
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Remove ANSI escape codes from the string.
|
|
219
|
+
*
|
|
220
|
+
* @param string Text to remove ANSI escape codes from
|
|
221
|
+
*
|
|
222
|
+
* @returns Text without ANSI escape codes
|
|
223
|
+
*
|
|
224
|
+
* @example Usage
|
|
225
|
+
* ```ts no-assert
|
|
226
|
+
* import { red, stripAnsiCode } from "@std/internal/styles";
|
|
227
|
+
*
|
|
228
|
+
* console.log(stripAnsiCode(red("Hello, world!"))); // Prints "Hello, world!"
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
export function stripAnsiCode(string: string): string {
|
|
232
|
+
return string.replace(ANSI_PATTERN, "");
|
|
233
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
|
|
4
|
+
/** Ways that lines in a diff can be different. */
|
|
5
|
+
export type DiffType = DiffResult<unknown>["type"];
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents the result of a diff operation.
|
|
9
|
+
* @typeParam T The type of the value in the diff result.
|
|
10
|
+
*/
|
|
11
|
+
export type DiffResult<T> = ChangedDiffResult<T> | CommonDiffResult<T>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the result of a common diff operation.
|
|
15
|
+
* @typeParam T The type of the value in the diff result.
|
|
16
|
+
*/
|
|
17
|
+
export type CommonDiffResult<T> = {
|
|
18
|
+
type: "common" | "truncation";
|
|
19
|
+
value: T;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Represents the result of a changed diff operation.
|
|
24
|
+
* @typeParam T The type of the value in the diff result.
|
|
25
|
+
*/
|
|
26
|
+
export type ChangedDiffResult<T> = {
|
|
27
|
+
type: "removed" | "added";
|
|
28
|
+
value: T;
|
|
29
|
+
details?: DiffResult<T>[];
|
|
30
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { assertEquals } from './deps/jsr.io/@std/assert/1.0.16/mod.js';
|
|
2
|
+
|
|
3
|
+
export function trimLines(args: TemplateStringsArray) {
|
|
4
|
+
const lines = args[0].split('\n');
|
|
5
|
+
if (!lines[0].trim()) {
|
|
6
|
+
lines.shift();
|
|
7
|
+
}
|
|
8
|
+
if (!lines[lines.length - 1].trim()) {
|
|
9
|
+
lines[lines.length - 1] = '';
|
|
10
|
+
}
|
|
11
|
+
return lines.join('\n');
|
|
12
|
+
}
|