ts-mock-imports
Version:
Intuitive mocking for Typescript class imports
23 lines (22 loc) • 913 B
TypeScript
/// <reference types="sinon" />
import { IManager, IModule, StringKeyOf } from '../types';
interface IOriginal {
[key: string]: any;
}
export declare class InPlaceMockManager<T> implements IManager {
protected module: IModule;
protected importName: string;
protected original: IOriginal;
protected classFunctionNames: string[];
constructor(module: IModule, importName: string);
mock(funcName: StringKeyOf<T>, returns?: any): sinon.SinonStub;
getMockInstance(): T;
restore(): void;
protected mockFunction(funcName: string, returns?: any): sinon.SinonStub;
protected replaceFunction(funcName: string, newFunc: () => any): void;
protected replace(name: string, arg: any): void;
protected getAllFunctionNames(obj: any): string[];
protected saveOriginal(functionNames: string[]): IOriginal;
protected mockMethods(functionNames: string[]): void;
}
export {};