{"version":3,"file":"async.cjs","sources":["../../../src/matchers/async.js"],"sourcesContent":["import { getMatcherResult } from './utils.js';\n\n/**\n * For async matchers, we need to handle failures differently\n * Return a result object that indicates failure without throwing\n * @param {*} received \n * @returns \n */\nexport async function toResolve(received) {\n  try {\n    await received;\n    return getMatcherResult(true, 'toResolve', received);\n  } catch (error) {\n    return {\n      success: false,\n      error: new Error(`Expected promise to resolve, but it rejected with: ${error.message}`),\n      matcherName: 'toResolve',\n      received: received\n    };\n  }\n}\n\n/**\n * For async matchers, we need to handle failures differently\n * Return a result object that indicates failure without throwing\n * @param {*} received \n * @returns \n */\nexport async function toReject(received) {\n  try {\n    await received;\n    return {\n      success: false,\n      error: new Error('Expected promise to reject, but it resolved'),\n      matcherName: 'toReject',\n      received: received\n    };\n  } catch (error) {\n    return getMatcherResult(true, 'toReject', received);\n  }\n} \n\n/**\n * Create a rejects object that can be chained with other matchers\n * @param {*} received \n * @returns \n */\nexport function rejects(received) {\n  return {\n    toThrow: async (expected) => {\n      try {\n        await received;\n        return getMatcherResult(false, 'rejects.toThrow', received, expected);\n      } catch (error) {\n        if (!expected) {\n          return getMatcherResult(true, 'rejects.toThrow', received, expected);\n        }  \n        if (typeof expected === 'string') {\n          return getMatcherResult(error && error.message && error.message.includes(expected), 'rejects.toThrow', received, expected);\n        }\n        if (expected instanceof RegExp) {\n          return getMatcherResult(expected.test(error && error.message), 'rejects.toThrow', received, expected);\n        }\n        if (typeof expected === 'function') {\n          return getMatcherResult(error instanceof expected, 'rejects.toThrow', received, expected);\n        }\n        return getMatcherResult(false, 'rejects.toThrow', received, expected);\n      }\n    }\n  };\n}\n"],"names":["getMatcherResult"],"mappings":";;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,SAAS,CAAC,QAAQ,EAAE;AAC1C,EAAE,IAAI;AACN,IAAI,MAAM,QAAQ;AAClB,IAAI,OAAOA,sBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC;AACxD,EAAE,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