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
46 lines
1.2 KiB
Plaintext
46 lines
1.2 KiB
Plaintext
'use strict'
|
|
|
|
const { test } = require('node:test')
|
|
const match = require('@jsumners/assert-match')
|
|
const handleCustomLevelsNamesOpts = require('./handle-custom-levels-names-opts')
|
|
|
|
test('returns a empty object `{}` for undefined parameter', t => {
|
|
const handledCustomLevelNames = handleCustomLevelsNamesOpts()
|
|
t.assert.deepStrictEqual(handledCustomLevelNames, {})
|
|
})
|
|
|
|
test('returns a empty object `{}` for unknown parameter', t => {
|
|
const handledCustomLevelNames = handleCustomLevelsNamesOpts(123)
|
|
t.assert.deepStrictEqual(handledCustomLevelNames, {})
|
|
})
|
|
|
|
test('returns a filled object for string parameter', t => {
|
|
const handledCustomLevelNames = handleCustomLevelsNamesOpts('ok:10,warn:20,error:35')
|
|
match(handledCustomLevelNames, {
|
|
ok: 10,
|
|
warn: 20,
|
|
error: 35
|
|
}, t)
|
|
})
|
|
|
|
test('returns a filled object for object parameter', t => {
|
|
const handledCustomLevelNames = handleCustomLevelsNamesOpts({
|
|
ok: 10,
|
|
warn: 20,
|
|
error: 35
|
|
})
|
|
match(handledCustomLevelNames, {
|
|
ok: 10,
|
|
warn: 20,
|
|
error: 35
|
|
}, t)
|
|
})
|
|
|
|
test('defaults missing level num to first index', t => {
|
|
const result = handleCustomLevelsNamesOpts('ok:10,info')
|
|
match(result, {
|
|
ok: 10,
|
|
info: 1
|
|
}, t)
|
|
})
|