import { afterEach, expect, test, vi } from "vitest" import { ConsoleDebugLogEmitter, ConsoleErrorLogEmitter, ConsoleInfoLogEmitter, ConsoleLogLogEmitter, ConsoleWarnLogEmitter, } from "#Source/log/index.ts" afterEach(() => { vi.restoreAllMocks() }) test("console log emitters format tags and messages before output", () => { const logSpy = vi.spyOn(console, "log").mockImplementation(() => undefined) const infoSpy = vi.spyOn(console, "info").mockImplementation(() => undefined) const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => undefined) const errorSpy = vi.spyOn(console, "error").mockImplementation(() => undefined) const debugSpy = vi.spyOn(console, "debug").mockImplementation(() => undefined) new ConsoleLogLogEmitter({ tags: ["scope", "unit"], messages: ["hello", 1] }).emit() new ConsoleInfoLogEmitter({ tags: ["scope"], messages: ["info"] }).emit() new ConsoleWarnLogEmitter({ tags: ["scope"], messages: ["warn"] }).emit() new ConsoleErrorLogEmitter({ tags: ["scope"], messages: ["error"] }).emit() new ConsoleDebugLogEmitter({ tags: ["scope"], messages: ["debug"] }).emit() expect(logSpy).toHaveBeenCalledWith("[scope][unit] hello 1") expect(infoSpy).toHaveBeenCalledWith("[scope] info") expect(warnSpy).toHaveBeenCalledWith("[scope] warn") expect(errorSpy).toHaveBeenCalledWith("[scope] error") expect(debugSpy).toHaveBeenCalledWith("[scope] debug") })