MCPcopy Create free account
hub / github.com/angular/dev-infra / mockDispatch

Function mockDispatch

github-actions/bazel/configure-remote/configure-remote.js:11074–11117  ·  view source on GitHub ↗
(opts, handler)

Source from the content-addressed store, hash-verified

11072 const replyData = typeof data === "function" ? { callback: data } : __spreadValues({}, data);
11073 const newMockDispatch = __spreadProps(__spreadValues(__spreadValues({}, baseData), key), { pending: true, data: __spreadValues({ error: null }, replyData) });
11074 mockDispatches.push(newMockDispatch);
11075 return newMockDispatch;
11076 }
11077 function deleteMockDispatch(mockDispatches, key) {
11078 const index = mockDispatches.findIndex((dispatch) => {
11079 if (!dispatch.consumed) {
11080 return false;
11081 }
11082 return matchKey(dispatch, key);
11083 });
11084 if (index !== -1) {
11085 mockDispatches.splice(index, 1);
11086 }
11087 }
11088 function buildKey(opts) {
11089 const { path: path5, method, body, headers, query } = opts;
11090 return {
11091 path: path5,
11092 method,
11093 body,
11094 headers,
11095 query
11096 };
11097 }
11098 function generateKeyValues(data) {
11099 const keys = Object.keys(data);
11100 const result = [];
11101 for (let i = 0; i < keys.length; ++i) {
11102 const key = keys[i];
11103 const value = data[key];
11104 const name = Buffer.from(`${key}`);
11105 if (Array.isArray(value)) {
11106 for (let j = 0; j < value.length; ++j) {
11107 result.push(name, Buffer.from(`${value[j]}`));
11108 }
11109 } else {
11110 result.push(name, Buffer.from(`${value}`));
11111 }
11112 }
11113 return result;
11114 }
11115 function getStatusText(statusCode) {
11116 return STATUS_CODES[statusCode] || "unknown";
11117 }
11118 function getResponse(body) {
11119 return __async(this, null, function* () {
11120 const buffers = [];

Callers

nothing calls this directly

Calls 8

buildKeyFunction · 0.70
getMockDispatchFunction · 0.70
__spreadValuesFunction · 0.70
deleteMockDispatchFunction · 0.70
setTimeoutFunction · 0.70
handleReplyFunction · 0.70
callbackMethod · 0.45
onErrorMethod · 0.45

Tested by

no test coverage detected