Files
klz-cables.com/.pnpm-store/v10/files/16/f03089316b5b9d08f782f5afe8522e0e342899c8f74081041c9bca1c0a439b81b233a51a68dab50f5a5e1bbd4f7febbdb81fc401c2f545904306d1d771b91b
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

133 lines
2.7 KiB
Plaintext

'use strict'
const test = require('tape')
const pino = require('../browser')
test('child has parent level', ({ end, same, is }) => {
const instance = pino({
level: 'error',
browser: {}
})
const child = instance.child({})
same(child.level, instance.level)
end()
})
test('child can set level at creation time', ({ end, same, is }) => {
const instance = pino({
level: 'error',
browser: {}
})
const child = instance.child({}, { level: 'info' }) // first bindings, then options
same(child.level, 'info')
end()
})
test('changing child level does not affect parent', ({ end, same, is }) => {
const instance = pino({
level: 'error',
browser: {}
})
const child = instance.child({})
child.level = 'info'
same(instance.level, 'error')
end()
})
test('child should log, if its own level allows it', ({ end, same, is }) => {
const expected = [
{
level: 30,
msg: 'this is info'
},
{
level: 40,
msg: 'this is warn'
},
{
level: 50,
msg: 'this is an error'
}
]
const instance = pino({
level: 'error',
browser: {
write (actual) {
checkLogObjects(is, same, actual, expected.shift())
}
}
})
const child = instance.child({})
child.level = 'info'
child.debug('this is debug')
child.info('this is info')
child.warn('this is warn')
child.error('this is an error')
same(expected.length, 0, 'not all messages were read')
end()
})
test('changing child log level should not affect parent log behavior', ({ end, same, is }) => {
const expected = [
{
level: 50,
msg: 'this is an error'
},
{
level: 60,
msg: 'this is fatal'
}
]
const instance = pino({
level: 'error',
browser: {
write (actual) {
checkLogObjects(is, same, actual, expected.shift())
}
}
})
const child = instance.child({})
child.level = 'info'
instance.warn('this is warn')
instance.error('this is an error')
instance.fatal('this is fatal')
same(expected.length, 0, 'not all messages were read')
end()
})
test('onChild callback should be called when new child is created', ({ end, pass, plan }) => {
plan(1)
const instance = pino({
level: 'error',
browser: {},
onChild: (_child) => {
pass('onChild callback was called')
end()
}
})
instance.child({})
})
function checkLogObjects (is, same, actual, expected) {
is(actual.time <= Date.now(), true, 'time is greater than Date.now()')
const actualCopy = Object.assign({}, actual)
const expectedCopy = Object.assign({}, expected)
delete actualCopy.time
delete expectedCopy.time
same(actualCopy, expectedCopy)
}