* Mock an undici request with a defined reply.
(replyData)
| 57507 | } |
| 57508 | if (typeof responseOptions !== "object") { |
| 57509 | throw new InvalidArgumentError("responseOptions must be an object"); |
| 57510 | } |
| 57511 | } |
| 57512 | /** |
| 57513 | * Mock an undici request with a defined reply. |
| 57514 | */ |
| 57515 | reply(replyData) { |
| 57516 | if (typeof replyData === "function") { |
| 57517 | const wrappedDefaultsCallback = (opts) => { |
| 57518 | const resolvedData = replyData(opts); |
| 57519 | if (typeof resolvedData !== "object") { |
| 57520 | throw new InvalidArgumentError("reply options callback must return an object"); |
| 57521 | } |
| 57522 | const { statusCode: statusCode2, data: data2 = "", responseOptions: responseOptions2 = {} } = resolvedData; |
| 57523 | this.validateReplyParameters(statusCode2, data2, responseOptions2); |
| 57524 | return { |
| 57525 | ...this.createMockScopeDispatchData(statusCode2, data2, responseOptions2) |
| 57526 | }; |
| 57527 | }; |
| 57528 | const newMockDispatch2 = addMockDispatch(this[kDispatches], this[kDispatchKey], wrappedDefaultsCallback); |
| 57529 | return new MockScope(newMockDispatch2); |
| 57530 | } |
| 57531 | const [statusCode, data = "", responseOptions = {}] = [...arguments]; |
| 57532 | this.validateReplyParameters(statusCode, data, responseOptions); |
| 57533 | const dispatchData = this.createMockScopeDispatchData(statusCode, data, responseOptions); |
nothing calls this directly
no test coverage detected