deno.land / std@0.224.0 / expect / _types.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// deno-lint-ignore-file no-explicit-any
export interface MatcherContext { value: unknown; isNot: boolean; equal: (a: unknown, b: unknown, options?: EqualOptions) => boolean; customTesters: Tester[]; customMessage: string | undefined;}
export type Matcher = ( context: MatcherContext, ...args: any[]) => MatchResult | ExtendMatchResult;
export type Matchers = { [key: string]: Matcher;};export type MatchResult = void | Promise<void> | boolean;export type ExtendMatchResult = { message: () => string; pass: boolean;};export type AnyConstructor = new (...args: any[]) => any;
export type Tester = ( a: any, b: any, customTesters: Tester[],) => void;
// a helper type to match any function. Used so that we only convert functions// to return a promise and not properties.type Fn = (...args: any[]) => unknown;
// converts all the methods in an interface to be async functionsexport type Async<T> = { [K in keyof T]: T[K] extends Fn ? (...args: Parameters<T[K]>) => Promise<ReturnType<T[K]>> : T[K];};
export interface Expected { lastCalledWith(...expected: unknown[]): void; lastReturnedWith(expected: unknown): void; nthCalledWith(nth: number, ...expected: unknown[]): void; nthReturnedWith(nth: number, expected: unknown): void; toBeCalled(): void; toBeCalledTimes(expected: number): void; toBeCalledWith(...expected: unknown[]): void; toBeCloseTo(candidate: number, tolerance?: number): void; toBeDefined(): void; toBeFalsy(): void; toBeGreaterThan(expected: number): void; toBeGreaterThanOrEqual(expected: number): void; toBeInstanceOf<T extends AnyConstructor>(expected: T): void; toBeLessThan(expected: number): void; toBeLessThanOrEqual(expected: number): void; toBeNaN(): void; toBeNull(): void; toBeTruthy(): void; toBeUndefined(): void; toBe(expected: unknown): void; toContainEqual(expected: unknown): void; toContain(expected: unknown): void; toEqual(expected: unknown): void; toHaveBeenCalledTimes(expected: number): void; toHaveBeenCalledWith(...expected: unknown[]): void; toHaveBeenCalled(): void; toHaveBeenLastCalledWith(...expected: unknown[]): void; toHaveBeenNthCalledWith(nth: number, ...expected: unknown[]): void; toHaveLength(expected: number): void; toHaveLastReturnedWith(expected: unknown): void; toHaveNthReturnedWith(nth: number, expected: unknown): void; toHaveProperty(propName: string | string[], value?: unknown): void; toHaveReturnedTimes(expected: number): void; toHaveReturnedWith(expected: unknown): void; toHaveReturned(): void; toMatch(expected: RegExp): void; toMatchObject( expected: | Record<PropertyKey, unknown> | Record<PropertyKey, unknown>[], ): void; toReturn(): void; toReturnTimes(expected: number): void; toReturnWith(expected: unknown): void; toStrictEqual(candidate: unknown): void; toThrow<E extends Error = Error>( expected?: string | RegExp | E | (new (...args: any[]) => E), ): void; not: Expected; resolves: Async<Expected>; rejects: Async<Expected>; // This declaration prepares for the `expect.extend` and just only let // compiler pass, the more concrete type definition is defined by user [name: string]: unknown;}
export type MatcherKey = keyof Omit<Expected, "not" | "resolves" | "rejects">;
export type EqualOptions = { customTesters?: Tester[]; msg?: string; formatter?: (value: unknown) => string; strictCheck?: boolean;};
export interface EqualOptionUtil extends MatcherContext { strictCheck?: boolean;}
export interface Colors { comment: { close: string; open: string }; content: { close: string; open: string }; prop: { close: string; open: string }; tag: { close: string; open: string }; value: { close: string; open: string };}type Indent = (arg0: string) => string;type Print = (arg0: unknown) => string;
export type Refs = Array<unknown>;
export type CompareKeys = ((a: string, b: string) => number) | null | undefined;
export interface Config { callToJSON: boolean; compareKeys: CompareKeys; colors: Colors; escapeRegex: boolean; escapeString: boolean; indent: string; maxDepth: number; maxWidth: number; min: boolean; plugins: SnapshotPlugin; printBasicPrototype: boolean; printFunctionName: boolean; spacingInner: string; spacingOuter: string;}
export type Printer = ( val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean,) => string;
interface PluginOptions { edgeSpacing: string; min: boolean; spacing: string;}
type Test = (arg0: any) => boolean;
export interface NewSnapshotPlugin { serialize: ( val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer, ) => string; test: Test;}
export interface OldSnapshotPlugin { print: ( val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors, ) => string; test: Test;}
export type SnapshotPlugin = NewSnapshotPlugin | OldSnapshotPlugin;
export type SnapshotPlugins = Array<SnapshotPlugin>;
std

Version Info

Tagged at
3 weeks ago