Skip to content

Commit 3044fce

Browse files
authored
Merge pull request #259 from vktrl/master
fix undefined check, add null test for browser
2 parents c24f7e1 + be1e549 commit 3044fce

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/runtime/browser/util.inspect.polyfil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function isBoolean(arg: unknown) {
6363
}
6464

6565
function isUndefined(arg: unknown) {
66-
return arg == null;
66+
return arg === undefined;
6767
}
6868

6969
function stylizeNoColor(str: string) {

tests/Browser/1_json.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,14 @@ describe("Browser: JSON: Log level", () => {
7575

7676
expect(consoleOutput).toContain("Foo bar");
7777
});
78+
79+
it("pretty nullish", async () => {
80+
await page.evaluate(() => {
81+
// @ts-ignore
82+
const logger = new tslog.Logger({ type: "pretty", stylePrettyLogs: false });
83+
logger.info({ foo: null, bar: undefined });
84+
});
85+
expect(consoleOutput).toContain("null");
86+
expect(consoleOutput).toContain("undefined");
87+
});
7888
});

tests/Nodejs/5_pretty_Log_Types.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ describe("Pretty: Log Types", () => {
4545
expect(getConsoleLog()).toContain("555");
4646
});
4747

48+
test("null", (): void => {
49+
const logger = new Logger({ type: "pretty" });
50+
logger.log(1234, "testLevel", null);
51+
expect(getConsoleLog()).toContain("null");
52+
});
53+
4854
test("Array, stylePrettyLogs: false", (): void => {
4955
const logger = new Logger({ type: "pretty", stylePrettyLogs: false });
5056
logger.log(1234, "testLevel", [1, 2, 3, "test"]);

0 commit comments

Comments
 (0)