rx-player
Version:
Canal+ HTML5 Video Player
30 lines • 1.08 kB
TypeScript
/**
* Util useful to create mocked versions of classes with each of their methods
* and properties replaced, while being properly checked by TypeScript.
* @param {Object} methods - Each of this class' methods (key is the method
* name, value is the implementation).
* @param {Object} properties - Each of this class' property (key is the
* property name, value is the implementation).
* @returns {*} - The mocked class, which should respect its public API.
*/
export declare function makeMockedClass<T>(methods: MethodsMap<T>, properties: PropertiesMap<T>): {
new (opts?: Partial<T>): T;
prototype: IPrototype<T>;
};
type IPrototype<T> = {
[K in keyof T as T[K] extends Function ? K : never]: T[K];
};
type MethodKeys<T> = {
[K in keyof T]: T[K] extends Function ? K : never;
}[keyof T];
type PropertyKeys<T> = {
[K in keyof T]: T[K] extends Function ? never : K;
}[keyof T];
type MethodsMap<T> = {
[K in MethodKeys<T>]: T[K];
};
type PropertiesMap<T> = {
[K in PropertyKeys<T>]: T[K];
};
export {};
//# sourceMappingURL=test-utils.d.ts.map