1 |
|
2 | declare type JMPFunctionPropertyNames<T> = {
|
3 | [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
|
4 | }[keyof T] & string;
|
5 | declare type JMPArgsType<T> = T extends (...args: infer A) => any ? A : never;
|
6 | declare type JMPReturnType<T> = T extends (...args: any[]) => infer A ? A : never;
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | export declare function spyOnImplementing<T extends {}, M extends JMPFunctionPropertyNames<T>, F extends T[M], I extends (...args: any[]) => JMPReturnType<F>>(target: T, property: M, impl: I): jest.SpyInstance<Required<JMPReturnType<F>>, JMPArgsType<F>>;
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | export declare const mockProcessExit: (err?: any) => jest.SpyInstance<never, [code?: number]>;
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | export declare const mockProcessStdout: () => jest.SpyInstance<Required<boolean>, [str: string, encoding?: string, cb?: Function]>;
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | export declare const mockProcessStderr: () => jest.SpyInstance<Required<boolean>, [str: string, encoding?: string, cb?: Function]>;
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | export declare const mockProcessUptime: (value?: number) => jest.SpyInstance<number, []>;
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | export declare const mockConsoleLog: () => jest.SpyInstance<void, [message?: any, ...optionalParams: any[]]>;
|
43 | declare type JestCallableMocksObject = {
|
44 | [_: string]: () => jest.SpyInstance;
|
45 | };
|
46 | declare type JestMocksObject<T extends JestCallableMocksObject> = {
|
47 | [K in keyof T]: T[K] extends () => infer J ? J : never;
|
48 | };
|
49 | export interface MockedRunResult<R, M> {
|
50 | error?: any;
|
51 | result?: R;
|
52 | mocks: M;
|
53 | }
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | export declare function mockedRun<T extends JestCallableMocksObject, R>(callers: T): (f: () => R) => MockedRunResult<R, JestMocksObject<T>>;
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | export declare function asyncMockedRun<T extends JestCallableMocksObject, R>(callers: T): (f: () => Promise<R>) => Promise<MockedRunResult<R, JestMocksObject<T>>>;
|
66 | export {};
|