import { isObjectLike } from "lodash"; export function mockModelFunction(Model: new () => any) { const ProxyModel = new Proxy(Model, { construct(target: any, args) { const instance = new target(...args); const proxy = new Proxy(instance, { get(obj, prop) { if(typeof prop === 'string') { if(typeof obj[prop] === 'function') { const newProp = `$${prop}`; if(!obj[newProp]) { obj[newProp] = jest.fn((...args) => { return obj[prop](...args); }); } return obj[newProp]; } } return obj[prop]; } }); return proxy; } }); return ProxyModel; }