diff options
author | David DeSimone <lord.good.mail@gmail.com> | 2021-02-10 03:52:54 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-10 20:52:54 +0900 |
commit | 61108935f16bd2aa60d51525e3578719425eef03 (patch) | |
tree | 5bed537dca04d1a84dd8d59032cd67a45ee78645 /cli/tests/unit | |
parent | 6752be05cda38dc6188bacc73fb8eb7c01560c97 (diff) |
fix(console): log function object properties / do not log non-enumerable props by default (#9363)
Diffstat (limited to 'cli/tests/unit')
-rw-r--r-- | cli/tests/unit/console_test.ts | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/cli/tests/unit/console_test.ts b/cli/tests/unit/console_test.ts index fc23b1d70..286b693ff 100644 --- a/cli/tests/unit/console_test.ts +++ b/cli/tests/unit/console_test.ts @@ -310,7 +310,7 @@ unitTest(function consoleTestStringifyCircular(): void { assertEquals(stringify(nestedObj), nestedObjExpected); assertEquals( stringify(JSON), - 'JSON { [Symbol(Symbol.toStringTag)]: "JSON" }', + "JSON {}", ); assertEquals( stringify(console), @@ -335,7 +335,6 @@ unitTest(function consoleTestStringifyCircular(): void { clear: [Function: clear], trace: [Function: trace], indentLevel: 0, - [Symbol(Symbol.toStringTag)]: "console", [Symbol(isConsoleInstance)]: true }`, ); @@ -362,6 +361,50 @@ unitTest(function consoleTestStringifyFunctionWithPrototypeRemoved(): void { assertEquals(stringify(agf), "[Function: agf]"); }); +unitTest(function consoleTestStringifyFunctionWithProperties(): void { + const f = () => "test"; + f.x = () => "foo"; + f.y = 3; + f.z = () => "baz"; + f.b = function bar() {}; + f.a = new Map(); + assertEquals( + stringify({ f }), + `{ + f: [Function: f] { x: [Function], y: 3, z: [Function], b: [Function: bar], a: Map {} } +}`, + ); + + const t = () => {}; + t.x = f; + f.s = f; + f.t = t; + assertEquals( + stringify({ f }), + `{ + f: [Function: f] { + x: [Function], + y: 3, + z: [Function], + b: [Function: bar], + a: Map {}, + s: [Circular], + t: [Function: t] { x: [Circular] } + } +}`, + ); + + assertEquals( + stringify(Array), + `[Function: Array]`, + ); + + assertEquals( + stripColor(Deno.inspect(Array, { showHidden: true })), + `[Function: Array] { [Symbol(Symbol.species)]: [Getter] }`, + ); +}); + unitTest(function consoleTestStringifyWithDepth(): void { // deno-lint-ignore no-explicit-any const nestedObj: any = { a: { b: { c: { d: { e: { f: 42 } } } } } }; |