Skip to content

Commit 74812dd

Browse files
committed
test(lib/logging): stub console
1 parent ec5cd2b commit 74812dd

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lib/logging_test.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
1-
import { describe, it } from "../lib/std/testing.ts";
1+
import { beforeEach, describe, it } from "../lib/std/testing.ts";
2+
import { assertEquals } from "../lib/std/assert.ts";
23
import { ConsoleLogger } from "./logging.ts";
34
import { assert } from "../lib/std/assert.ts";
45

56
describe("ConsoleLogger", () => {
7+
let output = "";
8+
9+
beforeEach(() => {
10+
globalThis.console = new Proxy(globalThis.console, {
11+
get: () => {
12+
return (data: unknown) => {
13+
output += data;
14+
};
15+
},
16+
});
17+
});
18+
619
it("should be a writable stream", () => {
720
const logger = new ConsoleLogger();
821
assert(logger instanceof WritableStream);
922
});
23+
1024
it("should log to console", async () => {
11-
// TODO: Stub console.log
1225
const logger = new ConsoleLogger();
1326
await logger.getWriter().write("ConsoleLogger");
27+
assertEquals(output, "ConsoleLogger");
1428
});
1529
});

0 commit comments

Comments
 (0)