From ddbfa1418c5ec2805a565caa07f7eec6af1deb39 Mon Sep 17 00:00:00 2001 From: Ben Heidemann <56122437+bcheidemann@users.noreply.github.com> Date: Mon, 25 Apr 2022 12:59:15 +0100 Subject: feat(ext/console): Add string abbreviation size option for "Deno.inspect" (#14384) --- cli/tests/unit/console_test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'cli/tests') diff --git a/cli/tests/unit/console_test.ts b/cli/tests/unit/console_test.ts index d1c570e1b..39baaf1a3 100644 --- a/cli/tests/unit/console_test.ts +++ b/cli/tests/unit/console_test.ts @@ -1938,3 +1938,22 @@ Deno.test(function inspectColors() { assertEquals(Deno.inspect(1), "1"); assertStringIncludes(Deno.inspect(1, { colors: true }), "\x1b["); }); + +Deno.test(function inspectStringAbbreviation() { + const LONG_STRING = + "This is a really long string which will be abbreviated with ellipsis."; + const obj = { + str: LONG_STRING, + }; + const arr = [LONG_STRING]; + + assertEquals( + Deno.inspect(obj, { strAbbreviateSize: 10 }), + '{ str: "This is a ..." }', + ); + + assertEquals( + Deno.inspect(arr, { strAbbreviateSize: 10 }), + '[ "This is a ..." ]', + ); +}); -- cgit v1.2.3