(url, currentVersion = 'free-pro-team@latest')
| 10 | const __dirname = path.dirname(fileURLToPath(import.meta.url)) |
| 11 | |
| 12 | function 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 | |
| 39 | describe('find page middleware', () => { |
| 40 | test('attaches page on req.context', async () => { |
no outgoing calls
no test coverage detected