@plugjs/expect5 0.4.3 → 0.4.5
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 +58 -45
- package/dist/expectation/async.cjs.map +1 -1
- package/dist/expectation/async.d.ts +53 -52
- package/dist/expectation/async.mjs +59 -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 +34 -5
- package/dist/test.cjs.map +1 -1
- package/dist/test.d.ts +2 -2
- package/dist/test.mjs +35 -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 +116 -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 +34 -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 -409
- package/src/expectation/throwing.ts +0 -106
- package/src/expectation/trivial.ts +0 -107
package/src/expectation/print.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { $grn, $gry, $red, $und, $wht, $ylw } from '@plugjs/plug/logging'
|
|
1
|
+
import { $grn, $gry, $red, $und, $wht, $ylw, type Logger } from '@plugjs/plug/logging'
|
|
2
2
|
import { textDiff } from '@plugjs/plug/utils'
|
|
3
3
|
|
|
4
|
+
import {
|
|
5
|
+
type Diff,
|
|
6
|
+
type ExpectedDiff,
|
|
7
|
+
type ExtraValueDiff,
|
|
8
|
+
type MissingValueDiff,
|
|
9
|
+
type ObjectDiff,
|
|
10
|
+
} from './diff'
|
|
4
11
|
import { stringifyValue } from './types'
|
|
5
12
|
|
|
6
|
-
import type { Diff, ExtraValueDiff, MissingValueDiff, ObjectDiff, ExpectedDiff } from './diff'
|
|
7
|
-
import type { Logger } from '@plugjs/plug/logging'
|
|
8
|
-
|
|
9
13
|
/* ========================================================================== *
|
|
10
14
|
* CONSTANT LABELS FOR PRINTING *
|
|
11
15
|
* ========================================================================== */
|
package/src/expectation/types.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
1
|
+
import { type Diff } from './diff'
|
|
2
|
+
import { type Expectations } from './expectations'
|
|
3
|
+
import { type Matchers } from './matchers'
|
|
3
4
|
|
|
4
5
|
/* ========================================================================== *
|
|
5
6
|
* INTERNAL TYPES FOR EXPECTATIONS *
|
|
@@ -44,45 +45,6 @@ export type TypeMappings = {
|
|
|
44
45
|
/** Values returned by our own _expanded_ `{@link typeOf}` */
|
|
45
46
|
export type TypeName = keyof TypeMappings
|
|
46
47
|
|
|
47
|
-
/** Join the asserted type of an {@link Expectations} with another type */
|
|
48
|
-
export type JoinExpectations<E, T2> =
|
|
49
|
-
E extends Expectations<infer T1> ? Expectations<T1 & T2> : Expectations<T2>
|
|
50
|
-
|
|
51
|
-
/** An assertion function, for sub-expectations and value introspection */
|
|
52
|
-
export type AssertionFunction<T = unknown> = (assert: Expectations<T>) => void | Expectations
|
|
53
|
-
|
|
54
|
-
/** Get the type asserted by an {@link AssertionFunction} */
|
|
55
|
-
export type AssertedType<F extends AssertionFunction<any>, R = ReturnType<F>> =
|
|
56
|
-
R extends Expectations<infer T> ? T : unknown
|
|
57
|
-
|
|
58
|
-
/** Internal context used by expectations functions to operate */
|
|
59
|
-
export interface ExpectationsContext<T = unknown> {
|
|
60
|
-
/** The value being expected */
|
|
61
|
-
readonly value: T,
|
|
62
|
-
/** Whether this is a negative or positive expectation */
|
|
63
|
-
readonly negative: boolean,
|
|
64
|
-
/** The optional parent of this instance, when constructed for a property */
|
|
65
|
-
readonly parent?: ExpectationsParent
|
|
66
|
-
/** The current _positive_ {@link Expectations} for the value */
|
|
67
|
-
readonly expects: Expectations<T>
|
|
68
|
-
/**
|
|
69
|
-
* If _negative_, the _negative_ {@link ExpectationFunctions} for the value,
|
|
70
|
-
* otherwise the _positive_ ones (basically, follow the `not` of `expect`).
|
|
71
|
-
*/
|
|
72
|
-
readonly negated: ExpectationFunctions<T>
|
|
73
|
-
|
|
74
|
-
/** Create an {@link Expectation} instance for the specified value */
|
|
75
|
-
forValue<V>(value: V): Expectations<V>,
|
|
76
|
-
/** Create an {@link Expectation} instance for a property of this value */
|
|
77
|
-
forProperty(prop: string | number | symbol): Expectations
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/** Parent expectations context (for properties) */
|
|
81
|
-
export interface ExpectationsParent {
|
|
82
|
-
context: ExpectationsContext,
|
|
83
|
-
prop: string | number | symbol,
|
|
84
|
-
}
|
|
85
|
-
|
|
86
48
|
/* ========================================================================== *
|
|
87
49
|
* TYPE INSPECTION, GUARD, AND ASSERTION *
|
|
88
50
|
* ========================================================================== */
|
|
@@ -119,16 +81,6 @@ export function typeOf(value: unknown): TypeName {
|
|
|
119
81
|
return 'object'
|
|
120
82
|
}
|
|
121
83
|
|
|
122
|
-
/** Asserts that the specified `value` is of the specified _expanded_ `type` */
|
|
123
|
-
export function assertContextType<T extends keyof TypeMappings>(
|
|
124
|
-
context: ExpectationsContext,
|
|
125
|
-
type: T,
|
|
126
|
-
): asserts context is ExpectationsContext<TypeMappings[T]> {
|
|
127
|
-
if (typeOf(context.value) === type) return
|
|
128
|
-
|
|
129
|
-
throw new ExpectationError(context, `to be ${prefixType(type)}`, false)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
84
|
/* ========================================================================== *
|
|
133
85
|
* PRETTY PRINTING FOR MESSAGES AND DIFFS *
|
|
134
86
|
* ========================================================================== */
|
|
@@ -188,7 +140,6 @@ export function stringifyValue(value: unknown): string {
|
|
|
188
140
|
}
|
|
189
141
|
|
|
190
142
|
// specific object types
|
|
191
|
-
if (isMatcher(value)) return '<matcher>'
|
|
192
143
|
if (value instanceof RegExp) return String(value)
|
|
193
144
|
if (value instanceof Date) return `[${constructorName(value)}: ${value.toISOString()}]`
|
|
194
145
|
if (value instanceof Boolean) return `[${constructorName(value)}: ${value.valueOf()}]`
|
|
@@ -238,10 +189,10 @@ export function prefixType(type: TypeName): string {
|
|
|
238
189
|
}
|
|
239
190
|
|
|
240
191
|
/* ========================================================================== *
|
|
241
|
-
* EXPECTATIONS MATCHERS MARKER
|
|
192
|
+
* EXPECTATIONS MATCHERS MARKER // avoids import loops *
|
|
242
193
|
* ========================================================================== */
|
|
243
194
|
|
|
244
|
-
export const matcherMarker = Symbol.for('plugjs:expect5:types:
|
|
195
|
+
export const matcherMarker = Symbol.for('plugjs:expect5:types:Matcher')
|
|
245
196
|
|
|
246
197
|
export function isMatcher(what: any): what is Matchers {
|
|
247
198
|
return what && what[matcherMarker] === matcherMarker
|
|
@@ -252,69 +203,46 @@ export function isMatcher(what: any): what is Matchers {
|
|
|
252
203
|
* ========================================================================== */
|
|
253
204
|
|
|
254
205
|
export class ExpectationError extends Error {
|
|
206
|
+
remarks?: string
|
|
255
207
|
diff?: Diff | undefined
|
|
256
208
|
|
|
257
|
-
/** Create an {@link ExpectationError} from a context and details message */
|
|
258
|
-
constructor(context: ExpectationsContext, details: string)
|
|
259
|
-
|
|
260
209
|
/**
|
|
261
|
-
* Create an {@link ExpectationError} from a
|
|
262
|
-
* including an optional {@link Diff}
|
|
210
|
+
* Create an {@link ExpectationError} from a {@link Expectations} instance
|
|
211
|
+
* and details message, including an optional {@link Diff}
|
|
263
212
|
*/
|
|
264
|
-
constructor(context: ExpectationsContext, details: string, diff?: Diff)
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Create an {@link ExpectationError} from a context and details message,
|
|
268
|
-
* optionally forcing _negation_ to be as specified.
|
|
269
|
-
*/
|
|
270
|
-
constructor(context: ExpectationsContext, details: string, forcedNegative?: boolean)
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* Create an {@link ExpectationError} from a context and details message,
|
|
274
|
-
* including an optional {@link Diff} and forcing _negation_ to be as
|
|
275
|
-
* specified.
|
|
276
|
-
*/
|
|
277
|
-
constructor(context: ExpectationsContext, details: string, diff?: Diff, forcedNegative?: boolean)
|
|
278
|
-
|
|
279
|
-
/* Overloaded constructor implementation */
|
|
280
213
|
constructor(
|
|
281
|
-
|
|
214
|
+
expectations: Expectations,
|
|
282
215
|
details: string,
|
|
283
|
-
|
|
284
|
-
maybeForcedNegative?: boolean,
|
|
216
|
+
diff?: Diff,
|
|
285
217
|
) {
|
|
286
|
-
const
|
|
287
|
-
const negative =
|
|
288
|
-
typeof diffOrForcedNegative === 'boolean' ? diffOrForcedNegative :
|
|
289
|
-
typeof maybeForcedNegative === 'boolean' ? maybeForcedNegative :
|
|
290
|
-
context.negative
|
|
291
|
-
|
|
292
|
-
const { value } = context
|
|
293
|
-
const not = negative ? ' not' : ''
|
|
218
|
+
const { value } = expectations
|
|
294
219
|
|
|
295
220
|
// if we're not root...
|
|
296
221
|
let preamble = stringifyValue(value)
|
|
297
|
-
if (
|
|
222
|
+
if (expectations.parent) {
|
|
298
223
|
const properties: any[] = []
|
|
299
224
|
|
|
300
|
-
while (
|
|
301
|
-
properties.push(`[${stringifyValue(
|
|
302
|
-
|
|
225
|
+
while (expectations.parent) {
|
|
226
|
+
properties.push(`[${stringifyValue(expectations.parent.prop)}]`)
|
|
227
|
+
expectations = expectations.parent.expectations
|
|
303
228
|
}
|
|
304
229
|
|
|
305
230
|
preamble = properties.reverse().join('')
|
|
306
231
|
|
|
307
232
|
// type of root value is constructor without details
|
|
308
|
-
const type = typeof
|
|
309
|
-
stringifyObjectType(
|
|
310
|
-
stringifyValue(
|
|
233
|
+
const type = typeof expectations.value === 'object' ?
|
|
234
|
+
stringifyObjectType(expectations.value as object) : // parent values can not be null!
|
|
235
|
+
stringifyValue(expectations.value)
|
|
311
236
|
|
|
312
237
|
// assemble the preamble
|
|
313
238
|
preamble = `property ${preamble} of ${type} (${stringifyValue(value)})`
|
|
314
239
|
}
|
|
315
240
|
|
|
316
|
-
|
|
241
|
+
// Super constructor!
|
|
242
|
+
super(`Expected ${preamble} ${details}`)
|
|
317
243
|
|
|
244
|
+
// Optional instance values
|
|
245
|
+
if (expectations.remarks) this.remarks = expectations.remarks
|
|
318
246
|
if (diff) this.diff = diff
|
|
319
247
|
}
|
|
320
248
|
}
|
package/src/globals.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { logging } from '@plugjs/plug'
|
|
2
2
|
import type { skip as SkipFunction } from './execution/executable'
|
|
3
3
|
import type { expect as ExpectFunction } from './expectation/expect'
|
|
4
|
-
import type
|
|
4
|
+
import type * as setup from './execution/setup'
|
|
5
5
|
|
|
6
6
|
declare global {
|
|
7
7
|
const describe: setup.SuiteFunction
|
package/src/index.ts
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
|
-
import { installForking } from '@plugjs/plug/fork'
|
|
1
|
+
import { installForking, type ForkOptions } from '@plugjs/plug/fork'
|
|
2
2
|
import { requireResolve } from '@plugjs/plug/paths'
|
|
3
3
|
|
|
4
|
-
import type { ForkOptions } from '@plugjs/plug/fork'
|
|
5
|
-
|
|
6
4
|
/* ========================================================================== *
|
|
7
5
|
* EXPORTED VARIABLES (for when globals is false) *
|
|
8
6
|
* ========================================================================== */
|
|
9
7
|
|
|
8
|
+
export { skip } from './execution/executable'
|
|
10
9
|
export {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
afterAll,
|
|
11
|
+
afterEach,
|
|
12
|
+
beforeAll,
|
|
13
|
+
beforeEach,
|
|
14
|
+
describe,
|
|
15
|
+
fdescribe,
|
|
16
|
+
fit,
|
|
17
|
+
it,
|
|
18
|
+
xafterAll,
|
|
19
|
+
xafterEach,
|
|
20
|
+
xbeforeAll,
|
|
21
|
+
xbeforeEach,
|
|
22
|
+
xdescribe,
|
|
23
|
+
xit,
|
|
15
24
|
} from './execution/setup'
|
|
16
|
-
export
|
|
17
|
-
export { expect } from './expectation/expect'
|
|
25
|
+
export * from './expectation/expect'
|
|
18
26
|
|
|
19
|
-
export type { Expectations } from './expectation/expect'
|
|
20
27
|
|
|
21
28
|
/* ========================================================================== *
|
|
22
29
|
* EXPORTED OPTIONS TYPE AND PLUG DEFINITION *
|
package/src/test.ts
CHANGED
|
@@ -4,21 +4,20 @@
|
|
|
4
4
|
import { AssertionError } from 'node:assert'
|
|
5
5
|
|
|
6
6
|
import { BuildFailure } from '@plugjs/plug'
|
|
7
|
-
import { $blu, $grn, $gry, $ms, $red, $wht, $ylw, log, ERROR, NOTICE, WARN } from '@plugjs/plug/logging'
|
|
8
7
|
import { assert } from '@plugjs/plug/asserts'
|
|
8
|
+
import { type Files } from '@plugjs/plug/files'
|
|
9
|
+
import { $blu, $grn, $gry, $ms, $red, $wht, $ylw, ERROR, NOTICE, WARN, log, type Logger } from '@plugjs/plug/logging'
|
|
10
|
+
import { type Context, type PipeParameters, type Plug } from '@plugjs/plug/pipe'
|
|
9
11
|
|
|
10
|
-
import
|
|
12
|
+
import * as setup from './execution/setup'
|
|
13
|
+
import { Suite, skip } from './execution/executable'
|
|
11
14
|
import { runSuite } from './execution/executor'
|
|
15
|
+
import { diff } from './expectation/diff'
|
|
12
16
|
import { expect } from './expectation/expect'
|
|
13
|
-
import { ExpectationError, stringifyObjectType } from './expectation/types'
|
|
14
17
|
import { printDiff } from './expectation/print'
|
|
15
|
-
import {
|
|
16
|
-
import * as setup from './execution/setup'
|
|
18
|
+
import { ExpectationError, stringifyObjectType, stringifyValue } from './expectation/types'
|
|
17
19
|
|
|
18
|
-
import type
|
|
19
|
-
import type { Logger } from '@plugjs/plug/logging'
|
|
20
|
-
import type { Context, PipeParameters, Plug } from '@plugjs/plug/pipe'
|
|
21
|
-
import type { TestOptions } from './index'
|
|
20
|
+
import { type TestOptions } from './index'
|
|
22
21
|
|
|
23
22
|
const _pending = '\u22EF' // middle ellipsis
|
|
24
23
|
const _success = '\u2714' // heavy check mark
|
|
@@ -176,6 +175,7 @@ function dumpError(log: Logger, error: any, genericErrorDiffs: boolean): void {
|
|
|
176
175
|
if (error instanceof ExpectationError) {
|
|
177
176
|
log.enter(ERROR, `${$gry('Expectation Error:')} ${$red(error.message)}`)
|
|
178
177
|
try {
|
|
178
|
+
dumpProps(log, 17, error)
|
|
179
179
|
dumpStack(log, error)
|
|
180
180
|
if (error.diff) printDiff(log, error.diff)
|
|
181
181
|
} finally {
|
|
@@ -188,6 +188,7 @@ function dumpError(log: Logger, error: any, genericErrorDiffs: boolean): void {
|
|
|
188
188
|
const [ message = 'Unknown Error', ...lines ] = error.message.split('\n')
|
|
189
189
|
log.enter(ERROR, `${$gry('Assertion Error:')} ${$red(message)}`)
|
|
190
190
|
try {
|
|
191
|
+
dumpProps(log, 15, error)
|
|
191
192
|
dumpStack(log, error)
|
|
192
193
|
|
|
193
194
|
// If we print diffs from generic errors, we take over
|
|
@@ -208,9 +209,12 @@ function dumpError(log: Logger, error: any, genericErrorDiffs: boolean): void {
|
|
|
208
209
|
// Any other error also gets printed somewhat nicely
|
|
209
210
|
} else if (error instanceof Error) {
|
|
210
211
|
const message = error.message || 'Unknown Error'
|
|
211
|
-
const
|
|
212
|
+
const string = stringifyObjectType(error)
|
|
213
|
+
// Chai calls its own assertion errors "AssertionError"
|
|
214
|
+
const type = string === '[AssertionError]' ? 'Assertion Error' : string
|
|
212
215
|
log.enter(ERROR, `${$gry(type)}: ${$red(message)}`)
|
|
213
216
|
try {
|
|
217
|
+
dumpProps(log, type.length, error)
|
|
214
218
|
dumpStack(log, error)
|
|
215
219
|
|
|
216
220
|
// if there are "actual" or "expected" properties on the error, diff!
|
|
@@ -229,6 +233,26 @@ function dumpError(log: Logger, error: any, genericErrorDiffs: boolean): void {
|
|
|
229
233
|
}
|
|
230
234
|
}
|
|
231
235
|
|
|
236
|
+
function dumpProps(log: Logger, pad: number, error: Error): void {
|
|
237
|
+
const keys = Object.keys(error)
|
|
238
|
+
.filter((k) => ![
|
|
239
|
+
'diff', // expectations error,
|
|
240
|
+
'actual', // assertion error, chai
|
|
241
|
+
'expected', // assertion error, chai,
|
|
242
|
+
'generatedMessage', // assertion error,
|
|
243
|
+
'message', // error
|
|
244
|
+
'showDiff', // chai
|
|
245
|
+
'stack', // error
|
|
246
|
+
].includes(k))
|
|
247
|
+
.forEach((k) => {
|
|
248
|
+
const value = error[k as keyof typeof error]
|
|
249
|
+
if ((k === 'code') && (value === 'ERR_ASSERTION')) return
|
|
250
|
+
const details = typeof value === 'string' ? value : stringifyValue(value)
|
|
251
|
+
log.error($gry(`${k}:`.padStart(pad - 1)), $ylw(details))
|
|
252
|
+
})
|
|
253
|
+
log.error('KEYS!!!', keys)
|
|
254
|
+
}
|
|
255
|
+
|
|
232
256
|
function dumpStack(log: Logger, error: Error): void {
|
|
233
257
|
if (! error.stack) return log.error('<no stack trace>')
|
|
234
258
|
error.stack
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// expectation/basic.ts
|
|
21
|
-
var basic_exports = {};
|
|
22
|
-
__export(basic_exports, {
|
|
23
|
-
toBeA: () => toBeA,
|
|
24
|
-
toBeCloseTo: () => toBeCloseTo,
|
|
25
|
-
toBeError: () => toBeError,
|
|
26
|
-
toBeGreaterThan: () => toBeGreaterThan,
|
|
27
|
-
toBeGreaterThanOrEqual: () => toBeGreaterThanOrEqual,
|
|
28
|
-
toBeInstanceOf: () => toBeInstanceOf,
|
|
29
|
-
toBeLessThan: () => toBeLessThan,
|
|
30
|
-
toBeLessThanOrEqual: () => toBeLessThanOrEqual,
|
|
31
|
-
toBeWithinRange: () => toBeWithinRange,
|
|
32
|
-
toEqual: () => toEqual,
|
|
33
|
-
toHaveLength: () => toHaveLength,
|
|
34
|
-
toHaveProperty: () => toHaveProperty,
|
|
35
|
-
toHaveSize: () => toHaveSize,
|
|
36
|
-
toMatch: () => toMatch,
|
|
37
|
-
toStrictlyEqual: () => toStrictlyEqual
|
|
38
|
-
});
|
|
39
|
-
module.exports = __toCommonJS(basic_exports);
|
|
40
|
-
var import_diff = require("./diff.cjs");
|
|
41
|
-
var import_types = require("./types.cjs");
|
|
42
|
-
function toBeA(type, assert) {
|
|
43
|
-
const match = (0, import_types.typeOf)(this.value) === type;
|
|
44
|
-
if (match === this.negative) {
|
|
45
|
-
throw new import_types.ExpectationError(this, `to be ${(0, import_types.prefixType)(type)}`);
|
|
46
|
-
} else if (assert) {
|
|
47
|
-
assert(this.expects);
|
|
48
|
-
}
|
|
49
|
-
return this.expects;
|
|
50
|
-
}
|
|
51
|
-
function toBeCloseTo(value, delta) {
|
|
52
|
-
const min = value - delta;
|
|
53
|
-
const max = value + delta;
|
|
54
|
-
return this.negated.toBeWithinRange(min, max);
|
|
55
|
-
}
|
|
56
|
-
function toBeError(...args) {
|
|
57
|
-
const [constructor, message] = typeof args[0] === "function" ? [args[0], args[1]] : [Error, args[0]];
|
|
58
|
-
this.negated.toBeInstanceOf(constructor);
|
|
59
|
-
if (this.negative || message === void 0)
|
|
60
|
-
return this.expects;
|
|
61
|
-
return this.expects.toHaveProperty("message", (assert) => {
|
|
62
|
-
assert.toBeA("string");
|
|
63
|
-
return typeof message === "string" ? assert.toStrictlyEqual(message) : assert.toMatch(message);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
function toBeGreaterThan(value) {
|
|
67
|
-
(0, import_types.assertContextType)(this, typeof value);
|
|
68
|
-
if (this.value > value !== this.negative)
|
|
69
|
-
return this.expects;
|
|
70
|
-
throw new import_types.ExpectationError(this, `to be greater than ${(0, import_types.stringifyValue)(value)}`);
|
|
71
|
-
}
|
|
72
|
-
function toBeGreaterThanOrEqual(value) {
|
|
73
|
-
(0, import_types.assertContextType)(this, typeof value);
|
|
74
|
-
if (this.value >= value !== this.negative)
|
|
75
|
-
return this.expects;
|
|
76
|
-
throw new import_types.ExpectationError(this, `to be greater than or equal to ${(0, import_types.stringifyValue)(value)}`);
|
|
77
|
-
}
|
|
78
|
-
function toBeInstanceOf(value) {
|
|
79
|
-
const match = this.value instanceof value;
|
|
80
|
-
if (match !== this.negative)
|
|
81
|
-
return this.expects;
|
|
82
|
-
throw new import_types.ExpectationError(this, `to be an instance of ${(0, import_types.stringifyConstructor)(value)}`);
|
|
83
|
-
}
|
|
84
|
-
function toBeLessThan(value) {
|
|
85
|
-
(0, import_types.assertContextType)(this, typeof value);
|
|
86
|
-
if (this.value < value !== this.negative)
|
|
87
|
-
return this.expects;
|
|
88
|
-
throw new import_types.ExpectationError(this, `to be less than ${(0, import_types.stringifyValue)(value)}`);
|
|
89
|
-
}
|
|
90
|
-
function toBeLessThanOrEqual(value) {
|
|
91
|
-
(0, import_types.assertContextType)(this, typeof value);
|
|
92
|
-
if (this.value <= value !== this.negative)
|
|
93
|
-
return this.expects;
|
|
94
|
-
throw new import_types.ExpectationError(this, `to be less than or equal to ${(0, import_types.stringifyValue)(value)}`);
|
|
95
|
-
}
|
|
96
|
-
function toBeWithinRange(min, max) {
|
|
97
|
-
if (max < min) {
|
|
98
|
-
const num = max;
|
|
99
|
-
max = min;
|
|
100
|
-
min = num;
|
|
101
|
-
}
|
|
102
|
-
(0, import_types.assertContextType)(this, typeof min);
|
|
103
|
-
if ((this.value >= min && this.value <= max) !== this.negative)
|
|
104
|
-
return this.expects;
|
|
105
|
-
throw new import_types.ExpectationError(this, `to be within ${(0, import_types.stringifyValue)(min)}...${(0, import_types.stringifyValue)(max)}`);
|
|
106
|
-
}
|
|
107
|
-
function toEqual(expected) {
|
|
108
|
-
const result = (0, import_diff.diff)(this.value, expected);
|
|
109
|
-
if (result.diff === this.negative)
|
|
110
|
-
return this.expects;
|
|
111
|
-
throw new import_types.ExpectationError(this, `to equal ${(0, import_types.stringifyValue)(expected)}`, result);
|
|
112
|
-
}
|
|
113
|
-
function toHaveLength(length) {
|
|
114
|
-
this.expects.toBeDefined();
|
|
115
|
-
const actualLength = this.value.length;
|
|
116
|
-
if (typeof actualLength !== "number") {
|
|
117
|
-
throw new import_types.ExpectationError(this, 'to have a numeric "length" property', false);
|
|
118
|
-
}
|
|
119
|
-
if (actualLength === length === this.negative) {
|
|
120
|
-
throw new import_types.ExpectationError(this, `to have length ${(0, import_types.stringifyValue)(length)}`);
|
|
121
|
-
}
|
|
122
|
-
return this.expects;
|
|
123
|
-
}
|
|
124
|
-
function toHaveProperty(prop, assert) {
|
|
125
|
-
this.expects.toBeDefined();
|
|
126
|
-
const match = this.value[prop] !== void 0;
|
|
127
|
-
if (match === this.negative) {
|
|
128
|
-
throw new import_types.ExpectationError(this, `to have property "${String(prop)}"`);
|
|
129
|
-
} else if (match && assert) {
|
|
130
|
-
try {
|
|
131
|
-
assert(this.forProperty(prop));
|
|
132
|
-
} catch (error) {
|
|
133
|
-
if (error instanceof import_types.ExpectationError && error.diff) {
|
|
134
|
-
error.diff = {
|
|
135
|
-
diff: true,
|
|
136
|
-
value: this.value,
|
|
137
|
-
props: { [prop]: error.diff }
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
throw error;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return this.expects;
|
|
144
|
-
}
|
|
145
|
-
function toHaveSize(size) {
|
|
146
|
-
this.expects.toBeDefined();
|
|
147
|
-
const actualSize = this.value.size;
|
|
148
|
-
if (typeof actualSize !== "number") {
|
|
149
|
-
throw new import_types.ExpectationError(this, 'to have a numeric "size" property', false);
|
|
150
|
-
}
|
|
151
|
-
if (actualSize === size === this.negative) {
|
|
152
|
-
throw new import_types.ExpectationError(this, `to have size ${(0, import_types.stringifyValue)(size)}`);
|
|
153
|
-
}
|
|
154
|
-
return this.expects;
|
|
155
|
-
}
|
|
156
|
-
function toMatch(expr) {
|
|
157
|
-
(0, import_types.assertContextType)(this, "string");
|
|
158
|
-
const match = !!this.value.match(expr);
|
|
159
|
-
if (match !== this.negative)
|
|
160
|
-
return this.expects;
|
|
161
|
-
throw new import_types.ExpectationError(this, `to match ${(0, import_types.stringifyValue)(expr)}`);
|
|
162
|
-
}
|
|
163
|
-
function toStrictlyEqual(expected) {
|
|
164
|
-
const match = this.value === expected;
|
|
165
|
-
if (match !== this.negative)
|
|
166
|
-
return this.expects;
|
|
167
|
-
const diff2 = this.negative ? void 0 : { diff: true, value: this.value, expected };
|
|
168
|
-
throw new import_types.ExpectationError(this, `to strictly equal ${(0, import_types.stringifyValue)(expected)}`, diff2);
|
|
169
|
-
}
|
|
170
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
171
|
-
0 && (module.exports = {
|
|
172
|
-
toBeA,
|
|
173
|
-
toBeCloseTo,
|
|
174
|
-
toBeError,
|
|
175
|
-
toBeGreaterThan,
|
|
176
|
-
toBeGreaterThanOrEqual,
|
|
177
|
-
toBeInstanceOf,
|
|
178
|
-
toBeLessThan,
|
|
179
|
-
toBeLessThanOrEqual,
|
|
180
|
-
toBeWithinRange,
|
|
181
|
-
toEqual,
|
|
182
|
-
toHaveLength,
|
|
183
|
-
toHaveProperty,
|
|
184
|
-
toHaveSize,
|
|
185
|
-
toMatch,
|
|
186
|
-
toStrictlyEqual
|
|
187
|
-
});
|
|
188
|
-
//# sourceMappingURL=basic.cjs.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/expectation/basic.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AACrB,mBAOO;AAyBP,SAAS,MAEL,MACA,QACY;AACd,QAAM,YAAQ,qBAAO,KAAK,KAAK,MAAM;AACrC,MAAI,UAAU,KAAK,UAAU;AAC3B,UAAM,IAAI,8BAAiB,MAAM,aAAS,yBAAW,IAAI,GAAG;AAAA,EAC9D,WAAW,QAAQ;AACjB,WAAO,KAAK,OAAO;AAAA,EACrB;AACA,SAAO,KAAK;AACd;AAiBA,SAAS,YAEL,OACA,OACY;AACd,QAAM,MAAO,QAAoB;AACjC,QAAM,MAAO,QAAoB;AACjC,SAAO,KAAK,QAAQ,gBAAgB,KAAK,GAAG;AAC9C;AAgCA,SAAS,aAEF,MAKS;AACd,QAAM,CAAE,aAAa,OAAQ,IAC3B,OAAO,KAAK,CAAC,MAAM,aACjB,CAAE,KAAK,CAAC,GAAG,KAAK,CAAC,CAAE,IACnB,CAAE,OAAO,KAAK,CAAC,CAAE;AAErB,OAAK,QAAQ,eAAe,WAAW;AAGvC,MAAI,KAAK,YAAa,YAAY;AAAY,WAAO,KAAK;AAE1D,SAAO,KAAK,QAAQ,eAAe,WAAW,CAAC,WAAW;AACxD,WAAO,MAAM,QAAQ;AACrB,WAAO,OAAO,YAAY,WACtB,OAAO,gBAAgB,OAAO,IAC9B,OAAO,QAAQ,OAAO;AAAA,EAC5B,CAAC;AACH;AAWA,SAAS,gBAEL,OACY;AACd,sCAAkB,MAAM,OAAO,KAA4B;AAC3D,MAAK,KAAK,QAAQ,UAAW,KAAK;AAAU,WAAO,KAAK;AACxD,QAAM,IAAI,8BAAiB,MAAM,0BAAsB,6BAAe,KAAK,GAAG;AAChF;AAUA,SAAS,uBAEL,OACY;AACd,sCAAkB,MAAM,OAAO,KAA4B;AAC3D,MAAK,KAAK,SAAS,UAAW,KAAK;AAAU,WAAO,KAAK;AACzD,QAAM,IAAI,8BAAiB,MAAM,sCAAkC,6BAAe,KAAK,GAAG;AAC5F;AAQA,SAAS,eAEL,OACY;AACd,QAAM,QAAQ,KAAK,iBAAiB;AACpC,MAAI,UAAU,KAAK;AAAU,WAAO,KAAK;AACzC,QAAM,IAAI,8BAAiB,MAAM,4BAAwB,mCAAqB,KAAK,GAAG;AACxF;AAUA,SAAS,aAEL,OACY;AACd,sCAAkB,MAAM,OAAO,KAA4B;AAC3D,MAAK,KAAK,QAAQ,UAAW,KAAK;AAAU,WAAO,KAAK;AACxD,QAAM,IAAI,8BAAiB,MAAM,uBAAmB,6BAAe,KAAK,GAAG;AAC7E;AAUA,SAAS,oBAEL,OACY;AACd,sCAAkB,MAAM,OAAO,KAA4B;AAC3D,MAAK,KAAK,SAAS,UAAW,KAAK;AAAU,WAAO,KAAK;AACzD,QAAM,IAAI,8BAAiB,MAAM,mCAA+B,6BAAe,KAAK,GAAG;AACzF;AAUA,SAAS,gBAEL,KACA,KACY;AACd,MAAI,MAAM,KAAK;AACb,UAAM,MAAM;AACZ,UAAM;AACN,UAAM;AAAA,EACR;AAEA,sCAAkB,MAAM,OAAO,GAA0B;AACzD,OAAM,KAAK,SAAS,OAAS,KAAK,SAAS,SAAU,KAAK;AAAU,WAAO,KAAK;AAChF,QAAM,IAAI,8BAAiB,MAAM,oBAAgB,6BAAe,GAAG,WAAO,6BAAe,GAAG,GAAG;AACjG;AAQA,SAAS,QAEL,UACY;AACd,QAAM,aAAS,kBAAK,KAAK,OAAO,QAAQ;AACxC,MAAI,OAAO,SAAS,KAAK;AAAU,WAAO,KAAK;AAC/C,QAAM,IAAI,8BAAiB,MAAM,gBAAY,6BAAe,QAAQ,KAAK,MAAM;AACjF;AAQA,SAAS,aAEL,QACY;AACd,OAAK,QAAQ,YAAY;AAEzB,QAAM,eAAgB,KAAK,MAAc;AACzC,MAAI,OAAO,iBAAiB,UAAU;AACpC,UAAM,IAAI,8BAAiB,MAAM,uCAAuC,KAAK;AAAA,EAC/E;AAEA,MAAK,iBAAiB,WAAY,KAAK,UAAU;AAC/C,UAAM,IAAI,8BAAiB,MAAM,sBAAkB,6BAAe,MAAM,GAAG;AAAA,EAC7E;AAEA,SAAO,KAAK;AACd;AAqBA,SAAS,eAEL,MACA,QACY;AACd,OAAK,QAAQ,YAAY;AAEzB,QAAM,QAAS,KAAK,MAAc,IAAI,MAAM;AAC5C,MAAI,UAAU,KAAK,UAAU;AAC3B,UAAM,IAAI,8BAAiB,MAAM,qBAAqB,OAAO,IAAI,IAAI;AAAA,EACvE,WAAW,SAAS,QAAQ;AAC1B,QAAI;AACF,aAAO,KAAK,YAAY,IAAI,CAAC;AAAA,IAC/B,SAAS,OAAP;AAEA,UAAK,iBAAiB,iCAAsB,MAAM,MAAO;AACvD,cAAM,OAAO;AAAA,UACX,MAAM;AAAA,UACN,OAAO,KAAK;AAAA,UACZ,OAAO,EAAE,CAAC,IAAI,GAAG,MAAM,KAAK;AAAA,QAC9B;AAAA,MACF;AAGA,YAAM;AAAA,IACR;AAAA,EACF;AAEA,SAAO,KAAK;AACd;AASA,SAAS,WAEL,MACY;AACd,OAAK,QAAQ,YAAY;AAEzB,QAAM,aAAc,KAAK,MAAc;AACvC,MAAI,OAAO,eAAe,UAAU;AAClC,UAAM,IAAI,8BAAiB,MAAM,qCAAqC,KAAK;AAAA,EAC7E;AAEA,MAAK,eAAe,SAAU,KAAK,UAAU;AAC3C,UAAM,IAAI,8BAAiB,MAAM,oBAAgB,6BAAe,IAAI,GAAG;AAAA,EACzE;AAEA,SAAO,KAAK;AACd;AAUA,SAAS,QAEL,MACY;AACd,sCAAkB,MAAM,QAAQ;AAEhC,QAAM,QAAQ,CAAC,CAAE,KAAK,MAAM,MAAM,IAAI;AACtC,MAAI,UAAU,KAAK;AAAU,WAAO,KAAK;AAEzC,QAAM,IAAI,8BAAiB,MAAM,gBAAY,6BAAe,IAAI,GAAG;AACrE;AASA,SAAS,gBAEL,UACY;AAEd,QAAM,QAAQ,KAAK,UAAU;AAC7B,MAAI,UAAU,KAAK;AAAU,WAAO,KAAK;AAEzC,QAAMA,QAAO,KAAK,WAAW,SAAY,EAAE,MAAM,MAAM,OAAO,KAAK,OAAO,SAAS;AACnF,QAAM,IAAI,8BAAiB,MAAM,yBAAqB,6BAAe,QAAQ,KAAKA,KAAI;AACxF;",
|
|
5
|
-
"names": ["diff"]
|
|
6
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { Expectations } from './expect';
|
|
2
|
-
import type { AssertedType, AssertionFunction, Constructor, JoinExpectations, TypeMappings, TypeName } from './types';
|
|
3
|
-
/** Expects the value to be of the specified {@link TypeName type}. */
|
|
4
|
-
declare function toBeA<T extends TypeName>(type: T): Expectations<TypeMappings[T]>;
|
|
5
|
-
/**
|
|
6
|
-
* Expects the value to be of the specified {@link TypeName type}, and further
|
|
7
|
-
* asserts it with the specified callback.
|
|
8
|
-
*/
|
|
9
|
-
declare function toBeA<T extends TypeName>(type: T, assert: (valueExpectations: Expectations) => void): Expectations<TypeMappings[T]>;
|
|
10
|
-
/**
|
|
11
|
-
* Expects the value to be a `number` within a given +/- delta range of the
|
|
12
|
-
* specified `number`.
|
|
13
|
-
*/
|
|
14
|
-
declare function toBeCloseTo(value: number, delta: number): Expectations<number>;
|
|
15
|
-
/**
|
|
16
|
-
* Expects the value to be a a `bigint` within a given +/- delta range of the
|
|
17
|
-
* specified `bigint`.
|
|
18
|
-
*/
|
|
19
|
-
declare function toBeCloseTo(value: bigint, delta: bigint): Expectations<bigint>;
|
|
20
|
-
/** Expects the value to be an {@link Error}. */
|
|
21
|
-
declare function toBeError(): Expectations<Error>;
|
|
22
|
-
/** Expects the value to be an {@link Error} with the specified message. */
|
|
23
|
-
declare function toBeError(message: string): Expectations<Error>;
|
|
24
|
-
/**
|
|
25
|
-
* Expects the value to be an {@link Error} with its message matching the
|
|
26
|
-
* specified {@link RegExp}.
|
|
27
|
-
*/
|
|
28
|
-
declare function toBeError(matcher: RegExp): Expectations<Error>;
|
|
29
|
-
/** Expects the value to be an {@link Error} of the specified _type_. */
|
|
30
|
-
declare function toBeError<C extends Constructor<Error>>(constructor: C): Expectations<InstanceType<C>>;
|
|
31
|
-
/**
|
|
32
|
-
* Expects the value to be an {@link Error} of the specified _type_ with the
|
|
33
|
-
* specified message
|
|
34
|
-
*/
|
|
35
|
-
declare function toBeError<C extends Constructor<Error>>(constructor: C, message: string): Expectations<InstanceType<C>>;
|
|
36
|
-
/**
|
|
37
|
-
* Expects the value to be an {@link Error} of the specified _type_ with the
|
|
38
|
-
* specified message
|
|
39
|
-
*/
|
|
40
|
-
declare function toBeError<C extends Constructor<Error>>(constructor: C, matcher: RegExp): Expectations<InstanceType<C>>;
|
|
41
|
-
/** Expects the value to be a `number` greater than the specified `number`. */
|
|
42
|
-
declare function toBeGreaterThan(value: number): Expectations<number>;
|
|
43
|
-
/** Expects the value to be a `bigint` greater than the specified `bigint`. */
|
|
44
|
-
declare function toBeGreaterThan(value: bigint): Expectations<bigint>;
|
|
45
|
-
/** Expects the value to be a `number` greater than or equal to the specified `number`. */
|
|
46
|
-
declare function toBeGreaterThanOrEqual(value: number): Expectations<number>;
|
|
47
|
-
/** Expects the value to be a `bigint` greater than or equal to the specified `bigint`. */
|
|
48
|
-
declare function toBeGreaterThanOrEqual(value: bigint): Expectations<bigint>;
|
|
49
|
-
/** Expects the value to be an instance of the specified _type_. */
|
|
50
|
-
declare function toBeInstanceOf<C extends Constructor>(value: C): Expectations<InstanceType<C>>;
|
|
51
|
-
/** Expects the value to be a `number` less than the specified `number`. */
|
|
52
|
-
declare function toBeLessThan(value: number): Expectations<number>;
|
|
53
|
-
/** Expects the value to be a `bigint` less than the specified `bigint`. */
|
|
54
|
-
declare function toBeLessThan(value: bigint): Expectations<bigint>;
|
|
55
|
-
/** Expects the value to be a `number` less than or equal to the specified `number`. */
|
|
56
|
-
declare function toBeLessThanOrEqual(value: number): Expectations<number>;
|
|
57
|
-
/** Expects the value to be a `bigint` less than or equal to the specified `bigint`. */
|
|
58
|
-
declare function toBeLessThanOrEqual(value: bigint): Expectations<bigint>;
|
|
59
|
-
/** Expects the value to be a `number` within the specified range (inclusive). */
|
|
60
|
-
declare function toBeWithinRange(min: number, max: number): Expectations<number>;
|
|
61
|
-
/** Expects the value to be a `bigint` within the specified range (inclusive). */
|
|
62
|
-
declare function toBeWithinRange(min: bigint, max: bigint): Expectations<bigint>;
|
|
63
|
-
/** Expects the value to _deeply equal_ to the specified expected value. */
|
|
64
|
-
declare function toEqual<T>(expected: T): Expectations<T>;
|
|
65
|
-
/** Expects the value to have a numerical `length` property with the specified value. */
|
|
66
|
-
declare function toHaveLength<T, N extends number>(this: T, length: N): JoinExpectations<T, {
|
|
67
|
-
length: N;
|
|
68
|
-
}>;
|
|
69
|
-
/** Expects the value to have a property. */
|
|
70
|
-
declare function toHaveProperty<T, P extends string | number | symbol, A extends AssertionFunction>(this: T, prop: P): JoinExpectations<T, {
|
|
71
|
-
[key in P]: AssertedType<A>;
|
|
72
|
-
}>;
|
|
73
|
-
/**
|
|
74
|
-
* Expects the value to have a property, and further asserts the property
|
|
75
|
-
* value with the specified callback.
|
|
76
|
-
*/
|
|
77
|
-
declare function toHaveProperty<T, P extends string | number | symbol, A extends AssertionFunction>(this: T, prop: P, assert: A): JoinExpectations<T, {
|
|
78
|
-
[key in P]: AssertedType<A>;
|
|
79
|
-
}>;
|
|
80
|
-
/** Expects the value to have a numerical `size` property with the specified value. */
|
|
81
|
-
declare function toHaveSize<T, N extends number>(this: T, size: N): JoinExpectations<T, {
|
|
82
|
-
size: N;
|
|
83
|
-
}>;
|
|
84
|
-
/** Expects the value to be a `string` _matching_ the specified substring. */
|
|
85
|
-
declare function toMatch(substring: string): Expectations<string>;
|
|
86
|
-
/** Expects the value to be a `string` _matching_ the specified {@link RegExp}. */
|
|
87
|
-
declare function toMatch(expression: RegExp): Expectations<string>;
|
|
88
|
-
/** Expects the value to _strictly equal_ to the specified expected value. */
|
|
89
|
-
declare function toStrictlyEqual<T>(expected: T): Expectations<T>;
|
|
90
|
-
export { toBeA, toBeCloseTo, toBeError, toBeGreaterThan, toBeGreaterThanOrEqual, toBeInstanceOf, toBeLessThan, toBeLessThanOrEqual, toBeWithinRange, toEqual, toHaveLength, toHaveProperty, toHaveSize, toMatch, toStrictlyEqual, };
|