Commit 21b243b4 authored by Sebastiaan Deckers's avatar Sebastiaan Deckers 馃悜

fix: workaround for Node.js 8 unknown methods

parent cc9a151c
Pipeline #37886046 passed with stages
in 2 minutes and 29 seconds
......@@ -19,15 +19,13 @@ const fixtures = [
{ url: http, method: 'POST', status: HTTP_STATUS_METHOD_NOT_ALLOWED },
{ url: http, method: 'PUT', status: HTTP_STATUS_METHOD_NOT_ALLOWED },
{ url: http, method: 'PATCH', status: HTTP_STATUS_METHOD_NOT_ALLOWED },
{ url: http, method: 'FOOBAR', status: HTTP_STATUS_BAD_REQUEST },
{ url: https, method: 'GET', status: HTTP_STATUS_OK },
{ url: https, method: 'HEAD', status: HTTP_STATUS_OK },
{ url: https, method: 'OPTIONS', status: HTTP_STATUS_OK },
{ url: https, method: 'POST', status: HTTP_STATUS_METHOD_NOT_ALLOWED },
{ url: https, method: 'PUT', status: HTTP_STATUS_METHOD_NOT_ALLOWED },
{ url: https, method: 'PATCH', status: HTTP_STATUS_METHOD_NOT_ALLOWED },
{ url: https, method: 'FOOBAR', status: HTTP_STATUS_BAD_REQUEST }
{ url: https, method: 'PATCH', status: HTTP_STATUS_METHOD_NOT_ALLOWED }
]
let master
......@@ -45,4 +43,14 @@ for (const { method, url, status } of fixtures) {
})
}
test('Reject unknown HTTP methods', async (t) => {
let response
try {
response = await h1(http, { method: 'FOOBAR' })
t.is(response.status, HTTP_STATUS_BAD_REQUEST) // Node.js 10+
} catch ({ code }) {
t.is(code, 'ECONNRESET') // Node.js 8
}
})
test('stop server', async (t) => master.close())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment