{"version":3,"sources":["../../src/matchers/toMatchException.ts"],"sourcesContent":["import { Exception } from '../utils/Types';\nimport { match } from './Match';\nimport { isDefined } from '../utils/Utils';\n\nexport const toMatchException = (received: Exception, expected: unknown, reason?: string): jest.CustomMatcherResult =>\n  match<Exception>(expected as Exception)\n    .undefined(e => e.id, 'Expected value is not an exception.')\n    .not(\n      e => e.id === received.id,\n      e => `Expected exception has id '${e.id}', while the received exception has id '${received.id}'.`\n    )\n    .not(\n      () => !isDefined(reason) || (isDefined(reason) && isDefined(received.reason)),\n      () => `We expected to have reason '${reason}', but we received no reason.`\n    )\n    .not(\n      () => !isDefined(reason) || (isDefined(reason) && received.reason === reason),\n      () => `We expected to have reason '${reason}', but we received reason '${received.reason}'.`\n    )\n    .else(`Expected exception matches received exception`);\n\nexpect.extend({\n  toMatchException,\n});\n\ndeclare global {\n  // eslint-disable-next-line @typescript-eslint/no-namespace\n  namespace jest {\n    interface Matchers<R, T> {\n      toMatchException(exception: unknown, reason?: string): R;\n    }\n  }\n}\n"],"mappings":";;;;;;;;;AAIO,IAAM,mBAAmB,CAAC,UAAqB,UAAmB,WACvE,MAAiB,QAAqB,EACnC,UAAU,OAAK,EAAE,IAAI,qCAAqC,EAC1D;AAAA,EACC,OAAK,EAAE,OAAO,SAAS;AAAA,EACvB,OAAK,8BAA8B,EAAE,EAAE,2CAA2C,SAAS,EAAE;AAC/F,EACC;AAAA,EACC,MAAM,CAAC,UAAU,MAAM,KAAM,UAAU,MAAM,KAAK,UAAU,SAAS,MAAM;AAAA,EAC3E,MAAM,+BAA+B,MAAM;AAC7C,EACC;AAAA,EACC,MAAM,CAAC,UAAU,MAAM,KAAM,UAAU,MAAM,KAAK,SAAS,WAAW;AAAA,EACtE,MAAM,+BAA+B,MAAM,8BAA8B,SAAS,MAAM;AAC1F,EACC,KAAK,+CAA+C;AAEzD,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}