-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple-logging.ts
More file actions
36 lines (32 loc) · 1.02 KB
/
simple-logging.ts
File metadata and controls
36 lines (32 loc) · 1.02 KB
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 { consume } from "../../src/consumers";
import { simpleLogger } from "../../src/loggers";
import { fromIterable } from "../../src/producers";
import { peek } from "../../src/transformers";
describe("simple logger", () => {
const consoleLogSpy = jest.spyOn(console, "log");
beforeEach(() => {
jest.resetAllMocks();
});
test("logs strings", async () => {
await consume(peek(simpleLogger)(fromIterable(["hello", "world"])));
expect(consoleLogSpy).toHaveBeenCalledWith(
expect.stringContaining("hello")
);
expect(consoleLogSpy).toHaveBeenCalledWith(
expect.stringContaining("world")
);
});
test("logs objects", async () => {
await consume(
peek(simpleLogger)(
fromIterable([{ hello: "world" }, { iAm: "a working logger" }])
)
);
expect(consoleLogSpy).toHaveBeenCalledWith(
expect.stringContaining('"hello": "world"')
);
expect(consoleLogSpy).toHaveBeenCalledWith(
expect.stringContaining('"iAm": "a working logger"')
);
});
});