strong-mock 8.0.0 → 9.0.0-beta.0
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/README.md +53 -31
- package/dist/errors/api.d.ts +13 -0
- package/dist/errors/unexpected-access.d.ts +5 -0
- package/dist/errors/unexpected-call.d.ts +17 -0
- package/dist/errors/verify.d.ts +8 -0
- package/dist/expectation/expectation.d.ts +27 -30
- package/dist/expectation/repository/expectation-repository.d.ts +90 -90
- package/dist/expectation/repository/flexible-repository.d.ts +38 -38
- package/dist/expectation/repository/return-value.d.ts +13 -13
- package/dist/expectation/strong-expectation.d.ts +30 -30
- package/dist/index.d.ts +14 -9
- package/dist/index.js +815 -512
- package/dist/index.js.map +1 -1
- package/dist/matchers/deep-equals.d.ts +16 -0
- package/dist/matchers/is-any.d.ts +11 -0
- package/dist/matchers/is-array.d.ts +22 -0
- package/dist/matchers/is-number.d.ts +12 -0
- package/dist/matchers/is-object.d.ts +27 -0
- package/dist/matchers/is-string.d.ts +15 -0
- package/dist/matchers/is.d.ts +9 -0
- package/dist/matchers/it.d.ts +9 -0
- package/dist/matchers/matcher.d.ts +92 -0
- package/dist/matchers/will-capture.d.ts +21 -0
- package/dist/mock/defaults.d.ts +11 -11
- package/dist/mock/map.d.ts +16 -16
- package/dist/mock/mock.d.ts +29 -29
- package/dist/mock/options.d.ts +99 -99
- package/dist/mock/stub.d.ts +5 -5
- package/dist/print.d.ts +10 -10
- package/dist/proxy.d.ts +48 -48
- package/dist/return/invocation-count.d.ts +44 -44
- package/dist/return/returns.d.ts +61 -77
- package/dist/verify/reset.d.ts +20 -20
- package/dist/verify/verify.d.ts +27 -27
- package/dist/when/{pending-expectation.d.ts → expectation-builder.d.ts} +26 -31
- package/dist/when/when.d.ts +32 -32
- package/package.json +20 -16
- package/dist/errors.d.ts +0 -28
- package/dist/expectation/it.d.ts +0 -29
- package/dist/expectation/matcher.d.ts +0 -21
package/dist/return/returns.d.ts
CHANGED
|
@@ -1,77 +1,61 @@
|
|
|
1
|
-
import type { ExpectationRepository } from '../expectation/repository/expectation-repository';
|
|
2
|
-
import type {
|
|
3
|
-
import type { InvocationCount } from './invocation-count';
|
|
4
|
-
export
|
|
5
|
-
/**
|
|
6
|
-
* Set the return value for the current call.
|
|
7
|
-
*
|
|
8
|
-
* @param value This needs to be of the same type as the value returned
|
|
9
|
-
* by the call inside `when`.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* when(() => fn()).thenReturn(Promise.resolve(23));
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* when(() => fn()).thenReturn(Promise.reject({ foo: 'bar' });
|
|
16
|
-
*/
|
|
17
|
-
thenReturn(value: P)
|
|
18
|
-
/**
|
|
19
|
-
* Set the return value for the current call.
|
|
20
|
-
*
|
|
21
|
-
* @param promiseValue This needs to be of the same type as the value inside
|
|
22
|
-
* the promise returned by the `when` callback.
|
|
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
|
-
* @param message Will be wrapped in `new Error()`. If you want to throw
|
|
64
|
-
* a custom error pass it here instead of the message.
|
|
65
|
-
*/
|
|
66
|
-
thenThrow(message: string): InvocationCount;
|
|
67
|
-
/**
|
|
68
|
-
* Make the current call throw `new Error()`.
|
|
69
|
-
*/
|
|
70
|
-
thenThrow(): InvocationCount;
|
|
71
|
-
};
|
|
72
|
-
export declare const createReturns: (pendingExpectation: PendingExpectation, repository: ExpectationRepository) => {
|
|
73
|
-
thenReturn: (returnValue: any) => InvocationCount;
|
|
74
|
-
thenThrow: (errorOrMessage?: Error | string) => InvocationCount;
|
|
75
|
-
thenResolve: (promiseValue: any) => InvocationCount;
|
|
76
|
-
thenReject: (errorOrMessage?: Error | string) => InvocationCount;
|
|
77
|
-
};
|
|
1
|
+
import type { ExpectationRepository } from '../expectation/repository/expectation-repository';
|
|
2
|
+
import type { ExpectationBuilder } from '../when/expectation-builder';
|
|
3
|
+
import type { InvocationCount } from './invocation-count';
|
|
4
|
+
export type PromiseStub<R, P> = {
|
|
5
|
+
/**
|
|
6
|
+
* Set the return value for the current call.
|
|
7
|
+
*
|
|
8
|
+
* @param value This needs to be of the same type as the value returned
|
|
9
|
+
* by the call inside `when`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* when(() => fn()).thenReturn(Promise.resolve(23));
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* when(() => fn()).thenReturn(Promise.reject({ foo: 'bar' });
|
|
16
|
+
*/
|
|
17
|
+
thenReturn: (value: P) => InvocationCount;
|
|
18
|
+
/**
|
|
19
|
+
* Set the return value for the current call.
|
|
20
|
+
*
|
|
21
|
+
* @param promiseValue This needs to be of the same type as the value inside
|
|
22
|
+
* the promise returned by the `when` callback.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* when(() => fn()).thenResolve('foo');
|
|
26
|
+
*/
|
|
27
|
+
thenResolve: (promiseValue: R) => InvocationCount;
|
|
28
|
+
/**
|
|
29
|
+
* Make the current call reject with the given error.
|
|
30
|
+
*
|
|
31
|
+
* @param error An `Error` instance. You can pass just a message, and
|
|
32
|
+
* it will be wrapped in an `Error` instance. If you want to reject with
|
|
33
|
+
* a non error then use the {@link thenReturn} method.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* when(() => fn()).thenReject(new Error('oops'));
|
|
37
|
+
*/
|
|
38
|
+
thenReject: ((error: Error) => InvocationCount) & ((message: string) => InvocationCount) & (() => InvocationCount);
|
|
39
|
+
};
|
|
40
|
+
export type NonPromiseStub<R> = {
|
|
41
|
+
/**
|
|
42
|
+
* Set the return value for the current call.
|
|
43
|
+
*
|
|
44
|
+
* @param returnValue This needs to be of the same type as the value returned
|
|
45
|
+
* by the `when` callback.
|
|
46
|
+
*/
|
|
47
|
+
thenReturn: (returnValue: R) => InvocationCount;
|
|
48
|
+
/**
|
|
49
|
+
* Make the current call throw the given error.
|
|
50
|
+
*
|
|
51
|
+
* @param error The error instance. If you want to throw a simple `Error`
|
|
52
|
+
* you can pass just the message.
|
|
53
|
+
*/
|
|
54
|
+
thenThrow: ((error: Error) => InvocationCount) & ((message: string) => InvocationCount) & (() => InvocationCount);
|
|
55
|
+
};
|
|
56
|
+
export declare const createReturns: (builder: ExpectationBuilder, repository: ExpectationRepository) => {
|
|
57
|
+
thenReturn: (returnValue: any) => InvocationCount;
|
|
58
|
+
thenThrow: (errorOrMessage?: Error | string) => InvocationCount;
|
|
59
|
+
thenResolve: (promiseValue: any) => InvocationCount;
|
|
60
|
+
thenReject: (errorOrMessage?: Error | string) => InvocationCount;
|
|
61
|
+
};
|
package/dist/verify/reset.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type { Mock } from '../mock/mock';
|
|
2
|
-
/**
|
|
3
|
-
* Remove any remaining expectations on the given mock.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* const fn = mock<() => number>();
|
|
7
|
-
*
|
|
8
|
-
* when(() => fn()).thenReturn(23);
|
|
9
|
-
*
|
|
10
|
-
* reset(fn);
|
|
11
|
-
*
|
|
12
|
-
* fn(); // throws
|
|
13
|
-
*/
|
|
14
|
-
export declare const reset: (mock: Mock<any>) => void;
|
|
15
|
-
/**
|
|
16
|
-
* Reset all existing mocks.
|
|
17
|
-
*
|
|
18
|
-
* @see reset
|
|
19
|
-
*/
|
|
20
|
-
export declare const resetAll: () => void;
|
|
1
|
+
import type { Mock } from '../mock/mock';
|
|
2
|
+
/**
|
|
3
|
+
* Remove any remaining expectations on the given mock.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const fn = mock<() => number>();
|
|
7
|
+
*
|
|
8
|
+
* when(() => fn()).thenReturn(23);
|
|
9
|
+
*
|
|
10
|
+
* reset(fn);
|
|
11
|
+
*
|
|
12
|
+
* fn(); // throws
|
|
13
|
+
*/
|
|
14
|
+
export declare const reset: (mock: Mock<any>) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Reset all existing mocks.
|
|
17
|
+
*
|
|
18
|
+
* @see reset
|
|
19
|
+
*/
|
|
20
|
+
export declare const resetAll: () => void;
|
package/dist/verify/verify.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import type { ExpectationRepository } from '../expectation/repository/expectation-repository';
|
|
2
|
-
import type { Mock } from '../mock/mock';
|
|
3
|
-
export declare const verifyRepo: (repository: ExpectationRepository) => void;
|
|
4
|
-
/**
|
|
5
|
-
* Verify that all expectations on the given mock have been met.
|
|
6
|
-
*
|
|
7
|
-
* @throws Will throw if there are remaining expectations that were set
|
|
8
|
-
* using `when` and that weren't met.
|
|
9
|
-
*
|
|
10
|
-
* @throws Will throw if any unexpected calls happened. Normally those
|
|
11
|
-
* calls throw on their own, but the error might be caught by the code
|
|
12
|
-
* being tested.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* const fn = mock<() => number>();
|
|
16
|
-
*
|
|
17
|
-
* when(() => fn()).thenReturn(23);
|
|
18
|
-
*
|
|
19
|
-
* verify(fn); // throws
|
|
20
|
-
*/
|
|
21
|
-
export declare const verify: <T>(mock: T) => void;
|
|
22
|
-
/**
|
|
23
|
-
* Verify all existing mocks.
|
|
24
|
-
*
|
|
25
|
-
* @see verify
|
|
26
|
-
*/
|
|
27
|
-
export declare const verifyAll: () => void;
|
|
1
|
+
import type { ExpectationRepository } from '../expectation/repository/expectation-repository';
|
|
2
|
+
import type { Mock } from '../mock/mock';
|
|
3
|
+
export declare const verifyRepo: (repository: ExpectationRepository) => void;
|
|
4
|
+
/**
|
|
5
|
+
* Verify that all expectations on the given mock have been met.
|
|
6
|
+
*
|
|
7
|
+
* @throws Will throw if there are remaining expectations that were set
|
|
8
|
+
* using `when` and that weren't met.
|
|
9
|
+
*
|
|
10
|
+
* @throws Will throw if any unexpected calls happened. Normally those
|
|
11
|
+
* calls throw on their own, but the error might be caught by the code
|
|
12
|
+
* being tested.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const fn = mock<() => number>();
|
|
16
|
+
*
|
|
17
|
+
* when(() => fn()).thenReturn(23);
|
|
18
|
+
*
|
|
19
|
+
* verify(fn); // throws
|
|
20
|
+
*/
|
|
21
|
+
export declare const verify: <T>(mock: T) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Verify all existing mocks.
|
|
24
|
+
*
|
|
25
|
+
* @see verify
|
|
26
|
+
*/
|
|
27
|
+
export declare const verifyAll: () => void;
|
|
@@ -1,31 +1,26 @@
|
|
|
1
|
-
import type { Expectation } from '../expectation/expectation';
|
|
2
|
-
import type { ReturnValue } from '../expectation/repository/return-value';
|
|
3
|
-
import type { ConcreteMatcher } from '../mock/options';
|
|
4
|
-
import type { Property } from '../proxy';
|
|
5
|
-
/**
|
|
6
|
-
* An expectation has to be built incrementally, starting first with the property
|
|
7
|
-
* being accessed inside {@link createStub}, then any arguments passed to it, and ending
|
|
8
|
-
* it with the returned value from {@link createReturns}.
|
|
9
|
-
*/
|
|
10
|
-
export interface
|
|
11
|
-
setProperty(prop: Property)
|
|
12
|
-
setArgs(args:
|
|
13
|
-
finish(returnValue: ReturnValue)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
setProperty(value: Property): void;
|
|
28
|
-
setArgs(value: any[] | undefined): void;
|
|
29
|
-
finish(returnValue: ReturnValue): Expectation;
|
|
30
|
-
toJSON(): string;
|
|
31
|
-
}
|
|
1
|
+
import type { Expectation } from '../expectation/expectation';
|
|
2
|
+
import type { ReturnValue } from '../expectation/repository/return-value';
|
|
3
|
+
import type { ConcreteMatcher } from '../mock/options';
|
|
4
|
+
import type { Property } from '../proxy';
|
|
5
|
+
/**
|
|
6
|
+
* An expectation has to be built incrementally, starting first with the property
|
|
7
|
+
* being accessed inside {@link createStub}, then any arguments passed to it, and ending
|
|
8
|
+
* it with the returned value from {@link createReturns}.
|
|
9
|
+
*/
|
|
10
|
+
export interface ExpectationBuilder {
|
|
11
|
+
setProperty: (prop: Property) => void;
|
|
12
|
+
setArgs: (args: unknown[] | undefined) => void;
|
|
13
|
+
finish: (returnValue: ReturnValue) => Expectation;
|
|
14
|
+
}
|
|
15
|
+
export type ExpectationFactory = (property: Property, args: any[] | undefined, returnValue: ReturnValue, concreteMatcher: ConcreteMatcher, exactParams: boolean) => Expectation;
|
|
16
|
+
export declare class ExpectationBuilderWithFactory implements ExpectationBuilder {
|
|
17
|
+
private createExpectation;
|
|
18
|
+
private concreteMatcher;
|
|
19
|
+
private exactParams;
|
|
20
|
+
private args;
|
|
21
|
+
private property;
|
|
22
|
+
constructor(createExpectation: ExpectationFactory, concreteMatcher: ConcreteMatcher, exactParams: boolean);
|
|
23
|
+
setProperty(value: Property): void;
|
|
24
|
+
setArgs(value: unknown[] | undefined): void;
|
|
25
|
+
finish(returnValue: ReturnValue): Expectation;
|
|
26
|
+
}
|
package/dist/when/when.d.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import type { NonPromiseStub, PromiseStub } from '../return/returns';
|
|
2
|
-
interface When {
|
|
3
|
-
<R>(expectation: () => Promise<R>): PromiseStub<R, Promise<R>>;
|
|
4
|
-
<R>(expectation: () => R): NonPromiseStub<R>;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Set an expectation on a mock.
|
|
8
|
-
*
|
|
9
|
-
* The expectation must be finished by setting a return value, even if the value
|
|
10
|
-
* is `undefined`.
|
|
11
|
-
*
|
|
12
|
-
* If a call happens that was not expected then the mock will throw an error.
|
|
13
|
-
* By default, the call is expected to only be made once. Use the invocation
|
|
14
|
-
* count helpers to expect a call multiple times.
|
|
15
|
-
*
|
|
16
|
-
* @param expectation A callback to set the expectation on your mock. The
|
|
17
|
-
* callback must return the value from the mock to properly infer types.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* const fn = mock<() => void>();
|
|
21
|
-
* when(() => fn()).thenReturn(undefined);
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* const fn = mock<() => number>();
|
|
25
|
-
* when(() => fn()).thenReturn(42).atMost(3);
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* const fn = mock<(x: number) => Promise<number>();
|
|
29
|
-
* when(() => fn(23)).thenResolve(42);
|
|
30
|
-
*/
|
|
31
|
-
export declare const when: When;
|
|
32
|
-
export {};
|
|
1
|
+
import type { NonPromiseStub, PromiseStub } from '../return/returns';
|
|
2
|
+
interface When {
|
|
3
|
+
<R>(expectation: () => Promise<R>): PromiseStub<R, Promise<R>>;
|
|
4
|
+
<R>(expectation: () => R): NonPromiseStub<R>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Set an expectation on a mock.
|
|
8
|
+
*
|
|
9
|
+
* The expectation must be finished by setting a return value, even if the value
|
|
10
|
+
* is `undefined`.
|
|
11
|
+
*
|
|
12
|
+
* If a call happens that was not expected then the mock will throw an error.
|
|
13
|
+
* By default, the call is expected to only be made once. Use the invocation
|
|
14
|
+
* count helpers to expect a call multiple times.
|
|
15
|
+
*
|
|
16
|
+
* @param expectation A callback to set the expectation on your mock. The
|
|
17
|
+
* callback must return the value from the mock to properly infer types.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const fn = mock<() => void>();
|
|
21
|
+
* when(() => fn()).thenReturn(undefined);
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const fn = mock<() => number>();
|
|
25
|
+
* when(() => fn()).thenReturn(42).atMost(3);
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* const fn = mock<(x: number) => Promise<number>();
|
|
29
|
+
* when(() => fn(23)).thenResolve(42);
|
|
30
|
+
*/
|
|
31
|
+
export declare const when: When;
|
|
32
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strong-mock",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "9.0.0-beta.0",
|
|
4
|
+
"description": "Type safe mocking library for TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tdd",
|
|
7
|
+
"test",
|
|
7
8
|
"mock",
|
|
9
|
+
"expectation",
|
|
10
|
+
"stub",
|
|
8
11
|
"interface",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
12
|
+
"type",
|
|
13
|
+
"typescript"
|
|
11
14
|
],
|
|
12
15
|
"repository": {
|
|
13
16
|
"type": "git",
|
|
@@ -21,25 +24,26 @@
|
|
|
21
24
|
"dist"
|
|
22
25
|
],
|
|
23
26
|
"dependencies": {
|
|
24
|
-
"jest-
|
|
25
|
-
"
|
|
27
|
+
"jest-diff": "~29.4.3",
|
|
28
|
+
"jest-matcher-utils": "~29.7.0",
|
|
29
|
+
"lodash": "~4.17.0",
|
|
30
|
+
"strip-ansi": "~6.0.0"
|
|
26
31
|
},
|
|
27
32
|
"devDependencies": {
|
|
28
|
-
"@nighttrax/eslint-config-ts": "~
|
|
29
|
-
"@tdd-buffet/jest-config": "~
|
|
30
|
-
"@tdd-buffet/tsconfig": "~1.0.
|
|
31
|
-
"@types/jest": "~
|
|
32
|
-
"@types/node": "~17.0
|
|
33
|
+
"@nighttrax/eslint-config-ts": "~12.0.0-alpha.0",
|
|
34
|
+
"@tdd-buffet/jest-config": "~6.0.0",
|
|
35
|
+
"@tdd-buffet/tsconfig": "~1.0.5",
|
|
36
|
+
"@types/jest": "~29.5.0",
|
|
37
|
+
"@types/node": "~18.17.0",
|
|
33
38
|
"@types/lodash": "~4.14.0",
|
|
34
39
|
"doctoc": "~2.2.0",
|
|
35
|
-
"eslint": "~8.
|
|
36
|
-
"jest": "~
|
|
40
|
+
"eslint": "~8.49.0",
|
|
41
|
+
"jest": "~29.7.0",
|
|
37
42
|
"microbundle": "~0.15.0",
|
|
38
43
|
"standard-version": "~9.5.0",
|
|
39
|
-
"strip-ansi": "~6.0.0",
|
|
40
44
|
"strong-mock": "~6.0.0",
|
|
41
|
-
"tslib": "~2.
|
|
42
|
-
"typescript": "~
|
|
45
|
+
"tslib": "~2.6.0",
|
|
46
|
+
"typescript": "~5.2.0"
|
|
43
47
|
},
|
|
44
48
|
"scripts": {
|
|
45
49
|
"docs": "doctoc --title '**Table of Contents**' README.md",
|
package/dist/errors.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Expectation } from './expectation/expectation';
|
|
2
|
-
import type { CallMap } from './expectation/repository/expectation-repository';
|
|
3
|
-
import type { Property } from './proxy';
|
|
4
|
-
import type { PendingExpectation } from './when/pending-expectation';
|
|
5
|
-
export declare class UnfinishedExpectation extends Error {
|
|
6
|
-
constructor(pendingExpectation: PendingExpectation);
|
|
7
|
-
}
|
|
8
|
-
export declare class MissingWhen extends Error {
|
|
9
|
-
constructor();
|
|
10
|
-
}
|
|
11
|
-
export declare class UnexpectedAccess extends Error {
|
|
12
|
-
constructor(property: Property, expectations: Expectation[]);
|
|
13
|
-
}
|
|
14
|
-
export declare class UnexpectedCall extends Error {
|
|
15
|
-
constructor(property: Property, args: any[], expectations: Expectation[]);
|
|
16
|
-
}
|
|
17
|
-
export declare class NotAMock extends Error {
|
|
18
|
-
constructor();
|
|
19
|
-
}
|
|
20
|
-
export declare class UnmetExpectations extends Error {
|
|
21
|
-
constructor(expectations: Expectation[]);
|
|
22
|
-
}
|
|
23
|
-
export declare class UnexpectedCalls extends Error {
|
|
24
|
-
constructor(unexpectedCalls: CallMap, expectations: Expectation[]);
|
|
25
|
-
}
|
|
26
|
-
export declare class NestedWhen extends Error {
|
|
27
|
-
constructor(parentProp: Property, childProp: Property);
|
|
28
|
-
}
|
package/dist/expectation/it.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Matcher, TypeMatcher } from './matcher';
|
|
2
|
-
declare type DeepPartial<T> = T extends object ? {
|
|
3
|
-
[K in keyof T]?: DeepPartial<T[K]>;
|
|
4
|
-
} : T;
|
|
5
|
-
/**
|
|
6
|
-
* Contains argument matchers that can be used to ignore arguments in an
|
|
7
|
-
* expectation or to match complex arguments.
|
|
8
|
-
*/
|
|
9
|
-
export declare const It: {
|
|
10
|
-
matches: <T>(cb: (actual: T) => boolean, { toJSON }?: {
|
|
11
|
-
toJSON?: (() => string) | undefined;
|
|
12
|
-
}) => TypeMatcher<T>;
|
|
13
|
-
deepEquals: <T_1>(expected: T_1, { strict }?: {
|
|
14
|
-
strict?: boolean | undefined;
|
|
15
|
-
}) => TypeMatcher<T_1>;
|
|
16
|
-
is: <T_2 = unknown>(expected: T_2) => TypeMatcher<T_2>;
|
|
17
|
-
isAny: () => TypeMatcher<any>;
|
|
18
|
-
isObject: <T_3 extends object, K extends DeepPartial<T_3>>(partial?: K | undefined) => TypeMatcher<T_3>;
|
|
19
|
-
isNumber: () => TypeMatcher<number>;
|
|
20
|
-
isString: ({ matching, containing, }?: {
|
|
21
|
-
matching?: RegExp | undefined;
|
|
22
|
-
containing?: string | undefined;
|
|
23
|
-
}) => TypeMatcher<string>;
|
|
24
|
-
isArray: <T_4 extends any[]>(containing?: T_4 | undefined) => TypeMatcher<T_4>;
|
|
25
|
-
willCapture: <T_5 = unknown>(name?: string) => T_5 & Matcher & {
|
|
26
|
-
value: T_5 | undefined;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export declare const MATCHER_SYMBOL: unique symbol;
|
|
2
|
-
export declare type Matcher = {
|
|
3
|
-
/**
|
|
4
|
-
* Will be called with a value to match against.
|
|
5
|
-
*/
|
|
6
|
-
matches: (arg: any) => boolean;
|
|
7
|
-
[MATCHER_SYMBOL]: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Used by `pretty-format`.
|
|
10
|
-
*/
|
|
11
|
-
toJSON(): string;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* This takes the shape of T to satisfy call sites, but strong-mock will only
|
|
15
|
-
* care about the matcher type.
|
|
16
|
-
*/
|
|
17
|
-
export declare type TypeMatcher<T> = T & Matcher;
|
|
18
|
-
/**
|
|
19
|
-
* Used to test if an expectation on an argument is a custom matcher.
|
|
20
|
-
*/
|
|
21
|
-
export declare function isMatcher(f: unknown): f is Matcher;
|