(mockDispatches, key)
| 57240 | if (Buffer.isBuffer(data)) { |
| 57241 | return data; |
| 57242 | } else if (typeof data === "object") { |
| 57243 | return JSON.stringify(data); |
| 57244 | } else { |
| 57245 | return data.toString(); |
| 57246 | } |
| 57247 | } |
| 57248 | function getMockDispatch(mockDispatches, key) { |
| 57249 | const basePath = key.query ? buildURL2(key.path, key.query) : key.path; |
| 57250 | const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath; |
| 57251 | let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path5 }) => matchValue(safeUrl(path5), resolvedPath)); |
| 57252 | if (matchedMockDispatches.length === 0) { |
| 57253 | throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`); |
| 57254 | } |
| 57255 | matchedMockDispatches = matchedMockDispatches.filter(({ method }) => matchValue(method, key.method)); |
| 57256 | if (matchedMockDispatches.length === 0) { |
| 57257 | throw new MockNotMatchedError(`Mock dispatch not matched for method '${key.method}'`); |
| 57258 | } |
| 57259 | matchedMockDispatches = matchedMockDispatches.filter(({ body }) => typeof body !== "undefined" ? matchValue(body, key.body) : true); |
| 57260 | if (matchedMockDispatches.length === 0) { |
| 57261 | throw new MockNotMatchedError(`Mock dispatch not matched for body '${key.body}'`); |
| 57262 | } |
| 57263 | matchedMockDispatches = matchedMockDispatches.filter((mockDispatch2) => matchHeaders(mockDispatch2, key.headers)); |
| 57264 | if (matchedMockDispatches.length === 0) { |
| 57265 | throw new MockNotMatchedError(`Mock dispatch not matched for headers '${typeof key.headers === "object" ? JSON.stringify(key.headers) : key.headers}'`); |
no test coverage detected
searching dependent graphs…