Files
boc/services/frilans-payout/node_modules/pino-pretty/lib/utils/handle-custom-levels-opts.test.js
T
Bernt 1a12fb870b dev-api: add developer portal, OpenAPI spec, and Flatenbadet case study
- New /developers/ page with API docs, SDKs, pricing, use cases
- OpenAPI 3.0 spec for Orders, Missions, Photos, Analytics
- Case study: Glasskiosken i Flatenbadet — complete ROI analysis
- Updated /order/ with recurring missions and frequency dropdown
2026-07-14 15:27:33 +00:00

48 lines
1.2 KiB
JavaScript

'use strict'
const tap = require('tap')
const handleCustomLevelsOpts = require('./handle-custom-levels-opts')
tap.test('returns a empty object `{}` for undefined parameter', async t => {
const handledCustomLevel = handleCustomLevelsOpts()
t.same(handledCustomLevel, {})
})
tap.test('returns a empty object `{}` for unknown parameter', async t => {
const handledCustomLevel = handleCustomLevelsOpts(123)
t.same(handledCustomLevel, {})
})
tap.test('returns a filled object for string parameter', async t => {
const handledCustomLevel = handleCustomLevelsOpts('ok:10,warn:20,error:35')
t.same(handledCustomLevel, {
10: 'OK',
20: 'WARN',
35: 'ERROR',
default: 'USERLVL'
})
})
tap.test('returns a filled object for object parameter', async t => {
const handledCustomLevel = handleCustomLevelsOpts({
ok: 10,
warn: 20,
error: 35
})
t.same(handledCustomLevel, {
10: 'OK',
20: 'WARN',
35: 'ERROR',
default: 'USERLVL'
})
})
tap.test('defaults missing level num to first index', async t => {
const result = handleCustomLevelsOpts('ok:10,info')
t.same(result, {
10: 'OK',
1: 'INFO',
default: 'USERLVL'
})
})