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
48 lines
1.2 KiB
Plaintext
48 lines
1.2 KiB
Plaintext
'use strict'
|
|
|
|
const { test } = require('node:test')
|
|
const handleCustomLevelsOpts = require('./handle-custom-levels-opts')
|
|
|
|
test('returns a empty object `{}` for undefined parameter', t => {
|
|
const handledCustomLevel = handleCustomLevelsOpts()
|
|
t.assert.deepStrictEqual(handledCustomLevel, {})
|
|
})
|
|
|
|
test('returns a empty object `{}` for unknown parameter', t => {
|
|
const handledCustomLevel = handleCustomLevelsOpts(123)
|
|
t.assert.deepStrictEqual(handledCustomLevel, {})
|
|
})
|
|
|
|
test('returns a filled object for string parameter', t => {
|
|
const handledCustomLevel = handleCustomLevelsOpts('ok:10,warn:20,error:35')
|
|
t.assert.deepStrictEqual(handledCustomLevel, {
|
|
10: 'OK',
|
|
20: 'WARN',
|
|
35: 'ERROR',
|
|
default: 'USERLVL'
|
|
})
|
|
})
|
|
|
|
test('returns a filled object for object parameter', t => {
|
|
const handledCustomLevel = handleCustomLevelsOpts({
|
|
ok: 10,
|
|
warn: 20,
|
|
error: 35
|
|
})
|
|
t.assert.deepStrictEqual(handledCustomLevel, {
|
|
10: 'OK',
|
|
20: 'WARN',
|
|
35: 'ERROR',
|
|
default: 'USERLVL'
|
|
})
|
|
})
|
|
|
|
test('defaults missing level num to first index', t => {
|
|
const result = handleCustomLevelsOpts('ok:10,info')
|
|
t.assert.deepStrictEqual(result, {
|
|
10: 'OK',
|
|
1: 'INFO',
|
|
default: 'USERLVL'
|
|
})
|
|
})
|