diff --git a/lib/logging_test.ts b/lib/logging_test.ts index d028d09..90724cd 100644 --- a/lib/logging_test.ts +++ b/lib/logging_test.ts @@ -1,15 +1,29 @@ -import { describe, it } from "../lib/std/testing.ts"; +import { beforeEach, describe, it } from "../lib/std/testing.ts"; +import { assertEquals } from "../lib/std/assert.ts"; import { ConsoleLogger } from "./logging.ts"; import { assert } from "../lib/std/assert.ts"; describe("ConsoleLogger", () => { + let output = ""; + + beforeEach(() => { + globalThis.console = new Proxy(globalThis.console, { + get: () => { + return (data: unknown) => { + output += data; + }; + }, + }); + }); + it("should be a writable stream", () => { const logger = new ConsoleLogger(); assert(logger instanceof WritableStream); }); + it("should log to console", async () => { - // TODO: Stub console.log const logger = new ConsoleLogger(); await logger.getWriter().write("ConsoleLogger"); + assertEquals(output, "ConsoleLogger"); }); });