From 86dc55134ef25c1bc4f8db6c3c0dc635c1660ea4 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Mon, 12 Oct 2020 03:52:20 +0800 Subject: fix(cli/console): only inspect getters with option (#7830) --- cli/tests/unit/console_test.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'cli/tests/unit/console_test.ts') diff --git a/cli/tests/unit/console_test.ts b/cli/tests/unit/console_test.ts index 46798fdf3..df1420345 100644 --- a/cli/tests/unit/console_test.ts +++ b/cli/tests/unit/console_test.ts @@ -1494,14 +1494,32 @@ unitTest(function inspectString(): void { ); }); -unitTest(function inspectGetterError(): void { +unitTest(function inspectGetters(): void { + assertEquals( + stripColor(Deno.inspect({ + get foo() { + return 0; + }, + })), + "{ foo: [Getter] }", + ); + + assertEquals( + stripColor(Deno.inspect({ + get foo() { + return 0; + }, + }, { getters: true })), + "{ foo: 0 }", + ); + assertEquals( Deno.inspect({ // deno-lint-ignore getter-return get foo() { throw new Error("bar"); }, - }), + }, { getters: true }), "{ foo: [Thrown Error: bar] }", ); }); -- cgit v1.2.3