Skip to content

Commit

Permalink
Merge pull request #259 from vktrl/master
Browse files Browse the repository at this point in the history
fix undefined check, add null test for browser
  • Loading branch information
terehov committed Aug 23, 2023
2 parents c24f7e1 + be1e549 commit 3044fce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/runtime/browser/util.inspect.polyfil.ts
Expand Up @@ -63,7 +63,7 @@ function isBoolean(arg: unknown) {
}

function isUndefined(arg: unknown) {
return arg == null;
return arg === undefined;
}

function stylizeNoColor(str: string) {
Expand Down
10 changes: 10 additions & 0 deletions tests/Browser/1_json.test.ts
Expand Up @@ -75,4 +75,14 @@ describe("Browser: JSON: Log level", () => {

expect(consoleOutput).toContain("Foo bar");
});

it("pretty nullish", async () => {
await page.evaluate(() => {
// @ts-ignore
const logger = new tslog.Logger({ type: "pretty", stylePrettyLogs: false });
logger.info({ foo: null, bar: undefined });
});
expect(consoleOutput).toContain("null");
expect(consoleOutput).toContain("undefined");
});
});
6 changes: 6 additions & 0 deletions tests/Nodejs/5_pretty_Log_Types.test.ts
Expand Up @@ -45,6 +45,12 @@ describe("Pretty: Log Types", () => {
expect(getConsoleLog()).toContain("555");
});

test("null", (): void => {
const logger = new Logger({ type: "pretty" });
logger.log(1234, "testLevel", null);
expect(getConsoleLog()).toContain("null");
});

test("Array, stylePrettyLogs: false", (): void => {
const logger = new Logger({ type: "pretty", stylePrettyLogs: false });
logger.log(1234, "testLevel", [1, 2, 3, "test"]);
Expand Down

0 comments on commit 3044fce

Please sign in to comment.