(fullReplyResult)
| 8 | const { FetchResponse } = require('@mswjs/interceptors') |
| 9 | |
| 10 | function parseFullReplyResult(fullReplyResult) { |
| 11 | debug('full response from callback result: %j', fullReplyResult) |
| 12 | |
| 13 | if (!Array.isArray(fullReplyResult)) { |
| 14 | throw Error('A single function provided to .reply MUST return an array') |
| 15 | } |
| 16 | |
| 17 | if (fullReplyResult.length > 3) { |
| 18 | throw Error( |
| 19 | 'The array returned from the .reply callback contains too many values', |
| 20 | ) |
| 21 | } |
| 22 | |
| 23 | const [status, body = '', headers] = fullReplyResult |
| 24 | |
| 25 | if (!Number.isInteger(status)) { |
| 26 | throw new Error(`Invalid ${typeof status} value for status code`) |
| 27 | } |
| 28 | |
| 29 | const rawHeaders = common.headersInputToRawArray(headers) |
| 30 | debug('response.rawHeaders after reply: %j', rawHeaders) |
| 31 | |
| 32 | return [status, body, rawHeaders] |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Determine which of the default headers should be added to the response. |
no outgoing calls
no test coverage detected
searching dependent graphs…