refactor(logging): split config + subsystem imports

This commit is contained in:
Peter Steinberger
2026-01-18 23:24:17 +00:00
parent ee36e12f81
commit 50fdd514ae
48 changed files with 109 additions and 72 deletions

View File

@@ -4,19 +4,22 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import * as logging from "../logging.js";
const createService = vi.fn();
const shutdown = vi.fn();
const registerUnhandledRejectionHandler = vi.fn();
const logWarn = vi.fn();
const logDebug = vi.fn();
const getLoggerInfo = vi.fn();
const mocks = vi.hoisted(() => ({
createService: vi.fn(),
shutdown: vi.fn(),
registerUnhandledRejectionHandler: vi.fn(),
logWarn: vi.fn(),
logDebug: vi.fn(),
}));
const { createService, shutdown, registerUnhandledRejectionHandler, logWarn, logDebug } = mocks;
const asString = (value: unknown, fallback: string) =>
typeof value === "string" && value.trim() ? value : fallback;
vi.mock("../logger.js", () => {
vi.mock("../logger.js", async () => {
const actual = await vi.importActual<typeof import("../logger.js")>("../logger.js");
return {
...actual,
logWarn: (message: string) => logWarn(message),
logDebug: (message: string) => logDebug(message),
logInfo: vi.fn(),
@@ -73,7 +76,6 @@ describe("gateway bonjour advertiser", () => {
registerUnhandledRejectionHandler.mockReset();
logWarn.mockReset();
logDebug.mockReset();
getLoggerInfo.mockReset();
vi.useRealTimers();
vi.restoreAllMocks();
});