From c8785e7b24309f8874379d91ee4cd02650c1f178 Mon Sep 17 00:00:00 2001 From: Andrey Osiyuk Date: Wed, 24 Apr 2024 20:51:33 +0200 Subject: [PATCH] Add test for Object.create(null) --- test/basic.test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/basic.test.js b/test/basic.test.js index 9986811c..c276bca1 100644 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -27,6 +27,9 @@ function prettyFactory (opts) { return _prettyFactory(opts) } +const Empty = function () {} +Empty.prototype = Object.create(null) + // All dates are computed from 'Fri, 30 Mar 2018 17:35:28 GMT' const epoch = 1522431328992 const formattedEpoch = '17:35:28.992' @@ -883,6 +886,22 @@ test('basic prettifier tests', (t) => { t.equal(arst, `[${formattedEpoch}] INFO: hello world\n`) }) + t.test('inlude a single key with null object', (t) => { + t.plan(1) + const pretty = prettyFactory({ include: 'level' }) + const obj = new Empty() + obj.nested = 'property' + const arst = pretty({ + msg: 'hello world', + pid: `${pid}`, + hostname, + time: epoch, + obj, + level: 30 + }) + t.equal(arst, 'INFO: hello world\n') + }) + t.test('prettifies trace caller', (t) => { t.plan(1) const traceCaller = (instance) => {