diff options
author | EuAndreh <eu@euandre.org> | 2024-03-14 12:55:30 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-03-14 12:55:30 -0300 |
commit | 06d1483ed03883745ea76b4481a10dee16800d50 (patch) | |
tree | 2b3b5d49472180ca04bf369f8d42b65fed35ef08 /tests/js | |
parent | Makefile: Add "run-binder" to expose lighttpd's unix socket to a TCP port (diff) | |
download | papod-06d1483ed03883745ea76b4481a10dee16800d50.tar.gz papod-06d1483ed03883745ea76b4481a10dee16800d50.tar.xz |
src/hero.mjs: Include "headers" and "ref" in request param
Diffstat (limited to 'tests/js')
-rw-r--r-- | tests/js/hero.mjs | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/tests/js/hero.mjs b/tests/js/hero.mjs index ee35489..4330cb2 100644 --- a/tests/js/hero.mjs +++ b/tests/js/hero.mjs @@ -1016,9 +1016,17 @@ const test_handleRequest = async t => { }, }, }; + const req = { + method: "GET", + url: "/?q=1", + headers: { + a: "1", + b: "two", + }, + }; assert.deepEqual( - await handleRequest(table, "GET", "/?q=1"), + await handleRequest(table, req), { params: { path: {}, @@ -1028,6 +1036,11 @@ const test_handleRequest = async t => { }, method: "GET", path: "/", + headers: { + a: "1", + b: "two", + }, + ref: req, handler: fn, }, ); @@ -1048,9 +1061,17 @@ const test_handleRequest = async t => { }, interceptors: [], }; + const req = { + method: "PUT", + url: "/api/user/2222", + headers: { + h1: "H1", + h2: "h2", + }, + }; assert.deepEqual( - await handleRequest(table, "PUT", "/api/user/2222"), + await handleRequest(table, req), { params: { path: { @@ -1060,14 +1081,22 @@ const test_handleRequest = async t => { }, method: "PUT", path: "/api/user/2222", + headers: { + h1: "H1", + h2: "h2", + }, handler: fn, + ref: req, }, ); }); await t.test("missing route", async () => { assert.deepEqual( - await handleRequest({ interceptors: [] }, "GET", "/"), + await handleRequest({ interceptors: [] }, { + method: "GET", + url: "/", + }), { status: 404, body: "Not Found\n", @@ -1572,7 +1601,10 @@ const test_buildRoutes = async t => { { const { handled, intercepted } = - await handleRequest(table, "GET", "/without"); + await handleRequest(table, { + method: "GET", + url: "/without", + }); assert.deepEqual( { handled, intercepted }, { handled: true, intercepted: undefined }, @@ -1580,7 +1612,10 @@ const test_buildRoutes = async t => { }; { const { handled, intercepted } = - await handleRequest(table, "GET", "/with"); + await handleRequest(table, { + method: "GET", + url: "/with", + }); assert.deepEqual( { handled, intercepted }, { handled: true, intercepted: true }, @@ -1602,7 +1637,10 @@ const test_buildRoutes = async t => { { const { handled, interceptor1, interceptor2 } = - await handleRequest(table, "GET", "/global-only"); + await handleRequest(table, { + method: "GET", + url: "/global-only", + }); assert.deepEqual( { handled, interceptor1, interceptor2 }, { handled: true, interceptor1: true, interceptor2: undefined }, @@ -1610,7 +1648,10 @@ const test_buildRoutes = async t => { }; { const { handled, interceptor1, interceptor2 } = - await handleRequest(table, "GET", "/global-and-local"); + await handleRequest(table, { + method: "GET", + url: "/global-and-local", + }); assert.deepEqual( { handled, interceptor1, interceptor2 }, { handled: true, interceptor1: true, interceptor2: true }, |