diff options
author | Rich Trott <rtrott@gmail.com> | 2017-08-23 20:36:54 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-08-25 11:29:33 -0700 |
commit | af11867b4180b033320e4f0c7d52c2bcfb957852 (patch) | |
tree | 066a75b82d826a6ec85efd8858995e724619f167 /test/parallel/test-console-group.js | |
parent | a1d34b3f491ce8e9c34cbc5ddf4e9052b0ed0a01 (diff) | |
download | android-node-v8-af11867b4180b033320e4f0c7d52c2bcfb957852.tar.gz android-node-v8-af11867b4180b033320e4f0c7d52c2bcfb957852.tar.bz2 android-node-v8-af11867b4180b033320e4f0c7d52c2bcfb957852.zip |
console: improve console.group()
Preserve indentation for multiline strings, objects that span multiple
lines, etc.
also make groupIndent non-enumerable
Hide the internal `groupIndent` key a bit by making it non-enumerable
and non-configurable.
PR-URL: https://github.com/nodejs/node/pull/14999
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Diffstat (limited to 'test/parallel/test-console-group.js')
-rw-r--r-- | test/parallel/test-console-group.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/parallel/test-console-group.js b/test/parallel/test-console-group.js index 8f7d84f2f1..8486d1a7ac 100644 --- a/test/parallel/test-console-group.js +++ b/test/parallel/test-console-group.js @@ -109,3 +109,39 @@ function teardown() { assert.strictEqual(stderr, expectedErr); teardown(); } + +// Check that multiline strings and object output are indented properly. +{ + setup(); + const expectedOut = 'not indented\n' + + ' indented\n' + + ' also indented\n' + + " { also: 'a',\n" + + " multiline: 'object',\n" + + " should: 'be',\n" + + " indented: 'properly',\n" + + " kthx: 'bai' }\n"; + const expectedErr = ''; + + c.log('not indented'); + c.group(); + c.log('indented\nalso indented'); + c.log({ also: 'a', + multiline: 'object', + should: 'be', + indented: 'properly', + kthx: 'bai' }); + + assert.strictEqual(stdout, expectedOut); + assert.strictEqual(stderr, expectedErr); + teardown(); +} + +// Check that the kGroupIndent symbol property is not enumerable +{ + const keys = Reflect.ownKeys(console) + .filter((val) => console.propertyIsEnumerable(val)) + .map((val) => val.toString()); + assert(!keys.includes('Symbol(groupIndent)'), + 'groupIndent should not be enumerable'); +} |