@portosaur/logger 0.1.2 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/tests/logger.format.test.mjs +0 -43
package/package.json
CHANGED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { expect, test, describe } from "bun:test";
|
|
2
|
-
import { _formatMsg, TARGET_WIDTH } from "../src/lib/helpers.mjs";
|
|
3
|
-
|
|
4
|
-
const stripAnsi = (s) => (s || "").replace(/\x1b\[[0-9;]*m/g, "");
|
|
5
|
-
|
|
6
|
-
describe("logger formatting", () => {
|
|
7
|
-
test("single-line message aligns", () => {
|
|
8
|
-
const levelLabel = "success";
|
|
9
|
-
const labelText = `[${levelLabel.toUpperCase()}]`;
|
|
10
|
-
const currentLabelLength = labelText.length + 1;
|
|
11
|
-
const paddingCount = TARGET_WIDTH - currentLabelLength;
|
|
12
|
-
const out = _formatMsg("Installation complete", levelLabel);
|
|
13
|
-
const raw = stripAnsi(out);
|
|
14
|
-
expect(raw).toBe(" ".repeat(paddingCount) + "Installation complete");
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test("leading newline preserved", () => {
|
|
18
|
-
const levelLabel = "error";
|
|
19
|
-
const labelText = `[${levelLabel.toUpperCase()}]`;
|
|
20
|
-
const currentLabelLength = labelText.length + 1;
|
|
21
|
-
const paddingCount = TARGET_WIDTH - currentLabelLength;
|
|
22
|
-
const out = _formatMsg("\nSetup aborted.", levelLabel);
|
|
23
|
-
const raw = stripAnsi(out);
|
|
24
|
-
expect(raw).toBe("\n" + " ".repeat(paddingCount) + "Setup aborted.");
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test("multi-line message indents subsequent lines", () => {
|
|
28
|
-
const levelLabel = "info";
|
|
29
|
-
const labelText = `[${levelLabel.toUpperCase()}]`;
|
|
30
|
-
const currentLabelLength = labelText.length + 1;
|
|
31
|
-
const paddingCount = TARGET_WIDTH - currentLabelLength;
|
|
32
|
-
const out = _formatMsg("Line1\nLine2\nLine3", levelLabel);
|
|
33
|
-
const raw = stripAnsi(out);
|
|
34
|
-
const expected =
|
|
35
|
-
" ".repeat(paddingCount) +
|
|
36
|
-
"Line1\n" +
|
|
37
|
-
" ".repeat(TARGET_WIDTH) +
|
|
38
|
-
"Line2\n" +
|
|
39
|
-
" ".repeat(TARGET_WIDTH) +
|
|
40
|
-
"Line3";
|
|
41
|
-
expect(raw).toBe(expected);
|
|
42
|
-
});
|
|
43
|
-
});
|