MCPcopy Index your code
hub / github.com/github/docs / makeRequestResponse

Function makeRequestResponse

tests/unit/find-page-middleware.js:12–37  ·  view source on GitHub ↗
(url, currentVersion = 'free-pro-team@latest')

Source from the content-addressed store, hash-verified

10const __dirname = path.dirname(fileURLToPath(import.meta.url))
11
12function makeRequestResponse(url, currentVersion = 'free-pro-team@latest') {
13 const req = new http.IncomingMessage(null)
14 req.method = 'GET'
15 req.url = url
16 req.path = url
17 req.cookies = {}
18 req.headers = {}
19
20 // Custom keys on the request
21 req.pagePath = url
22 req.context = {}
23 req.context.currentVersion = currentVersion
24 req.context.pages = {}
25
26 const res = new http.ServerResponse(req)
27 res.status = function (code) {
28 this._status = code
29 return {
30 send: function (message) {
31 this._message = message
32 }.bind(this),
33 }
34 }
35
36 return [req, res]
37}
38
39describe('find page middleware', () => {
40 test('attaches page on req.context', async () => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected