{"version":3,"file":"injectWrapperMethod.js","sourceRoot":"../src/","sources":["test/injectWrapperMethod.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAA6B,EAAE,UAAkB,EAAE,EAAc;IACnG,8DAA8D;IAC9D,IAAM,cAAc,GAAI,OAAO,CAAC,QAAQ,EAAU,CAAC,UAAU,CAAC,CAAC;IAE/D,IAAI,OAAO,cAAc,KAAK,UAAU,EAAE;QACxC,MAAM,IAAI,KAAK,CAAC,kCAAgC,UAAU,wDAAqD,CAAC,CAAC;KAClH;IAED,8DAA8D;IAC7D,OAAO,CAAC,QAAQ,EAAU,CAAC,UAAU,CAAC,GAAG,UAAS,SAAc;QAC/D,EAAE,EAAE,CAAC;QACL,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACvC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { ReactWrapper } from 'enzyme';\n/**\n * Injects a function call prior to running a method for a component\n * rendered using enzyme deep rendering.\n * @param wrapper - The enzyme deep rendering wrapper object to modify\n * @param methodName - The name of the method to modify on the wrapper\n * @param fn - The function to run prior to the call of the original method\n */\nexport function injectWrapperMethod(wrapper: ReactWrapper<{}, {}>, methodName: string, fn: () => void): void {\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  const originalMethod = (wrapper.instance() as any)[methodName];\n\n  if (typeof originalMethod !== 'function') {\n    throw new Error(`Tried to override the method ${methodName} on a ReactWrapper that does not have that function`);\n  }\n\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  (wrapper.instance() as any)[methodName] = function(prevProps: any): void {\n    fn();\n    originalMethod.call(this, prevProps);\n  };\n}\n"]}