UNPKG

916 BTypeScriptView Raw
1import * as sinon from "sinon";
2export declare type StubbedInstance<T> = sinon.SinonStubbedInstance<T> & T;
3export declare type AllowedKeys<T, Condition> = {
4 [Key in keyof T]: T[Key] extends Condition ? Key : never;
5}[keyof T];
6export declare type ObjectMethodsKeys<T> = AllowedKeys<T, (...args: any[]) => any>[];
7export declare type ObjectMethodsMap<T> = {
8 [Key in keyof T]?: T[Key] extends (...args: any[]) => any ? ReturnType<T[Key]> : never;
9};
10export declare function stubObject<T extends object>(object: T, methods?: ObjectMethodsKeys<T> | ObjectMethodsMap<T>): StubbedInstance<T>;
11export declare function stubConstructor<T extends new (...args: any[]) => any>(constructor: T, ...constructorArgs: ConstructorParameters<T> | undefined[]): StubbedInstance<InstanceType<T>>;
12export declare function stubInterface<T extends object>(methods?: ObjectMethodsMap<T>): StubbedInstance<T>;
13export default sinon;