MCPcopy Create free account
hub / github.com/nodejs/node / addMockDispatch

Function addMockDispatch

deps/undici/src/lib/mock/mock-utils.js:205–213  ·  view source on GitHub ↗
(mockDispatches, key, data, opts)

Source from the content-addressed store, hash-verified

203}
204
205function addMockDispatch (mockDispatches, key, data, opts) {
206 const baseData = { timesInvoked: 0, times: 1, persist: false, consumed: false, ...opts }
207 const replyData = typeof data === 'function' ? { callback: data } : { ...data }
208 const newMockDispatch = { ...baseData, ...key, pending: true, data: { error: null, ...replyData } }
209 mockDispatches.push(newMockDispatch)
210 // Track total number of intercepts ever registered for better error messages
211 mockDispatches[kTotalDispatchCount] = (mockDispatches[kTotalDispatchCount] || 0) + 1
212 return newMockDispatch
213}
214
215function deleteMockDispatch (mockDispatches, key) {
216 const index = mockDispatches.findIndex(dispatch => {

Callers 2

replyMethod · 0.85
replyWithErrorMethod · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected