Skip to content

Commit

Permalink
test(lib/logging): stub console
Browse files Browse the repository at this point in the history
  • Loading branch information
hasundue committed Feb 27, 2024
1 parent ec5cd2b commit 74812dd
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/logging_test.ts
Original file line number Diff line number Diff line change
@@ -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");
});
});

0 comments on commit 74812dd

Please sign in to comment.