Allow logging functions to accept string[] directly

This commit is contained in:
Michael B. Gale
2026-10-06 13:36:35 +01:00
parent 2b07ff4ed2
commit 4a2ca5c068
4 changed files with 75 additions and 19 deletions

17
src/logging.test.ts Normal file
View File

@@ -0,0 +1,17 @@
import test from "ava";
import { joinMessageStrings } from "./logging";
import { setupTests } from "./testing-utils";
setupTests(test);
test("joinMessageStrings", async (t) => {
// For strings and errors, it is the identity function.
t.deepEqual(joinMessageStrings("Hello"), "Hello");
const error = new Error("Some error");
t.deepEqual(joinMessageStrings(error), error);
// For arrays of strings, we get a join-ed string.
t.deepEqual(joinMessageStrings(["foo", "bar"]), "foo bar");
});