MCPcopy
hub / github.com/github/docs / mockResponse

Function mockResponse

tests/unit/static-assets.js:25–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23 }
24}
25const mockResponse = () => {
26 const res = {}
27 res.status = 404
28 res.statusCode = 404
29 res.json = (payload) => {
30 res._json = payload
31 }
32 res.send = (body) => {
33 res.status = 200
34 res.statusCode = 200
35 res._send = body
36 }
37 res.headers = {}
38 res.set = (key, value) => {
39 if (typeof key === 'string') {
40 res.headers[key.toLowerCase()] = value
41 } else {
42 for (const [k, value] of Object.entries(key)) {
43 res.headers[k.toLowerCase()] = value
44 }
45 }
46 }
47 res.removeHeader = (key) => {
48 delete res.headers[key]
49 }
50 res.hasHeader = (key) => {
51 return key in res.headers
52 }
53 return res
54}
55
56describe('archived enterprise static assets', () => {
57 // Sometimes static assets are proxied. The URL for the static asset

Callers 1

static-assets.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected