@plugjs/expect5 0.4.4 → 0.4.6
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/dist/cli.mjs +2 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/execution/executor.cjs.map +1 -1
- package/dist/execution/executor.d.ts +1 -1
- package/dist/execution/executor.mjs +1 -1
- package/dist/execution/executor.mjs.map +1 -1
- package/dist/execution/setup.cjs.map +1 -1
- package/dist/execution/setup.d.ts +1 -1
- package/dist/execution/setup.mjs +1 -1
- package/dist/execution/setup.mjs.map +1 -1
- package/dist/expectation/async.cjs +78 -45
- package/dist/expectation/async.cjs.map +1 -1
- package/dist/expectation/async.d.ts +66 -51
- package/dist/expectation/async.mjs +79 -42
- package/dist/expectation/async.mjs.map +1 -1
- package/dist/expectation/diff.cjs.map +1 -1
- package/dist/expectation/diff.mjs +6 -1
- package/dist/expectation/diff.mjs.map +1 -1
- package/dist/expectation/expect.cjs +11 -165
- package/dist/expectation/expect.cjs.map +2 -2
- package/dist/expectation/expect.d.ts +10 -112
- package/dist/expectation/expect.mjs +12 -207
- package/dist/expectation/expect.mjs.map +2 -2
- package/dist/expectation/expectations.cjs +549 -0
- package/dist/expectation/expectations.cjs.map +6 -0
- package/dist/expectation/expectations.d.ts +454 -0
- package/dist/expectation/expectations.mjs +530 -0
- package/dist/expectation/expectations.mjs.map +6 -0
- package/dist/expectation/include.cjs +43 -41
- package/dist/expectation/include.cjs.map +1 -1
- package/dist/expectation/include.d.ts +3 -19
- package/dist/expectation/include.mjs +43 -41
- package/dist/expectation/include.mjs.map +1 -1
- package/dist/expectation/matchers.cjs +350 -0
- package/dist/expectation/matchers.cjs.map +6 -0
- package/dist/expectation/matchers.d.ts +375 -0
- package/dist/expectation/matchers.mjs +328 -0
- package/dist/expectation/matchers.mjs.map +6 -0
- package/dist/expectation/print.cjs.map +1 -1
- package/dist/expectation/print.d.ts +2 -2
- package/dist/expectation/print.mjs.map +1 -1
- package/dist/expectation/types.cjs +17 -23
- package/dist/expectation/types.cjs.map +1 -1
- package/dist/expectation/types.d.ts +7 -51
- package/dist/expectation/types.mjs +17 -22
- package/dist/expectation/types.mjs.map +1 -1
- package/dist/globals.d.ts +2 -2
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.mjs +11 -12
- package/dist/index.mjs.map +1 -1
- package/dist/test.cjs +33 -5
- package/dist/test.cjs.map +1 -1
- package/dist/test.d.ts +2 -2
- package/dist/test.mjs +34 -6
- package/dist/test.mjs.map +1 -1
- package/package.json +2 -2
- package/src/cli.mts +1 -1
- package/src/execution/executor.ts +1 -3
- package/src/execution/setup.ts +1 -3
- package/src/expectation/async.ts +145 -145
- package/src/expectation/diff.ts +7 -3
- package/src/expectation/expect.ts +22 -362
- package/src/expectation/expectations.ts +971 -0
- package/src/expectation/include.ts +59 -75
- package/src/expectation/matchers.ts +698 -0
- package/src/expectation/print.ts +8 -4
- package/src/expectation/types.ts +22 -94
- package/src/globals.ts +2 -2
- package/src/index.ts +17 -10
- package/src/test.ts +33 -10
- package/dist/expectation/basic.cjs +0 -188
- package/dist/expectation/basic.cjs.map +0 -6
- package/dist/expectation/basic.d.ts +0 -90
- package/dist/expectation/basic.mjs +0 -156
- package/dist/expectation/basic.mjs.map +0 -6
- package/dist/expectation/throwing.cjs +0 -58
- package/dist/expectation/throwing.cjs.map +0 -6
- package/dist/expectation/throwing.d.ts +0 -36
- package/dist/expectation/throwing.mjs +0 -32
- package/dist/expectation/throwing.mjs.map +0 -6
- package/dist/expectation/trivial.cjs +0 -96
- package/dist/expectation/trivial.cjs.map +0 -6
- package/dist/expectation/trivial.d.ts +0 -13
- package/dist/expectation/trivial.mjs +0 -61
- package/dist/expectation/trivial.mjs.map +0 -6
- package/src/expectation/basic.ts +0 -413
- package/src/expectation/throwing.ts +0 -106
- package/src/expectation/trivial.ts +0 -107
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
import { type Diff } from './diff';
|
|
2
|
+
import { type Matchers } from './matchers';
|
|
3
|
+
import { type Constructor, type TypeMappings, type TypeName } from './types';
|
|
4
|
+
/** An assertion function, for sub-expectations and value introspection */
|
|
5
|
+
export type AssertionFunction<T = unknown> = (assert: Expectations<T>) => void | Expectations;
|
|
6
|
+
/** Return the type asserted by an {@link AssertionFunction} or `T` */
|
|
7
|
+
export type AssertedType<T, F extends AssertionFunction<any>, R = ReturnType<F>> = R extends Expectations<infer I> ? unknown extends I ? T : I : T;
|
|
8
|
+
export type InferMatchers<T> = T extends Matchers<infer V> ? V : T extends Record<any, any> ? {
|
|
9
|
+
[k in keyof T]: InferMatchers<T[k]>;
|
|
10
|
+
} : T;
|
|
11
|
+
/** Simple wrapper defining the _parent_ instance of an {@link Expectations}. */
|
|
12
|
+
type ExpectationsParent = {
|
|
13
|
+
/** Parent {@link Expectations} instance */
|
|
14
|
+
expectations: Expectations;
|
|
15
|
+
/** Property associating _this_ to the parent */
|
|
16
|
+
prop: string | number | symbol;
|
|
17
|
+
};
|
|
18
|
+
/** Main class containing all supported expectations */
|
|
19
|
+
export declare class Expectations<T = unknown> {
|
|
20
|
+
/** The value associated with this instance */
|
|
21
|
+
readonly value: T;
|
|
22
|
+
/** Optional additional _remarks_ to associate with errors */
|
|
23
|
+
readonly remarks: string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* An optional {@link ExpectationsParent} defining _this_ to be a
|
|
26
|
+
* child of another {@link Expectations} instance
|
|
27
|
+
*/
|
|
28
|
+
readonly parent?: ExpectationsParent | undefined;
|
|
29
|
+
/** The {@link NegativeExpectations} associated with _this_ */
|
|
30
|
+
readonly not: NegativeExpectations<T>;
|
|
31
|
+
/**
|
|
32
|
+
* Create an {@link Expectations} instance associated with the specified
|
|
33
|
+
* value and error remarks.
|
|
34
|
+
*
|
|
35
|
+
* Optionally a parent {@link Expectations} instance can be specified.
|
|
36
|
+
*/
|
|
37
|
+
constructor(
|
|
38
|
+
/** The value associated with this instance */
|
|
39
|
+
value: T,
|
|
40
|
+
/** Optional additional _remarks_ to associate with errors */
|
|
41
|
+
remarks: string | undefined, // required, but migth be undefined
|
|
42
|
+
/**
|
|
43
|
+
* An optional {@link ExpectationsParent} defining _this_ to be a
|
|
44
|
+
* child of another {@link Expectations} instance
|
|
45
|
+
*/
|
|
46
|
+
parent?: ExpectationsParent | undefined);
|
|
47
|
+
/** Throw an {@link ExpectationError} associated with _this_ */
|
|
48
|
+
protected _fail(details: string, diff?: Diff): never;
|
|
49
|
+
/**
|
|
50
|
+
* Expects the value to be of the specified _extended_ {@link TypeName type},
|
|
51
|
+
* and (if specified) further asserts it with an {@link AssertionFunction}.
|
|
52
|
+
*
|
|
53
|
+
* Negation: {@link NegativeExpectations.toBeA `not.toBeA(...)`}
|
|
54
|
+
*/
|
|
55
|
+
toBeA<Name extends TypeName, Mapped extends TypeMappings[Name], Assert extends AssertionFunction<Mapped>>(type: Name, assertion?: Assert): Expectations<AssertedType<Mapped, Assert>>;
|
|
56
|
+
/**
|
|
57
|
+
* Expects the value to be a `number` within a given +/- _delta_ range of the
|
|
58
|
+
* specified expected value.
|
|
59
|
+
*
|
|
60
|
+
* Negation: {@link NegativeExpectations.toBeCloseTo `not.toBeCloseTo(...)`}
|
|
61
|
+
*/
|
|
62
|
+
toBeCloseTo(value: number, delta: number): Expectations<number>;
|
|
63
|
+
/**
|
|
64
|
+
* Expects the value to be a `bigint` within a given +/- _delta_ range of the
|
|
65
|
+
* specified expected value.
|
|
66
|
+
*
|
|
67
|
+
* Negation: {@link NegativeExpectations.toBeCloseTo `not.toBeCloseTo(...)`}
|
|
68
|
+
*/
|
|
69
|
+
toBeCloseTo(value: bigint, delta: bigint): Expectations<bigint>;
|
|
70
|
+
/**
|
|
71
|
+
* Expects the value to be neither `null` nor `undefined`.
|
|
72
|
+
*
|
|
73
|
+
* Negation: {@link NegativeExpectations.toBeDefined `not.toBeDefined()`}
|
|
74
|
+
*/
|
|
75
|
+
toBeDefined(): Expectations<T>;
|
|
76
|
+
/**
|
|
77
|
+
* Expect the value to be an instance of {@link Error}.
|
|
78
|
+
*
|
|
79
|
+
* If specified, the {@link Error}'s own message will be further expected to
|
|
80
|
+
* either match the specified {@link RegExp}, or equal the specified `string`.
|
|
81
|
+
*/
|
|
82
|
+
toBeError(message?: string | RegExp): Expectations<Error>;
|
|
83
|
+
/**
|
|
84
|
+
* Expect the value to be an instance of {@link Error} and further asserts
|
|
85
|
+
* it to be an instance of the specifed {@link Error} {@link Constructor}.
|
|
86
|
+
*
|
|
87
|
+
* If specified, the {@link Error}'s own message will be further expected to
|
|
88
|
+
* either match the specified {@link RegExp}, or equal the specified `string`.
|
|
89
|
+
*/
|
|
90
|
+
toBeError<Class extends Constructor<Error>>(constructor: Class, message?: string | RegExp): Expectations<InstanceType<Class>>;
|
|
91
|
+
/** Expects the value strictly equal to `false`. */
|
|
92
|
+
toBeFalse(): Expectations<false>;
|
|
93
|
+
/**
|
|
94
|
+
* Expects the value to be _falsy_ (zero, empty string, `false`, ...).
|
|
95
|
+
*
|
|
96
|
+
* Negation: {@link Expectations.toBeTruthy `toBeTruthy()`}
|
|
97
|
+
*/
|
|
98
|
+
toBeFalsy(): Expectations<T>;
|
|
99
|
+
/**
|
|
100
|
+
* Expects the value to be a `number` greater than the specified expected
|
|
101
|
+
* value.
|
|
102
|
+
*
|
|
103
|
+
* Negation: {@link Expectations.toBeLessThanOrEqual `toBeLessThanOrEqual(...)`}
|
|
104
|
+
*/
|
|
105
|
+
toBeGreaterThan(value: number): Expectations<number>;
|
|
106
|
+
/**
|
|
107
|
+
* Expects the value to be a `bigint` greater than the specified expected
|
|
108
|
+
* value.
|
|
109
|
+
*
|
|
110
|
+
* Negation: {@link Expectations.toBeLessThanOrEqual `toBeLessThanOrEqual(...)`}
|
|
111
|
+
*/
|
|
112
|
+
toBeGreaterThan(value: bigint): Expectations<bigint>;
|
|
113
|
+
/**
|
|
114
|
+
* Expects the value to be a `number` greater than or equal to the specified
|
|
115
|
+
* expected value.
|
|
116
|
+
*
|
|
117
|
+
* Negation: {@link Expectations.toBeLessThan `toBeLessThan(...)`}
|
|
118
|
+
*/
|
|
119
|
+
toBeGreaterThanOrEqual(value: number): Expectations<number>;
|
|
120
|
+
/**
|
|
121
|
+
* Expects the value to be a `bigint` greater than or equal to the specified
|
|
122
|
+
* expected value.
|
|
123
|
+
*
|
|
124
|
+
* Negation: {@link Expectations.toBeLessThan `toBeLessThan(...)`}
|
|
125
|
+
*/
|
|
126
|
+
toBeGreaterThanOrEqual(value: bigint): Expectations<bigint>;
|
|
127
|
+
/**
|
|
128
|
+
* Expects the value to be an instance of the specified {@link Constructor},
|
|
129
|
+
* and (if specified) further asserts it with an {@link AssertionFunction}.
|
|
130
|
+
*
|
|
131
|
+
* Negation: {@link NegativeExpectations.toBeInstanceOf `not.toInstanceOf(...)`}
|
|
132
|
+
*/
|
|
133
|
+
toBeInstanceOf<Class extends Constructor, Assert extends AssertionFunction<InstanceType<Class>>>(constructor: Class, assertion?: Assert): Expectations<AssertedType<InstanceType<Class>, Assert>>;
|
|
134
|
+
/**
|
|
135
|
+
* Expects the value to be a `number` less than the specified expected value.
|
|
136
|
+
*
|
|
137
|
+
* Negation: {@link Expectations.toBeGreaterThanOrEqual `toBeGreaterThanOrEqual(...)`}
|
|
138
|
+
*/
|
|
139
|
+
toBeLessThan(value: number): Expectations<number>;
|
|
140
|
+
/**
|
|
141
|
+
* Expects the value to be a `bigint` less than the specified expected value.
|
|
142
|
+
*
|
|
143
|
+
* Negation: {@link Expectations.toBeGreaterThanOrEqual `toBeGreaterThanOrEqual(...)`}
|
|
144
|
+
*/
|
|
145
|
+
toBeLessThan(value: bigint): Expectations<bigint>;
|
|
146
|
+
/**
|
|
147
|
+
* Expects the value to be a `number` less than or equal to the specified
|
|
148
|
+
* expected value.
|
|
149
|
+
*
|
|
150
|
+
* Negation: {@link Expectations.toBeGreaterThan `toBeGreaterThan(...)`}
|
|
151
|
+
*/
|
|
152
|
+
toBeLessThanOrEqual(value: number): Expectations<number>;
|
|
153
|
+
/**
|
|
154
|
+
* Expects the value to be a `bigint` less than or equal to the specified
|
|
155
|
+
* expected value.
|
|
156
|
+
*
|
|
157
|
+
* Negation: {@link Expectations.toBeGreaterThan `toBeGreaterThan(...)`}
|
|
158
|
+
*/
|
|
159
|
+
toBeLessThanOrEqual(value: bigint): Expectations<bigint>;
|
|
160
|
+
/**
|
|
161
|
+
* Expects the value to be `NaN`.
|
|
162
|
+
*
|
|
163
|
+
* Negation: {@link NegativeExpectations.toBeNaN `not.toBeNaN()`}
|
|
164
|
+
*/
|
|
165
|
+
toBeNaN(): Expectations<number>;
|
|
166
|
+
/** Expects the value to strictly equal `null`. */
|
|
167
|
+
toBeNull(): Expectations<null>;
|
|
168
|
+
/** Expects the value to strictly equal `true`. */
|
|
169
|
+
toBeTrue(): Expectations<true>;
|
|
170
|
+
/**
|
|
171
|
+
* Expects the value to be _falsy_ (non-zero, non-empty string, ...).
|
|
172
|
+
*
|
|
173
|
+
* Negation: {@link Expectations.toBeFalsy `toBeFalsy()`}
|
|
174
|
+
*/
|
|
175
|
+
toBeTruthy(): Expectations<T>;
|
|
176
|
+
/** Expects the value to strictly equal `undefined`. */
|
|
177
|
+
toBeUndefined(): Expectations<undefined>;
|
|
178
|
+
/**
|
|
179
|
+
* Expects the value to be a `number` within the specified range where the
|
|
180
|
+
* minimum and maximum values are inclusive.
|
|
181
|
+
*
|
|
182
|
+
* Negation: {@link NegativeExpectations.toBeWithinRange `not.toBeWithinRange(...)`}
|
|
183
|
+
*/
|
|
184
|
+
toBeWithinRange(min: number, max: number): Expectations<number>;
|
|
185
|
+
/**
|
|
186
|
+
* Expects the value to be a `bigint` within the specified range where the
|
|
187
|
+
* minimum and maximum values are inclusive.
|
|
188
|
+
*
|
|
189
|
+
* Negation: {@link NegativeExpectations.toBeWithinRange `not.toBeWithinRange(...)`}
|
|
190
|
+
*/
|
|
191
|
+
toBeWithinRange(min: bigint, max: bigint): Expectations<bigint>;
|
|
192
|
+
/**
|
|
193
|
+
* Expects the value to be _deep equal to_ the specified expected one.
|
|
194
|
+
*
|
|
195
|
+
* Negation: {@link NegativeExpectations.toEqual `not.toEqual(...)`}
|
|
196
|
+
*/
|
|
197
|
+
toEqual<Type>(expected: Type): Expectations<InferMatchers<Type>>;
|
|
198
|
+
/**
|
|
199
|
+
* Expects the value to have a `number` _property_ `length` with the specified
|
|
200
|
+
* expected value.
|
|
201
|
+
*
|
|
202
|
+
* Negation: {@link NegativeExpectations.toHaveLength `not.toHaveLength(...)`}
|
|
203
|
+
*/
|
|
204
|
+
toHaveLength(length: number): Expectations<T & {
|
|
205
|
+
length: number;
|
|
206
|
+
}>;
|
|
207
|
+
/**
|
|
208
|
+
* Expects the value to have the specified _property_ and (if specified)
|
|
209
|
+
* further asserts its value with an {@link AssertionFunction}.
|
|
210
|
+
*
|
|
211
|
+
* Negation: {@link NegativeExpectations.toHaveProperty `not.toHaveProperty(...)`}
|
|
212
|
+
*/
|
|
213
|
+
toHaveProperty<Prop extends string | number | symbol, Assert extends AssertionFunction>(property: Prop, assertion?: Assert): Expectations<T & {
|
|
214
|
+
[keyt in Prop]: AssertedType<unknown, Assert>;
|
|
215
|
+
}>;
|
|
216
|
+
/**
|
|
217
|
+
* Expects the value to have a `number` _property_ `size` with the specified
|
|
218
|
+
* expected value.
|
|
219
|
+
*
|
|
220
|
+
* Negation: {@link NegativeExpectations.toHaveSize `not.toHaveSize(...)`}
|
|
221
|
+
*/
|
|
222
|
+
toHaveSize(size: number): Expectations<T & {
|
|
223
|
+
size: number;
|
|
224
|
+
}>;
|
|
225
|
+
/**
|
|
226
|
+
* Expect the value to include _all_ properties from the specified _object_.
|
|
227
|
+
*
|
|
228
|
+
* If the object being expected is a {@link Map}, the properties specified
|
|
229
|
+
* here will be treated as _mappings_ for said {@link Map}.
|
|
230
|
+
*
|
|
231
|
+
* Negation: {@link NegativeExpectations.toInclude `not.toInclude(...)`}
|
|
232
|
+
*/
|
|
233
|
+
toInclude<P extends Record<string, any>>(properties: P): Expectations<T>;
|
|
234
|
+
/**
|
|
235
|
+
* Expect the value to include _all_ mappings from the specified {@link Map}.
|
|
236
|
+
*
|
|
237
|
+
* Negation: {@link NegativeExpectations.toInclude `not.toInclude(...)`}
|
|
238
|
+
*/
|
|
239
|
+
toInclude(mappings: Map<any, any>): Expectations<T>;
|
|
240
|
+
/**
|
|
241
|
+
* Expect the value to be an {@link Iterable} object includind _all_ values
|
|
242
|
+
* from the specified {@link Set}, in any order.
|
|
243
|
+
*
|
|
244
|
+
* Negation: {@link NegativeExpectations.toInclude `not.toInclude(...)`}
|
|
245
|
+
*/
|
|
246
|
+
toInclude(entries: Set<any>): Expectations<T>;
|
|
247
|
+
/**
|
|
248
|
+
* Expect the value to be an {@link Iterable} object includind _all_ values
|
|
249
|
+
* from the specified _array_, in any order.
|
|
250
|
+
*
|
|
251
|
+
* Negation: {@link NegativeExpectations.toInclude `not.toInclude(...)`}
|
|
252
|
+
*/
|
|
253
|
+
toInclude(values: any[]): Expectations<T>;
|
|
254
|
+
/**
|
|
255
|
+
* Expects the value to be a `string` _matching_ the specified sub-`string`
|
|
256
|
+
* or {@link RegExp}.
|
|
257
|
+
*
|
|
258
|
+
* Negation: {@link NegativeExpectations.toMatch `not.toMatch(...)`}
|
|
259
|
+
*/
|
|
260
|
+
toMatch<Matcher extends string | RegExp>(matcher: Matcher): Expectations<string>;
|
|
261
|
+
/**
|
|
262
|
+
* Expect the value to be an {@link Iterable} object includind _all_ values
|
|
263
|
+
* (and only those values) from the specified _array_ or {@link Set},
|
|
264
|
+
* in any order.
|
|
265
|
+
*/
|
|
266
|
+
toMatchContents(contents: any[] | Set<any>): Expectations<T>;
|
|
267
|
+
/**
|
|
268
|
+
* Expects the value to be _strictly equal to_ the specified expected one.
|
|
269
|
+
*
|
|
270
|
+
* Negation: {@link NegativeExpectations.toStrictlyEqual `not.toStrictlyEqual(...)`}
|
|
271
|
+
*/
|
|
272
|
+
toStrictlyEqual<Type>(expected: Type): Expectations<Type>;
|
|
273
|
+
/**
|
|
274
|
+
* Expects the value to be a `function` throwing, and (if specified) further
|
|
275
|
+
* asserts the thrown value with an {@link AssertionFunction}.
|
|
276
|
+
*
|
|
277
|
+
* Negation: {@link NegativeExpectations.toThrow `not.toThrow()`}
|
|
278
|
+
*/
|
|
279
|
+
toThrow(assert?: AssertionFunction): Expectations<() => any>;
|
|
280
|
+
/**
|
|
281
|
+
* Expects the value to be a `function` throwing an {@link Error}.
|
|
282
|
+
*
|
|
283
|
+
* If specified, the {@link Error}'s own message will be further expected to
|
|
284
|
+
* either match the specified {@link RegExp}, or equal to the specified
|
|
285
|
+
* `string`.
|
|
286
|
+
*
|
|
287
|
+
* Negation: {@link NegativeExpectations.toThrow `not.toThrow()`}
|
|
288
|
+
*/
|
|
289
|
+
toThrowError(message?: string | RegExp): Expectations<() => any>;
|
|
290
|
+
/**
|
|
291
|
+
* Expects the value to be a `function` throwing an instance of the
|
|
292
|
+
* {@link Error} identified by the specified {@link Constructor}.
|
|
293
|
+
*
|
|
294
|
+
* If specified, the {@link Error}'s own message will be further expected to
|
|
295
|
+
* either match the specified {@link RegExp}, or equal to the specified
|
|
296
|
+
* `string`.
|
|
297
|
+
*
|
|
298
|
+
* Negation: {@link NegativeExpectations.toThrow `not.toThrow()`}
|
|
299
|
+
*/
|
|
300
|
+
toThrowError<Class extends Constructor<Error>>(constructor: Class, message?: string | RegExp): Expectations<() => any>;
|
|
301
|
+
}
|
|
302
|
+
/** Negative expectations, as a subset of (meaningful) expectations. */
|
|
303
|
+
export declare class NegativeExpectations<T = unknown> {
|
|
304
|
+
/** The {@link Expectations} instance associated with this one */
|
|
305
|
+
private readonly _expectations;
|
|
306
|
+
/** For convenience, the value associated with the {@link Expectations} */
|
|
307
|
+
private readonly _value;
|
|
308
|
+
/**
|
|
309
|
+
* Create a {@link NegativeExpectations} instance associated with the
|
|
310
|
+
* specified (positive) {@link Expectations}.
|
|
311
|
+
*/
|
|
312
|
+
constructor(
|
|
313
|
+
/** The {@link Expectations} instance associated with this one */
|
|
314
|
+
_expectations: Expectations<T>);
|
|
315
|
+
/** Throw an {@link ExpectationError} associated with _this_ */
|
|
316
|
+
private _fail;
|
|
317
|
+
/**
|
|
318
|
+
* Expects the value _**NOT**_ to be of the specified _extended_
|
|
319
|
+
* {@link TypeName type}.
|
|
320
|
+
*
|
|
321
|
+
* Negates: {@link Expectations.toBeA `toBeA(...)`}
|
|
322
|
+
*/
|
|
323
|
+
toBeA(type: TypeName): Expectations<T>;
|
|
324
|
+
/**
|
|
325
|
+
* Expects the value to be a `number` _**OUTSIDE**_ of the given +/- _delta_
|
|
326
|
+
* range of the specified expected value.
|
|
327
|
+
*
|
|
328
|
+
* Negates: {@link Expectations.toBeCloseTo `toBeCloseTo(...)`}
|
|
329
|
+
*/
|
|
330
|
+
toBeCloseTo(value: number, delta: number): Expectations<number>;
|
|
331
|
+
/**
|
|
332
|
+
* Expects the value to be a `bigint` _**OUTSIDE**_ of the given +/- _delta_
|
|
333
|
+
* range of the specified expected value.
|
|
334
|
+
*
|
|
335
|
+
* Negates: {@link Expectations.toBeCloseTo `toBeCloseTo(...)`}
|
|
336
|
+
*/
|
|
337
|
+
toBeCloseTo(value: bigint, delta: bigint): Expectations<bigint>;
|
|
338
|
+
/**
|
|
339
|
+
* Expects the value to be either `null` or `undefined`.
|
|
340
|
+
*
|
|
341
|
+
* Negates: {@link Expectations.toBeDefined `toBeDefined()`}
|
|
342
|
+
*/
|
|
343
|
+
toBeDefined(): Expectations<null | undefined>;
|
|
344
|
+
/**
|
|
345
|
+
* Expects the value _**NOT**_ to be an instance of the specified
|
|
346
|
+
* {@link Constructor}.
|
|
347
|
+
*
|
|
348
|
+
* Negates: {@link Expectations.toBeInstanceOf `toBeInstanceOf(...)`}
|
|
349
|
+
*/
|
|
350
|
+
toBeInstanceOf(constructor: Constructor): Expectations<T>;
|
|
351
|
+
/**
|
|
352
|
+
* Expects the value _**NOT**_ to be `NaN`.
|
|
353
|
+
*
|
|
354
|
+
* Negates: {@link Expectations.toBeNaN `toBeNaN()`}
|
|
355
|
+
*/
|
|
356
|
+
toBeNaN(): Expectations<number>;
|
|
357
|
+
/**
|
|
358
|
+
* Expects the value to be a `number` _**OUTSIDE**_ of the specified range
|
|
359
|
+
* where minimum and maximum values are inclusive.
|
|
360
|
+
*
|
|
361
|
+
* Negates: {@link Expectations.toBeWithinRange `toBeWithinRange(...)`}
|
|
362
|
+
*/
|
|
363
|
+
toBeWithinRange(min: number, max: number): Expectations<number>;
|
|
364
|
+
/**
|
|
365
|
+
* Expects the value to be a `bigint` _**OUTSIDE**_ of the specified range
|
|
366
|
+
* where minimum and maximum values are inclusive.
|
|
367
|
+
*
|
|
368
|
+
* Negates: {@link Expectations.toBeWithinRange `toBeWithinRange(...)`}
|
|
369
|
+
*/
|
|
370
|
+
toBeWithinRange(min: bigint, max: bigint): Expectations<bigint>;
|
|
371
|
+
/**
|
|
372
|
+
* Expects the value _**NOT**_ to be _deep equal to_ the specified expected
|
|
373
|
+
* one.
|
|
374
|
+
*
|
|
375
|
+
* Negates: {@link Expectations.toEqual `toEqual(...)`}
|
|
376
|
+
*/
|
|
377
|
+
toEqual(expected: any): Expectations<T>;
|
|
378
|
+
/**
|
|
379
|
+
* Expects the value to have a `number` _property_ `length` _different_ from
|
|
380
|
+
* the specified expected value.
|
|
381
|
+
*
|
|
382
|
+
* Negates: {@link Expectations.toHaveLength `toHaveLength(...)`}
|
|
383
|
+
*/
|
|
384
|
+
toHaveLength(length: number): Expectations<T & {
|
|
385
|
+
length: number;
|
|
386
|
+
}>;
|
|
387
|
+
/**
|
|
388
|
+
* Expects the value _**NOT**_ to have the specified _property_.
|
|
389
|
+
*
|
|
390
|
+
* Negates: {@link Expectations.toHaveProperty `toHaveProperty(...)`}
|
|
391
|
+
*/
|
|
392
|
+
toHaveProperty(property: string | number | symbol): Expectations<T>;
|
|
393
|
+
/**
|
|
394
|
+
* Expects the value to have a `number` _property_ `size` _different_ from
|
|
395
|
+
* the specified expected value.
|
|
396
|
+
*
|
|
397
|
+
* Negates: {@link Expectations.toHaveSize `toHaveSize(...)`}
|
|
398
|
+
*/
|
|
399
|
+
toHaveSize(size: number): Expectations<T & {
|
|
400
|
+
size: number;
|
|
401
|
+
}>;
|
|
402
|
+
/**
|
|
403
|
+
* Expect the value to include _none_ of the properties from the specified
|
|
404
|
+
* _object_.
|
|
405
|
+
*
|
|
406
|
+
* If the object being expected is a {@link Map}, the properties specified
|
|
407
|
+
* here will be treated as _mappings_ for said {@link Map}.
|
|
408
|
+
*
|
|
409
|
+
* Negates: {@link Expectations.toInclude `toInclude(...)`}
|
|
410
|
+
*/
|
|
411
|
+
toInclude<P extends Record<string, any>>(properties: P): Expectations<T>;
|
|
412
|
+
/**
|
|
413
|
+
* Expect the value to include _none_ of the mappings from the specified
|
|
414
|
+
* {@link Map}.
|
|
415
|
+
*
|
|
416
|
+
* Negates: {@link Expectations.toInclude `toInclude(...)`}
|
|
417
|
+
*/
|
|
418
|
+
toInclude(mappings: Map<any, any>): Expectations<T>;
|
|
419
|
+
/**
|
|
420
|
+
* Expect the value to be an {@link Iterable} object includind _none_ of the
|
|
421
|
+
* values from the specified {@link Set}.
|
|
422
|
+
*
|
|
423
|
+
* Negates: {@link Expectations.toInclude `toInclude(...)`}
|
|
424
|
+
*/
|
|
425
|
+
toInclude(entries: Set<any>): Expectations<T>;
|
|
426
|
+
/**
|
|
427
|
+
* Expect the value to be an {@link Iterable} object includind _none_ of the
|
|
428
|
+
* values from the specified _array_.
|
|
429
|
+
*
|
|
430
|
+
* Negates: {@link Expectations.toInclude `toInclude(...)`}
|
|
431
|
+
*/
|
|
432
|
+
toInclude(values: any[]): Expectations<T>;
|
|
433
|
+
/**
|
|
434
|
+
* Expects the value to be a `string` _**NOT MATCHING**_ the specified
|
|
435
|
+
* sub-`string` or {@link RegExp}.
|
|
436
|
+
*
|
|
437
|
+
* Negates: {@link Expectations.toMatch `toMatch(...)`}
|
|
438
|
+
*/
|
|
439
|
+
toMatch(matcher: string | RegExp): Expectations<string>;
|
|
440
|
+
/**
|
|
441
|
+
* Expects the value to be a `function` not throwing anything.
|
|
442
|
+
*
|
|
443
|
+
* Negates: {@link Expectations.toThrow `toThrow(...)`}
|
|
444
|
+
*/
|
|
445
|
+
toThrow(): Expectations<() => any>;
|
|
446
|
+
/**
|
|
447
|
+
* Expects the value _**NOT**_ to be _strictly equal to_ the specified
|
|
448
|
+
* expected one.
|
|
449
|
+
*
|
|
450
|
+
* Negates: {@link Expectations.toStrictlyEqual `toStrictlyEqual(...)`}
|
|
451
|
+
*/
|
|
452
|
+
toStrictlyEqual(expected: any): Expectations<T>;
|
|
453
|
+
}
|
|
454
|
+
export {};
|