Skip to content

Commit

Permalink
Add test for Object.create(null)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisands committed Apr 24, 2024
1 parent b67b7c4 commit c8785e7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit c8785e7

Please sign in to comment.