MCPcopy
hub / github.com/processing/p5.js / respondWithMock

Function respondWithMock

test/mockServiceWorker.js:290–307  ·  view source on GitHub ↗
(response)

Source from the content-addressed store, hash-verified

288}
289
290async function respondWithMock(response) {
291 // Setting response status code to 0 is a no-op.
292 // However, when responding with a "Response.error()", the produced Response
293 // instance will have status code set to 0. Since it's not possible to create
294 // a Response instance with status code 0, handle that use-case separately.
295 if (response.status === 0) {
296 return Response.error()
297 }
298
299 const mockedResponse = new Response(response.body, response)
300
301 Reflect.defineProperty(mockedResponse, IS_MOCKED_RESPONSE, {
302 value: true,
303 enumerable: true,
304 })
305
306 return mockedResponse
307}

Callers 1

getResponseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected