diff options
author | EuAndreh <eu@euandre.org> | 2024-02-25 05:01:00 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-02-25 05:01:00 -0300 |
commit | 458bf0fc628d9bcf6a59a0efb898045266dab6ba (patch) | |
tree | bb538753668dad5abc7eec4a65bf4f233b34d93a /tests/js/hero.mjs | |
parent | Normalize how modules import and name each other (diff) | |
download | papod-458bf0fc628d9bcf6a59a0efb898045266dab6ba.tar.gz papod-458bf0fc628d9bcf6a59a0efb898045266dab6ba.tar.xz |
Explicit import from "node:process"; move log() to hero.mjs
Diffstat (limited to 'tests/js/hero.mjs')
-rw-r--r-- | tests/js/hero.mjs | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/tests/js/hero.mjs b/tests/js/hero.mjs index bc9d3d2..5507375 100644 --- a/tests/js/hero.mjs +++ b/tests/js/hero.mjs @@ -15,6 +15,7 @@ import { extractQueryParams, handleRequest, makeRequestListener, + log, interceptorsFn, interceptors, defaultInterceptors, @@ -562,7 +563,7 @@ const test_handleRequest = t => { await handleRequest({}, "GET", "/"), { status: 404, - body: "Not Found", + body: "Not Found\n", }, ); }); @@ -631,6 +632,20 @@ const test_makeRequestListener = t => { }); }; +const test_log = t => { + t.start("log()"); + + t.test("we can log data", () => { + log({ a: 1, type: "log-test" }); + }); + + t.test("we can't log unserializable things", () => { + const obj = { self: null }; + obj.self = obj; + assert.throws(() => log(obj), TypeError); + }); +}; + const test_interceptorsFn = t => { const next = x => x; @@ -800,7 +815,7 @@ const test_interceptorsFn = t => { await interceptorsFn({ logger }).serverError({ id: 123 }, next), { status: 500, - body: "Internal Server Error", + body: "Internal Server Error\n", }, ); assert.deepEqual( @@ -823,7 +838,7 @@ const test_interceptorsFn = t => { ), { status: 500, - body: "Internal Server Error", + body: "Internal Server Error\n", }, ); assert.deepEqual( @@ -1158,7 +1173,7 @@ const test_buildServer = t => { const response = await socketRequest(socketPath, "/anything"); await server.close(); - assert.deepEqual(response, { status: 404, body: "Not Found" }); + assert.deepEqual(response, { status: 404, body: "Not Found\n" }); }); t.test("integrated application server", async () => { @@ -1188,6 +1203,7 @@ await runner.runTests([ test_extractQueryParams, test_handleRequest, test_makeRequestListener, + test_log, test_interceptorsFn, test_chainInterceptors, test_wrapHandler, |