ts-jest 24.0.1 → 24.0.2
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/.ts-jest-digest +1 -1
- package/CHANGELOG.md +5 -0
- package/dist/util/testing.d.ts +16 -17
- package/package.json +1 -1
package/.ts-jest-digest
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
0aceab77a1f613fedb22a0395a65327e834ef35c
|
package/CHANGELOG.md
CHANGED
package/dist/util/testing.d.ts
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
/// <reference types="jest" />
|
|
2
|
-
|
|
3
|
-
new (...args: ArgumentsOf<T>): T;
|
|
4
|
-
(...args: ArgumentsOf<T>): any;
|
|
5
|
-
}
|
|
2
|
+
declare type MockableFunction = (...args: any[]) => any;
|
|
6
3
|
declare type MethodKeysOf<T> = {
|
|
7
|
-
[K in keyof T]: T[K] extends
|
|
4
|
+
[K in keyof T]: T[K] extends MockableFunction ? K : never;
|
|
8
5
|
}[keyof T];
|
|
9
6
|
declare type PropertyKeysOf<T> = {
|
|
10
|
-
[K in keyof T]: T[K] extends
|
|
7
|
+
[K in keyof T]: T[K] extends MockableFunction ? never : K;
|
|
11
8
|
}[keyof T];
|
|
12
9
|
declare type ArgumentsOf<T> = T extends (...args: infer A) => any ? A : never;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
(...args:
|
|
10
|
+
declare type ConstructorArgumentsOf<T> = T extends new (...args: infer A) => any ? A : never;
|
|
11
|
+
interface MockWithArgs<T extends MockableFunction> extends jest.MockInstance<ReturnType<T>, ArgumentsOf<T>> {
|
|
12
|
+
new (...args: ConstructorArgumentsOf<T>): T;
|
|
13
|
+
(...args: ArgumentsOf<T>): ReturnType<T>;
|
|
16
14
|
}
|
|
17
|
-
declare type
|
|
15
|
+
declare type MaybeMockedConstructor<T> = T extends new (...args: any[]) => infer R ? jest.MockInstance<R, ConstructorArgumentsOf<T>> : {};
|
|
16
|
+
declare type MockedFunction<T extends MockableFunction> = MockWithArgs<T> & {
|
|
18
17
|
[K in keyof T]: T[K];
|
|
19
18
|
};
|
|
20
|
-
declare type MockedFunctionDeep<T> = MockWithArgs<T> & MockedObjectDeep<T>;
|
|
21
|
-
declare type MockedObject<T> = {
|
|
22
|
-
[K in MethodKeysOf<T>]: MockedFunction<T[K]
|
|
19
|
+
declare type MockedFunctionDeep<T extends MockableFunction> = MockWithArgs<T> & MockedObjectDeep<T>;
|
|
20
|
+
declare type MockedObject<T> = MaybeMockedConstructor<T> & {
|
|
21
|
+
[K in MethodKeysOf<T>]: T[K] extends MockableFunction ? MockedFunction<T[K]> : T[K];
|
|
23
22
|
} & {
|
|
24
23
|
[K in PropertyKeysOf<T>]: T[K];
|
|
25
24
|
};
|
|
26
|
-
declare type MockedObjectDeep<T> = {
|
|
27
|
-
[K in MethodKeysOf<T>]: MockedFunctionDeep<T[K]
|
|
25
|
+
declare type MockedObjectDeep<T> = MaybeMockedConstructor<T> & {
|
|
26
|
+
[K in MethodKeysOf<T>]: T[K] extends MockableFunction ? MockedFunctionDeep<T[K]> : T[K];
|
|
28
27
|
} & {
|
|
29
28
|
[K in PropertyKeysOf<T>]: MaybeMockedDeep<T[K]>;
|
|
30
29
|
};
|
|
31
|
-
export declare type MaybeMockedDeep<T> = T extends
|
|
32
|
-
export declare type MaybeMocked<T> = T extends
|
|
30
|
+
export declare type MaybeMockedDeep<T> = T extends MockableFunction ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
|
|
31
|
+
export declare type MaybeMocked<T> = T extends MockableFunction ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
|
|
33
32
|
export declare function mocked<T>(item: T, deep?: false): MaybeMocked<T>;
|
|
34
33
|
export declare function mocked<T>(item: T, deep: true): MaybeMockedDeep<T>;
|
|
35
34
|
export {};
|