(
funcOrConstOrSelf?:
| ((this: Self, ...args: Args) => Return)
| (new (...args: Args) => Self)
| Self,
property?: keyof Self,
)
| 941 | GetReturnFromProp<Self, Prop> |
| 942 | >; |
| 943 | export function spy< |
| 944 | Self, |
| 945 | Args extends unknown[], |
| 946 | Return, |
| 947 | >( |
| 948 | funcOrConstOrSelf?: |
| 949 | | ((this: Self, ...args: Args) => Return) |
| 950 | | (new (...args: Args) => Self) |
| 951 | | Self, |
| 952 | property?: keyof Self, |
| 953 | ): SpyLike<Self, Args, Return> { |
| 954 | if (!funcOrConstOrSelf) { |
| 955 | return functionSpy<Self, Args, Return>(); |
| 956 | } else if (property !== undefined) { |
| 957 | return methodSpy<Self, Args, Return>(funcOrConstOrSelf as Self, property); |
| 958 | } else if (funcOrConstOrSelf.toString().startsWith("class")) { |
| 959 | return constructorSpy<Self, Args>( |
| 960 | funcOrConstOrSelf as new (...args: Args) => Self, |
| 961 | ); |
| 962 | } else { |
| 963 | return functionSpy<Self, Args, Return>( |
| 964 | funcOrConstOrSelf as (this: Self, ...args: Args) => Return, |
| 965 | ); |
| 966 | } |
| 967 | } |
| 968 | |
| 969 | /** An instance method replacement that records all calls made to it. */ |
| 970 | export interface Stub< |
no test coverage detected