Skip to content

Commit 8f93112

Browse files
committed
Add unit tests for all the logging methods I just wrote
Signed-off-by: Rahul Krishna <[email protected]>
1 parent e382132 commit 8f93112

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/unit/utils/loggers.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { test, expect } from 'bun:test';
2+
import { logger, createLogger } from '../../../src/utils/logger';
3+
4+
test("Must create a logger instance", () => {
5+
expect(logger).toBeDefined();
6+
});
7+
8+
test("Must log info message without throwing", () => {
9+
expect(() => logger.info("This is an info message")).not.toThrow();
10+
});
11+
12+
test("Must log success message without throwing", () => {
13+
expect(() => logger.success("This is a success message")).not.toThrow();
14+
});
15+
16+
test("Must log warning message without throwing", () => {
17+
expect(() => logger.warn("This is a warning message")).not.toThrow();
18+
});
19+
20+
test("Must log error message without throwing", () => {
21+
expect(() => logger.error("This is an error message")).not.toThrow();
22+
});
23+
24+
test("Must log debug message without throwing", () => {
25+
expect(() => logger.debug("This is a debug message")).not.toThrow();
26+
});
27+
28+
test("Must pretty print JSON without throwing", () => {
29+
expect(() => logger.prettyJson("Test Object", { foo: "bar", baz: 42 })).not.toThrow();
30+
});
31+
32+
test("Must create scoped logger instance", () => {
33+
const scopedLogger = createLogger("TestScope");
34+
expect(scopedLogger).toBeDefined();
35+
});
36+
37+
test("Scoped logger must log info without throwing", () => {
38+
const scopedLogger = createLogger("TestScope");
39+
expect(() => scopedLogger.info("Scoped info message")).not.toThrow();
40+
});

0 commit comments

Comments
 (0)