-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogSource.test.ts
More file actions
36 lines (32 loc) · 960 Bytes
/
Copy pathlogSource.test.ts
File metadata and controls
36 lines (32 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { expect, test } from "bun:test";
import { LogSource } from "./logSource";
test("constructor requires a writer", () => {
expect(() => new LogSource("id", undefined as never, () => {})).toThrow();
});
test("constructor requires a debugWriter", () => {
expect(() => new LogSource("id", () => {}, undefined as never)).toThrow();
});
test("write delegates to the writer with the logID", () => {
const calls: Array<[string, string]> = [];
const source = new LogSource(
"myID",
(title, message) => {
calls.push([title, message]);
},
() => {},
);
source.write("hello");
expect(calls).toEqual([["myID", "hello"]]);
});
test("writeDebug delegates to the debugWriter with the logID", () => {
const calls: Array<[string, string]> = [];
const source = new LogSource(
"myID",
() => {},
(title, message) => {
calls.push([title, message]);
},
);
source.writeDebug("debugging");
expect(calls).toEqual([["myID", "debugging"]]);
});