mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
feat(ext/console): Add string abbreviation size option for "Deno.inspect" (#14384)
This commit is contained in:
parent
6dcf3a447c
commit
ddbfa1418c
3 changed files with 28 additions and 2 deletions
|
@ -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 ..." ]',
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue