Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
izatop committed Mar 30, 2020
1 parent c269a9e commit 4eceb1c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
19 changes: 16 additions & 3 deletions packages/test/src/util/logger/LogFormat.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {debugLogFormat, defaultLogFormat, SeverityLevel} from "@typesafeunit/util";
import {debugLogFormat, defaultLogFormat, readableJSONLogFormat, SeverityLevel} from "@typesafeunit/util";

describe("Log format", () => {
test("test default log formatter", () => {
Expand All @@ -10,7 +10,20 @@ describe("Log format", () => {
groupId: "groupId",
host: "srv1",
timestamp: 1585574245816,
severity: SeverityLevel.DEBUG,
severity: SeverityLevel.EMERGENCY,
})).toMatchSnapshot();
});

test("test readable JSON log formatter", () => {
expect(readableJSONLogFormat({
pid: 5761,
label: "Test",
message: "Log message",
args: [1, {foo: "123"}],
groupId: "groupId",
host: "srv1",
timestamp: 1585574245816,
severity: SeverityLevel.NOTICE,
})).toMatchSnapshot();
});

Expand All @@ -23,7 +36,7 @@ describe("Log format", () => {
groupId: "G-7782",
host: "srv2",
timestamp: 1585574245816,
severity: SeverityLevel.DEBUG,
severity: SeverityLevel.INFO,
})).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Log format test debug log formatter 1`] = `
"2020-03-30T13:17:25.816Z DEBUG srv=srv2 pid=6611 group=G-7782
"2020-03-30T13:17:25.816Z INFO srv=srv2 pid=6611 group=G-7782
Test: Log message
[
1,
Expand All @@ -11,7 +11,9 @@ Test: Log message
]"
`;

exports[`Log format test default log formatter 1`] = `
exports[`Log format test default log formatter 1`] = `"{\\"pid\\":5761,\\"label\\":\\"Test\\",\\"message\\":\\"Log message\\",\\"args\\":[1,{\\"foo\\":\\"123\\"}],\\"groupId\\":\\"groupId\\",\\"host\\":\\"srv1\\",\\"timestamp\\":1585574245816,\\"severity\\":0}"`;

exports[`Log format test readable JSON log formatter 1`] = `
"{
\\"pid\\": 5761,
\\"label\\": \\"Test\\",
Expand All @@ -25,6 +27,6 @@ exports[`Log format test default log formatter 1`] = `
\\"groupId\\": \\"groupId\\",
\\"host\\": \\"srv1\\",
\\"timestamp\\": 1585574245816,
\\"severity\\": 7
\\"severity\\": 5
}"
`;

0 comments on commit 4eceb1c

Please sign in to comment.