-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.test.js
58 lines (45 loc) · 1.3 KB
/
index.test.js
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"use strict";
import { Writable as WritableStream } from "stream";
import { test } from "tap";
import { pino } from "pino";
import { getTransformStream } from "../index.js";
test("API", (t) => {
let env = Object.assign({}, process.env);
t.afterEach(() => {
process.env = { ...env };
});
t.test("getTransformStream export", (t) => {
t.type(getTransformStream, Function);
t.end();
});
t.test("getTransformStream without options", (t) => {
getTransformStream();
t.end();
});
t.test(
"A single \\n is added to the end log lines when LOG_FORMAT is set to 'json' (https://github.com/probot/probot/issues/1334)",
(t) => {
const streamLogsToOutput = new WritableStream({ objectMode: true });
const output = [];
streamLogsToOutput._write = (line, encoding, done) => {
output.push(line);
done();
};
const transform = getTransformStream({
logFormat: "json",
logLevelInString: true,
});
transform.pipe(streamLogsToOutput);
const log = pino({}, transform);
log.info("test");
t.equal(
output.join(""),
output.join("").trim() + "\n",
'No "\\n" is added to end of line',
);
t.equal(JSON.parse(output).level, "info");
t.end();
},
);
t.end();
});